Skip to content

Commit

Permalink
swipe, fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonavichus committed Jan 30, 2023
1 parent a569470 commit 263d51b
Show file tree
Hide file tree
Showing 9 changed files with 406 additions and 363 deletions.
16 changes: 9 additions & 7 deletions lib/app/modules/all_tasks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ class _AllTaskPageState extends State<AllTaskPage> {
],
),
),
TodosList(
calendare: false,
allTask: true,
toggle: service.toggleValue.value,
set: () {
getCountTodos();
},
Expanded(
child: TodosList(
calendare: false,
allTask: true,
toggle: service.toggleValue.value,
set: () {
getCountTodos();
},
),
),
],
),
Expand Down
42 changes: 31 additions & 11 deletions lib/app/modules/calendar.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,6 +19,8 @@ class _CalendarPageState extends State<CalendarPage> {
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 = <Todos>[];
Expand Down Expand Up @@ -98,8 +101,8 @@ class _CalendarPageState extends State<CalendarPage> {
},
),
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],
Expand Down Expand Up @@ -183,15 +186,32 @@ class _CalendarPageState extends State<CalendarPage> {
],
),
),
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();
},
),
),
),
],
),
Expand Down
1 change: 1 addition & 0 deletions lib/app/modules/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class _HomePageState extends State<HomePage> {
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
surfaceTintColor: Colors.transparent,
elevation: 0,
titleSpacing: 30,
title: Row(
Expand Down
18 changes: 10 additions & 8 deletions lib/app/modules/tasks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,16 @@ class _TaskPageState extends State<TaskPage> {
],
),
),
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();
},
),
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/app/widgets/task_type_cu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class _TaskTypeCuState extends State<TaskTypeCu> {
},
icon: const Icon(
Icons.save,
color: Colors.blue,
color: Colors.white,
),
),
],
Expand Down
166 changes: 92 additions & 74 deletions lib/app/widgets/todos_ce.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,44 +112,6 @@ class _TodosCeState extends State<TodosCe> {
],
),
),
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,
),
),
],
),
),
Expand Down Expand Up @@ -261,45 +223,101 @@ class _TodosCeState extends State<TodosCe> {
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),
],
Expand Down
Loading

0 comments on commit 263d51b

Please sign in to comment.