diff --git a/lib/app/modules/all_tasks.dart b/lib/app/modules/all_tasks.dart index 1a12605..8910fef 100644 --- a/lib/app/modules/all_tasks.dart +++ b/lib/app/modules/all_tasks.dart @@ -89,13 +89,15 @@ class _AllTaskPageState extends State { ], ), ), - TodosList( - calendare: false, - allTask: true, - toggle: service.toggleValue.value, - set: () { - getCountTodos(); - }, + Expanded( + child: TodosList( + calendare: false, + allTask: true, + toggle: service.toggleValue.value, + set: () { + getCountTodos(); + }, + ), ), ], ), diff --git a/lib/app/modules/calendar.dart b/lib/app/modules/calendar.dart index c9ef4bc..b2d7411 100644 --- a/lib/app/modules/calendar.dart +++ b/lib/app/modules/calendar.dart @@ -1,4 +1,5 @@ import 'package:isar/isar.dart'; +import 'package:swipe/swipe.dart'; import 'package:todark/app/data/schema.dart'; import 'package:todark/app/services/isar_service.dart'; import 'package:flutter/material.dart'; @@ -18,6 +19,8 @@ class _CalendarPageState extends State { final service = IsarServices(); final locale = Get.locale; DateTime selectedDay = DateTime.now(); + DateTime firstDay = DateTime.now().add(const Duration(days: -1000)); + DateTime lastDay = DateTime.now().add(const Duration(days: 1000)); CalendarFormat calendarFormat = CalendarFormat.week; var todos = []; @@ -98,8 +101,8 @@ class _CalendarPageState extends State { }, ), startingDayOfWeek: StartingDayOfWeek.monday, - firstDay: DateTime(2022, 09, 01), - lastDay: selectedDay.add(const Duration(days: 1000)), + firstDay: firstDay, + lastDay: lastDay, focusedDay: selectedDay, locale: '${locale?.languageCode}', weekendDays: const [DateTime.sunday], @@ -183,15 +186,32 @@ class _CalendarPageState extends State { ], ), ), - TodosList( - calendare: true, - allTask: false, - toggle: service.toggleValue.value, - selectedDay: selectedDay, - set: () { - getCountTodos(); - getTodosAll(); - }, + Expanded( + child: Swipe( + horizontalMinDisplacement: 20, + onSwipeLeft: () { + if (selectedDay.isBefore(lastDay)) { + selectedDay = selectedDay.add(const Duration(days: 1)); + setState(() {}); + } + }, + onSwipeRight: () { + if (selectedDay.isAfter(firstDay)) { + selectedDay = selectedDay.add(const Duration(days: -1)); + setState(() {}); + } + }, + child: TodosList( + calendare: true, + allTask: false, + toggle: service.toggleValue.value, + selectedDay: selectedDay, + set: () { + getCountTodos(); + getTodosAll(); + }, + ), + ), ), ], ), diff --git a/lib/app/modules/home.dart b/lib/app/modules/home.dart index 2d8d77a..45918f7 100644 --- a/lib/app/modules/home.dart +++ b/lib/app/modules/home.dart @@ -26,6 +26,7 @@ class _HomePageState extends State { appBar: AppBar( automaticallyImplyLeading: false, backgroundColor: Colors.transparent, + surfaceTintColor: Colors.transparent, elevation: 0, titleSpacing: 30, title: Row( diff --git a/lib/app/modules/tasks.dart b/lib/app/modules/tasks.dart index daa39a5..7c61586 100644 --- a/lib/app/modules/tasks.dart +++ b/lib/app/modules/tasks.dart @@ -193,14 +193,16 @@ class _TaskPageState extends State { ], ), ), - TodosList( - allTask: false, - calendare: false, - toggle: service.toggleValue.value, - task: widget.task, - set: () { - getCountTodos(); - }, + Expanded( + child: TodosList( + allTask: false, + calendare: false, + toggle: service.toggleValue.value, + task: widget.task, + set: () { + getCountTodos(); + }, + ), ), ], ), diff --git a/lib/app/widgets/task_type_cu.dart b/lib/app/widgets/task_type_cu.dart index 252305c..1e4d2f2 100644 --- a/lib/app/widgets/task_type_cu.dart +++ b/lib/app/widgets/task_type_cu.dart @@ -106,7 +106,7 @@ class _TaskTypeCuState extends State { }, icon: const Icon( Icons.save, - color: Colors.blue, + color: Colors.white, ), ), ], diff --git a/lib/app/widgets/todos_ce.dart b/lib/app/widgets/todos_ce.dart index 918c75c..b44351c 100644 --- a/lib/app/widgets/todos_ce.dart +++ b/lib/app/widgets/todos_ce.dart @@ -112,44 +112,6 @@ class _TodosCeState extends State { ], ), ), - IconButton( - onPressed: () { - if (formKey.currentState!.validate()) { - textTrim(service.titleEdit.value); - textTrim(service.descEdit.value); - widget.category == false - ? service.addTodo( - widget.task!, - service.titleEdit.value, - service.descEdit.value, - service.timeEdit.value, - widget.set, - ) - : widget.edit == false - ? service.addTodo( - selectedTask!, - service.titleEdit.value, - service.descEdit.value, - service.timeEdit.value, - widget.set, - ) - : service.updateTodo( - widget.todo!, - selectedTask!, - service.titleEdit.value, - service.descEdit.value, - service.timeEdit.value, - widget.set, - ); - textConroller.clear(); - Get.back(); - } - }, - icon: const Icon( - Icons.save, - color: Colors.blue, - ), - ), ], ), ), @@ -261,45 +223,101 @@ class _TodosCeState extends State { type: TextInputType.text, icon: const Icon(Iconsax.note_text), ), - MyTextForm( - readOnly: true, - textEditingController: service.timeEdit.value, - hintText: 'timeComlete'.tr, - type: TextInputType.datetime, - icon: const Icon(Iconsax.clock), - iconButton: IconButton( - icon: const Icon( - Icons.close, - size: 18, + Row( + children: [ + Flexible( + flex: 5, + child: MyTextForm( + readOnly: true, + textEditingController: service.timeEdit.value, + hintText: 'timeComlete'.tr, + type: TextInputType.datetime, + icon: const Icon(Iconsax.clock), + iconButton: IconButton( + icon: const Icon( + Icons.close, + size: 18, + ), + onPressed: () { + service.timeEdit.value.clear(); + }, + ), + onTap: () { + DatePicker.showDateTimePicker( + context, + showTitleActions: true, + theme: DatePickerTheme( + backgroundColor: + context.theme.scaffoldBackgroundColor, + cancelStyle: const TextStyle(color: Colors.red), + itemStyle: const TextStyle( + color: Colors.white, + ), + ), + minTime: DateTime.now(), + maxTime: + DateTime.now().add(const Duration(days: 1000)), + onConfirm: (date) { + service.timeEdit.value.text = date.toString(); + }, + currentTime: DateTime.now(), + locale: '${locale?.languageCode}' == 'ru' + ? LocaleType.ru + : '${locale?.languageCode}' == 'zh' + ? LocaleType.zh + : LocaleType.en, + ); + }, + ), ), - onPressed: () { - service.timeEdit.value.clear(); - }, - ), - onTap: () { - DatePicker.showDateTimePicker( - context, - showTitleActions: true, - theme: DatePickerTheme( - backgroundColor: context.theme.scaffoldBackgroundColor, - cancelStyle: const TextStyle(color: Colors.red), - itemStyle: const TextStyle( - color: Colors.white, + Flexible( + child: Container( + margin: + const EdgeInsets.only(right: 10, bottom: 5, top: 10), + decoration: const BoxDecoration( + color: Colors.deepPurple, + borderRadius: BorderRadius.all(Radius.circular(15))), + child: IconButton( + onPressed: () { + if (formKey.currentState!.validate()) { + textTrim(service.titleEdit.value); + textTrim(service.descEdit.value); + widget.category == false + ? service.addTodo( + widget.task!, + service.titleEdit.value, + service.descEdit.value, + service.timeEdit.value, + widget.set, + ) + : widget.edit == false + ? service.addTodo( + selectedTask!, + service.titleEdit.value, + service.descEdit.value, + service.timeEdit.value, + widget.set, + ) + : service.updateTodo( + widget.todo!, + selectedTask!, + service.titleEdit.value, + service.descEdit.value, + service.timeEdit.value, + widget.set, + ); + textConroller.clear(); + Get.back(); + } + }, + icon: const Icon( + Iconsax.send_1, + color: Colors.white, + ), ), ), - minTime: DateTime.now(), - maxTime: DateTime.now().add(const Duration(days: 1000)), - onConfirm: (date) { - service.timeEdit.value.text = date.toString(); - }, - currentTime: DateTime.now(), - locale: '${locale?.languageCode}' == 'ru' - ? LocaleType.ru - : '${locale?.languageCode}' == 'zh' - ? LocaleType.zh - : LocaleType.en, - ); - }, + ), + ], ), const SizedBox(height: 20), ], diff --git a/lib/app/widgets/todos_list.dart b/lib/app/widgets/todos_list.dart index 900c62d..ee59141 100644 --- a/lib/app/widgets/todos_list.dart +++ b/lib/app/widgets/todos_list.dart @@ -43,277 +43,268 @@ class _TodosListState extends State { return Colors.black; } - return Expanded( - child: StreamBuilder>( - stream: widget.allTask == true - ? service.getAllTodo(widget.toggle) - : widget.calendare == true - ? service.getCalendarTodo(widget.toggle, widget.selectedDay!) - : service.getTodo(widget.toggle, widget.task!), - builder: (BuildContext context, AsyncSnapshot> listData) { - switch (listData.connectionState) { - case ConnectionState.done: - default: - if (listData.hasData) { - final todos = listData.data!; - if (todos.isEmpty) { - return Center( - child: SingleChildScrollView( - child: Column( - children: [ - Image.asset( - 'assets/images/AddTasks.png', - scale: 5, + return StreamBuilder>( + stream: widget.allTask == true + ? service.getAllTodo(widget.toggle) + : widget.calendare == true + ? service.getCalendarTodo(widget.toggle, widget.selectedDay!) + : service.getTodo(widget.toggle, widget.task!), + builder: (BuildContext context, AsyncSnapshot> listData) { + switch (listData.connectionState) { + case ConnectionState.done: + default: + if (listData.hasData) { + final todos = listData.data!; + if (todos.isEmpty) { + return Center( + child: SingleChildScrollView( + child: Column( + children: [ + Image.asset( + 'assets/images/AddTasks.png', + scale: 5, + ), + Text( + widget.toggle == true + ? 'copletedTask'.tr + : 'addTask'.tr, + style: context.theme.textTheme.titleLarge?.copyWith( + color: Colors.black, ), - Text( - widget.toggle == true - ? 'copletedTask'.tr - : 'addTask'.tr, - style: context.theme.textTheme.titleLarge?.copyWith( - color: Colors.black, - ), - ), - ], - ), + ), + ], ), - ); - } - return StatefulBuilder( - builder: (context, innerState) { - return ListView.builder( - physics: const BouncingScrollPhysics(), - itemCount: listData.data?.length, - itemBuilder: (BuildContext context, int index) { - final todosList = todos[index]; - return Dismissible( - key: ObjectKey(todosList), - direction: DismissDirection.endToStart, - confirmDismiss: (DismissDirection direction) async { - return await showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - backgroundColor: context - .theme.colorScheme.primaryContainer, - title: Text( - "deletedTask".tr, - style: context.theme.textTheme.titleLarge, - ), - content: Text("deletedTaskQuery".tr, - style: - context.theme.textTheme.titleMedium), - actions: [ - TextButton( - onPressed: () => - Get.back(result: false), - child: Text("cancel".tr, - style: context - .theme.textTheme.titleMedium - ?.copyWith( - color: Colors.blueAccent))), - TextButton( - onPressed: () => Get.back(result: true), - child: Text("delete".tr, - style: context - .theme.textTheme.titleMedium - ?.copyWith(color: Colors.red))), - ], - ); - }, - ); - }, - onDismissed: (DismissDirection direction) { - service.deleteTodo(todosList, widget.set); - }, - background: Container( - alignment: Alignment.centerRight, - child: const Padding( - padding: EdgeInsets.only( - right: 15, - ), - child: Icon( - Iconsax.trush_square, - color: Colors.red, - ), + ), + ); + } + return StatefulBuilder( + builder: (context, innerState) { + return ListView.builder( + physics: const BouncingScrollPhysics(), + itemCount: listData.data?.length, + itemBuilder: (BuildContext context, int index) { + final todosList = todos[index]; + return Dismissible( + key: ObjectKey(todosList), + direction: DismissDirection.endToStart, + confirmDismiss: (DismissDirection direction) async { + return await showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + backgroundColor: + context.theme.colorScheme.primaryContainer, + title: Text( + "deletedTask".tr, + style: context.theme.textTheme.titleLarge, + ), + content: Text("deletedTaskQuery".tr, + style: context.theme.textTheme.titleMedium), + actions: [ + TextButton( + onPressed: () => Get.back(result: false), + child: Text("cancel".tr, + style: context + .theme.textTheme.titleMedium + ?.copyWith( + color: Colors.blueAccent))), + TextButton( + onPressed: () => Get.back(result: true), + child: Text("delete".tr, + style: context + .theme.textTheme.titleMedium + ?.copyWith(color: Colors.red))), + ], + ); + }, + ); + }, + onDismissed: (DismissDirection direction) { + service.deleteTodo(todosList, widget.set); + }, + background: Container( + alignment: Alignment.centerRight, + child: const Padding( + padding: EdgeInsets.only( + right: 15, ), - ), - child: Container( - margin: const EdgeInsets.only( - right: 20, left: 20, bottom: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - // color: Colors.white, + child: Icon( + Iconsax.trush_square, + color: Colors.red, ), - child: InkWell( - onTap: () { - showModalBottomSheet( - enableDrag: false, - backgroundColor: - context.theme.scaffoldBackgroundColor, - context: context, - isScrollControlled: true, - builder: (BuildContext context) { - return TodosCe( - text: 'editing'.tr, - edit: true, - todo: todosList, - category: true, - set: widget.set, - ); - }, - ); - }, - child: Row( - children: [ - Flexible( - child: Row( - children: [ - Checkbox( - checkColor: Colors.white, - fillColor: - MaterialStateProperty.resolveWith( - getColor), - value: todosList.done, - shape: const CircleBorder(), - onChanged: (val) { - innerState(() { - todosList.done = val!; - }); - todosList.done == true - ? flutterLocalNotificationsPlugin - .cancel(todosList.id) - : todosList.todoCompletedTime != - null - ? NotificationShow() - .showNotification( - todosList.id, - todosList.name, - todosList.description, - todosList - .todoCompletedTime, - ) - : null; - Future.delayed( - const Duration(milliseconds: 300), - () { - service.updateTodoCheck( - todosList, widget.set); - }, - ); - }, - ), - Expanded( - child: Padding( - padding: const EdgeInsets.only( - right: 10), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - todosList.name, - style: context.theme.textTheme - .titleLarge - ?.copyWith( - fontWeight: FontWeight.w600, - fontSize: 18, - color: todosList.todoCompletedTime != - null && - DateTime.now() - .isAfter(todosList - .todoCompletedTime!) && - todosList.done == - false - ? Colors.redAccent - : Colors.black, - ), - overflow: - TextOverflow.visible, + ), + ), + child: Container( + margin: const EdgeInsets.only( + right: 20, left: 20, bottom: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + // color: Colors.white, + ), + child: InkWell( + onTap: () { + showModalBottomSheet( + enableDrag: false, + backgroundColor: + context.theme.scaffoldBackgroundColor, + context: context, + isScrollControlled: true, + builder: (BuildContext context) { + return TodosCe( + text: 'editing'.tr, + edit: true, + todo: todosList, + category: true, + set: widget.set, + ); + }, + ); + }, + child: Row( + children: [ + Flexible( + child: Row( + children: [ + Checkbox( + checkColor: Colors.white, + fillColor: + MaterialStateProperty.resolveWith( + getColor), + value: todosList.done, + shape: const CircleBorder(), + onChanged: (val) { + innerState(() { + todosList.done = val!; + }); + todosList.done == true + ? flutterLocalNotificationsPlugin + .cancel(todosList.id) + : todosList.todoCompletedTime != + null + ? NotificationShow() + .showNotification( + todosList.id, + todosList.name, + todosList.description, + todosList + .todoCompletedTime, + ) + : null; + Future.delayed( + const Duration(milliseconds: 300), + () { + service.updateTodoCheck( + todosList, widget.set); + }, + ); + }, + ), + Expanded( + child: Padding( + padding: + const EdgeInsets.only(right: 10), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + todosList.name, + style: context + .theme.textTheme.titleLarge + ?.copyWith( + fontWeight: FontWeight.w600, + fontSize: 18, + color: todosList.todoCompletedTime != + null && + DateTime.now() + .isAfter(todosList + .todoCompletedTime!) && + todosList.done == + false + ? Colors.redAccent + : Colors.black, ), - todosList.description.isNotEmpty - ? Text( - todosList.description, - style: context.theme - .textTheme.bodyLarge - ?.copyWith( - fontSize: 12, - color: - Colors.grey[700], - ), - overflow: TextOverflow - .visible, - ) - : Container(), - todosList.todoCompletedTime != - null && - widget.calendare == - false - ? Text( - todosList.todoCompletedTime != - null - ? DateFormat( - 'dd MMM yyyy HH:mm', - '${locale?.languageCode}', - ).format(todosList - .todoCompletedTime!) - : '', - style: context.theme - .textTheme.bodyLarge - ?.copyWith( - color: Colors - .deepPurple), - ) - : Container(), - ], - ), + overflow: TextOverflow.visible, + ), + todosList.description.isNotEmpty + ? Text( + todosList.description, + style: context.theme + .textTheme.bodyLarge + ?.copyWith( + fontSize: 12, + color: Colors.grey[700], + ), + overflow: + TextOverflow.visible, + ) + : Container(), + todosList.todoCompletedTime != + null && + widget.calendare == false + ? Text( + todosList.todoCompletedTime != + null + ? DateFormat( + 'dd MMM yyyy HH:mm', + '${locale?.languageCode}', + ).format(todosList + .todoCompletedTime!) + : '', + style: context.theme + .textTheme.bodyLarge + ?.copyWith( + color: Colors + .deepPurple), + ) + : Container(), + ], ), ), - ], - ), + ), + ], ), - widget.allTask == true - ? Text( - todosList.task.value!.title.length > - 10 - ? todosList.task.value!.title - .substring(0, 10) - : todosList.task.value!.title, - style: context - .theme.textTheme.bodyLarge - ?.copyWith( - color: Colors.grey[700], - fontSize: 12, - ), - ) - : widget.calendare == true - ? Text( - '${todosList.task.value!.title.length > 10 ? todosList.task.value!.title.substring(0, 10) : todosList.task.value!.title}\n${DateFormat( - 'HH:mm', - '${locale?.languageCode}', - ).format(todosList.todoCompletedTime!)}', - style: context - .theme.textTheme.bodyLarge - ?.copyWith( - color: Colors.grey[700], - fontSize: 12, - ), - ) - : Container(), - ], - ), + ), + widget.allTask == true + ? Text( + todosList.task.value!.title.length > 10 + ? todosList.task.value!.title + .substring(0, 10) + : todosList.task.value!.title, + style: context.theme.textTheme.bodyLarge + ?.copyWith( + color: Colors.grey[700], + fontSize: 12, + ), + ) + : widget.calendare == true + ? Text( + '${todosList.task.value!.title.length > 10 ? todosList.task.value!.title.substring(0, 10) : todosList.task.value!.title}\n${DateFormat( + 'HH:mm', + '${locale?.languageCode}', + ).format(todosList.todoCompletedTime!)}', + style: context + .theme.textTheme.bodyLarge + ?.copyWith( + color: Colors.grey[700], + fontSize: 12, + ), + ) + : Container(), + ], ), ), - ); - }, - ); - }, - ); - } else { - return const Center(child: CircularProgressIndicator()); - } - } - }, - ), + ), + ); + }, + ); + }, + ); + } else { + return const Center(child: CircularProgressIndicator()); + } + } + }, ); } } diff --git a/pubspec.lock b/pubspec.lock index a517ee7..f5c6307 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -810,6 +810,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + swipe: + dependency: "direct main" + description: + name: swipe + sha256: e2f823093ef0161698cc380f5f868a6be380cb5c90c1c0ddc7fa2b0a7eadfa0e + url: "https://pub.dev" + source: hosted + version: "0.0.1" table_calendar: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 729fb75..8408fa4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. publish_to: 'none' -version: 1.2.6+16 +version: 1.2.7+17 environment: sdk: ">=2.17.6 <3.0.0" @@ -16,6 +16,7 @@ dependencies: get: ^4.6.5 isar: ^3.0.5 intl: ^0.17.0 + swipe: ^0.0.1 iconsax: ^0.0.8 path_provider: ^2.0.11 table_calendar: ^3.0.8