|
|
|
@@ -22,11 +22,16 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(),
|
|
|
|
|
body: ReorderableListView.builder(
|
|
|
|
|
itemBuilder: itemBuilder,
|
|
|
|
|
itemCount: tasks.length,
|
|
|
|
|
onReorderItem: context.controller<TaskController>().reorderTask,
|
|
|
|
|
appBar: AppBar(title: Text('Hallo Yannick')),
|
|
|
|
|
body: Padding(
|
|
|
|
|
padding: EdgeInsetsGeometry.symmetric(
|
|
|
|
|
horizontal: MediaQuery.of(context).size.width * 0.05,
|
|
|
|
|
),
|
|
|
|
|
child: ReorderableListView.builder(
|
|
|
|
|
itemBuilder: itemBuilder,
|
|
|
|
|
itemCount: tasks.length,
|
|
|
|
|
onReorderItem: context.controller<TaskController>().reorderTask,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
|
onPressed: onCreateTaskTapped,
|
|
|
|
@@ -38,27 +43,31 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
|
|
|
|
Widget itemBuilder(BuildContext context, int index) {
|
|
|
|
|
final task = tasks.elementAt(index);
|
|
|
|
|
|
|
|
|
|
return TaskDismissible(
|
|
|
|
|
return Padding(
|
|
|
|
|
key: Key(task.id),
|
|
|
|
|
onDismissedRight: () =>
|
|
|
|
|
context.controller<TaskController>().deleteTask(task),
|
|
|
|
|
child: ListTile(
|
|
|
|
|
title: Text(task.title),
|
|
|
|
|
subtitle: task.description.isNotEmpty ? Text(task.description) : null,
|
|
|
|
|
trailing: Checkbox(
|
|
|
|
|
value: task.isCompleted,
|
|
|
|
|
onChanged: (isCompleted) => context
|
|
|
|
|
.controller<TaskController>()
|
|
|
|
|
.saveTask(task.copyWith(isCompleted: isCompleted)),
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 12),
|
|
|
|
|
child: TaskDismissible(
|
|
|
|
|
key: Key(task.id),
|
|
|
|
|
onDismissedRight: () =>
|
|
|
|
|
context.controller<TaskController>().deleteTask(task),
|
|
|
|
|
child: ListTile(
|
|
|
|
|
title: Text(task.title),
|
|
|
|
|
subtitle: task.description.isNotEmpty ? Text(task.description) : null,
|
|
|
|
|
trailing: Checkbox(
|
|
|
|
|
value: task.isCompleted,
|
|
|
|
|
onChanged: (isCompleted) => context
|
|
|
|
|
.controller<TaskController>()
|
|
|
|
|
.saveTask(task.copyWith(isCompleted: isCompleted)),
|
|
|
|
|
),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final result = await onTaskTapped(task);
|
|
|
|
|
if (result != null && context.mounted) {
|
|
|
|
|
context.controller<TaskController>().saveTask(
|
|
|
|
|
result.toTask(id: task.id),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final result = await onTaskTapped(task);
|
|
|
|
|
if (result != null && context.mounted) {
|
|
|
|
|
context.controller<TaskController>().saveTask(
|
|
|
|
|
result.toTask(id: task.id),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|