Add reorder button

This commit is contained in:
2024-05-24 22:07:20 +08:00
parent 9ea5a80bfb
commit 3e86682abc
2 changed files with 33 additions and 17 deletions

View File

@@ -99,7 +99,7 @@ class _TaskManagerPage extends State<TaskManagerPage>
return Padding(
padding: const EdgeInsets.all(8),
key: ValueKey("task_${task.base.id}"),
child: TaskView(task));
child: TaskView(task, index));
}
Widget _proxyDecorator(Widget child, int index, Animation<double> animation) {
@@ -117,7 +117,15 @@ class _TaskManagerPage extends State<TaskManagerPage>
);
}
void _onReorder(int oldIndex, int newIndex) {}
void _onReorder(int oldIndex, int newIndex) {
setState(() {
if (oldIndex < newIndex) {
newIndex -= 1;
}
final task = tasks.tasksList.removeAt(oldIndex);
tasks.tasksList.insert(newIndex, task);
});
}
Widget _buildList(BuildContext context) {
return SliverReorderableList(