|
|
|
@ -13,6 +13,10 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final tag = Localizations.maybeLocaleOf(context)?.toLanguageTag();
|
|
|
|
|
return StreamBuilder<Object>(
|
|
|
|
|
stream: controller.widget.room.onUpdate.stream,
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
final list = controller.todos;
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
title: Text(L10n.of(context)!.todoLists),
|
|
|
|
@ -35,6 +39,7 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
? CrossFadeState.showSecond
|
|
|
|
|
: CrossFadeState.showFirst,
|
|
|
|
|
),
|
|
|
|
|
if (list.any((todo) => todo.done))
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.cleaning_services_outlined),
|
|
|
|
|
onPressed: controller.cleanUp,
|
|
|
|
@ -46,12 +51,8 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Opacity(
|
|
|
|
|
opacity: controller.isLoading ? 0.66 : 1,
|
|
|
|
|
child: StreamBuilder(
|
|
|
|
|
stream: controller.widget.room.onUpdate.stream,
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
final list = controller.todos;
|
|
|
|
|
if (list.isEmpty) {
|
|
|
|
|
return Column(
|
|
|
|
|
child: list.isEmpty
|
|
|
|
|
? Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
@ -69,9 +70,8 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return ReorderableListView.builder(
|
|
|
|
|
)
|
|
|
|
|
: ReorderableListView.builder(
|
|
|
|
|
onReorder: controller.onReorder,
|
|
|
|
|
itemCount: list.length,
|
|
|
|
|
itemBuilder: (context, i) {
|
|
|
|
@ -90,15 +90,17 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
decoration:
|
|
|
|
|
todo.done ? TextDecoration.lineThrough : null,
|
|
|
|
|
decoration: todo.done
|
|
|
|
|
? TextDecoration.lineThrough
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: description == null && dueDate == null
|
|
|
|
|
? null
|
|
|
|
|
: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (description != null)
|
|
|
|
|
Text(
|
|
|
|
@ -110,7 +112,8 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
height: 24,
|
|
|
|
|
child: OutlinedButton.icon(
|
|
|
|
|
style: OutlinedButton.styleFrom(
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
padding:
|
|
|
|
|
const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 6,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
@ -119,8 +122,11 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
size: 16,
|
|
|
|
|
),
|
|
|
|
|
label: Text(
|
|
|
|
|
DateFormat.yMMMd(tag).format(dueDate),
|
|
|
|
|
style: const TextStyle(fontSize: 12),
|
|
|
|
|
DateFormat.yMMMd(tag)
|
|
|
|
|
.format(dueDate),
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onPressed: () =>
|
|
|
|
|
controller.editTodoDueDate(
|
|
|
|
@ -134,15 +140,27 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
onTap: controller.isLoading
|
|
|
|
|
? null
|
|
|
|
|
: () => controller.toggleDone(i),
|
|
|
|
|
trailing: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
|
child: IconButton(
|
|
|
|
|
icon: const Icon(Icons.edit_outlined, size: 16),
|
|
|
|
|
onPressed: () => controller.editTodo(i, todo),
|
|
|
|
|
trailing: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.edit_outlined,
|
|
|
|
|
size: 16,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () =>
|
|
|
|
|
controller.editTodo(i, todo),
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(
|
|
|
|
|
Icons.delete_outlined,
|
|
|
|
|
size: 16,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () => controller.deleteTodo(i),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
@ -187,7 +205,8 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
icon: const Icon(Icons.add_outlined),
|
|
|
|
|
onPressed: controller.isLoading ? null : controller.addTodo,
|
|
|
|
|
onPressed:
|
|
|
|
|
controller.isLoading ? null : controller.addTodo,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
@ -195,5 +214,7 @@ class TasksView extends StatelessWidget {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|