feat:重构代办事项模块
This commit is contained in:
23
lib/utils/todo_utils.dart
Normal file
23
lib/utils/todo_utils.dart
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user