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

View File

@@ -1,51 +0,0 @@
import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
BoxDecoration buildBoxDecoration() {
return BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey[200]!, width: 1),
);
}
Container buildBody({Widget? child}) {
return Container(
color: Colors.grey[50],
padding: EdgeInsets.all(5),
child: SingleChildScrollView(child: child),
);
}
Container buildCard({Widget? child}) {
return Container(
decoration: buildBoxDecoration(),
padding: EdgeInsets.all(10),
child: child,
);
}
void showAwesomeDialog({
required BuildContext context,
required Widget body,
required VoidCallback onOk,
required VoidCallback onCancel,
}) {
AwesomeDialog(
context: context,
dialogType: DialogType.noHeader,
animType: AnimType.scale,
body: body,
dialogBackgroundColor: Colors.white,
btnOkText: "确认",
btnCancelText: "取消",
btnOkColor: Colors.orange,
btnCancelColor: Colors.grey,
buttonsBorderRadius: BorderRadius.circular(10),
headerAnimationLoop: false,
dismissOnTouchOutside: false,
dismissOnBackKeyPress: true,
btnOkOnPress: onOk,
btnCancelOnPress: onCancel,
).show();
}

68
lib/models/todo.dart Normal file
View File

@@ -0,0 +1,68 @@
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);
}