72 lines
1.4 KiB
Dart
72 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class TodoItem {
|
|
num id;
|
|
String title;
|
|
String content;
|
|
bool isCompleted;
|
|
DateTime? dueDate;
|
|
TodoPriority priority;
|
|
|
|
TodoItem({
|
|
required this.id,
|
|
required this.title,
|
|
required this.content,
|
|
this.isCompleted = false,
|
|
this.dueDate,
|
|
this.priority = TodoPriority.medium,
|
|
});
|
|
|
|
TodoItem copyWith({
|
|
num? id,
|
|
String? title,
|
|
String? content,
|
|
bool? isCompleted,
|
|
DateTime? dueDate,
|
|
TodoPriority? priority,
|
|
}) {
|
|
return TodoItem(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
content: content ?? this.content,
|
|
isCompleted: isCompleted ?? this.isCompleted,
|
|
dueDate: dueDate ?? this.dueDate,
|
|
priority: priority ?? this.priority,
|
|
);
|
|
}
|
|
|
|
static TodoItem getEmpty() {
|
|
return TodoItem(
|
|
id: 0,
|
|
title: '',
|
|
content: '',
|
|
isCompleted: false,
|
|
dueDate: null,
|
|
priority: TodoPriority.medium,
|
|
);
|
|
}
|
|
}
|
|
|
|
enum TodoPriority {
|
|
low('低', Color(0xFF757575), Icons.low_priority),
|
|
medium('中', Color(0xFFF57C00), Icons.flag),
|
|
high('高', Color(0xFFD32F2F), Icons.warning);
|
|
|
|
final String label;
|
|
final Color color;
|
|
final IconData icon;
|
|
|
|
const TodoPriority(this.label, this.color, this.icon);
|
|
}
|
|
|
|
enum TodoTab {
|
|
all('全部'),
|
|
active('待完成'),
|
|
completed('已完成'),
|
|
today('今天');
|
|
|
|
final String label;
|
|
|
|
const TodoTab(this.label);
|
|
}
|