69 lines
1.5 KiB
Dart
69 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class TodoItem {
|
|
String id;
|
|
String title;
|
|
String? description;
|
|
bool isCompleted;
|
|
DateTime createdAt;
|
|
DateTime? dueDate;
|
|
TodoPriority priority;
|
|
String? category;
|
|
|
|
TodoItem({
|
|
required this.id,
|
|
required this.title,
|
|
this.description,
|
|
this.isCompleted = false,
|
|
DateTime? createdAt,
|
|
this.dueDate,
|
|
this.priority = TodoPriority.medium,
|
|
this.category,
|
|
}) : createdAt = createdAt ?? DateTime.now();
|
|
|
|
TodoItem copyWith({
|
|
String? id,
|
|
String? title,
|
|
String? description,
|
|
bool? isCompleted,
|
|
DateTime? createdAt,
|
|
DateTime? dueDate,
|
|
TodoPriority? priority,
|
|
String? category,
|
|
}) {
|
|
return TodoItem(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
description: description ?? this.description,
|
|
isCompleted: isCompleted ?? this.isCompleted,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
dueDate: dueDate ?? this.dueDate,
|
|
priority: priority ?? this.priority,
|
|
category: category ?? this.category,
|
|
);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|