23 lines
684 B
Dart
23 lines
684 B
Dart
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;
|
|
}
|
|
} |