feat:重构代办事项模块

This commit is contained in:
2025-11-06 23:52:20 +08:00
parent 6c3d2c9099
commit 783fd67398
11 changed files with 751 additions and 689 deletions

23
lib/utils/todo_utils.dart Normal file
View File

@@ -0,0 +1,23 @@
import 'package:flisp_app/models/todo.dart';
List<TodoItem> getActiveTodos(TodoTab currentTab, List<TodoItem> todos) {
switch (currentTab) {
case TodoTab.active:
return todos.where((todo) => !todo.isCompleted).toList();
case TodoTab.completed:
return todos.where((todo) => todo.isCompleted).toList();
case TodoTab.today:
final today = DateTime.now();
return todos
.where(
(todo) =>
todo.dueDate != null &&
todo.dueDate!.year == today.year &&
todo.dueDate!.month == today.month &&
todo.dueDate!.day == today.day,
)
.toList();
default:
return todos;
}
}