Compare commits
4 Commits
a3258b84fe
...
v0.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 392ec22dcd | |||
| 064c014f8b | |||
| 410a7eb843 | |||
| 20b017b066 |
@@ -1,4 +1,3 @@
|
||||
import '../location.dart';
|
||||
import '../task.dart';
|
||||
|
||||
class CreateTaskRequest {
|
||||
|
||||
@@ -22,7 +22,12 @@ class LocalRepository
|
||||
if (_prefs == null) {
|
||||
await SharedPreferencesWithCache.create(
|
||||
cacheOptions: const SharedPreferencesWithCacheOptions(
|
||||
allowList: <String>{_tasksKey, _taskOrderKey},
|
||||
allowList: <String>{
|
||||
_tasksKey,
|
||||
_taskOrderKey,
|
||||
_alarmsKey,
|
||||
_locationsKey,
|
||||
},
|
||||
),
|
||||
).then((value) => _prefs = value);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../model/extensions/controller_context.dart';
|
||||
import '../model/task.dart';
|
||||
import '../service/controllers/task_controller.dart';
|
||||
import '../service/tools.dart';
|
||||
import '../widgets/task_dismissible.dart';
|
||||
import 'task_edit_page.dart';
|
||||
|
||||
class TaskOverviewPage extends StatefulWidget {
|
||||
@@ -37,8 +38,11 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
||||
Widget itemBuilder(BuildContext context, int index) {
|
||||
final task = tasks.elementAt(index);
|
||||
|
||||
return ListTile(
|
||||
return 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(
|
||||
@@ -55,6 +59,7 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TaskDismissible extends StatelessWidget {
|
||||
const TaskDismissible({
|
||||
required super.key,
|
||||
this.onDismissedRight,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final VoidCallback? onDismissedRight;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dismissible(
|
||||
key: key!,
|
||||
direction: DismissDirection.startToEnd,
|
||||
background: Container(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
child: Align(
|
||||
alignment: AlignmentGeometry.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: Theme.of(context).colorScheme.onError,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onDismissed: onDismissed,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
void onDismissed(DismissDirection direction) {
|
||||
if (direction == DismissDirection.startToEnd && onDismissedRight != null) {
|
||||
onDismissedRight!();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user