feat:更新代办事项存储功能

This commit is contained in:
2025-11-07 21:24:09 +08:00
parent 00e65bc5be
commit 27f0638c01
9 changed files with 80 additions and 92 deletions

View File

@@ -51,4 +51,18 @@ void showSuccessDialog(BuildContext context, String message) {
btnOkOnPress: () {},
autoHide: Duration(seconds: 2),
).show();
}
// 显示失败提示
void showErrorDialog(BuildContext context, String message) {
AwesomeDialog(
context: context,
dialogType: DialogType.error,
animType: AnimType.scale,
title: message,
btnOkText: "好的",
btnOkColor: Colors.green,
btnOkOnPress: () {},
autoHide: Duration(seconds: 2),
).show();
}

View File

@@ -25,14 +25,6 @@ class _TodoFormState extends State<TodoForm> {
@override
void initState() {
super.initState();
// 如果是编辑模式,初始化数据
if (widget.isEditing && widget.initialTodo != null) {
WidgetsBinding.instance.addPostFrameCallback((_) {
final store = Provider.of<TodoProvider>(context, listen: false);
store.initForm(widget.initialTodo!);
});
}
}
@override
@@ -201,7 +193,8 @@ class _TodoFormState extends State<TodoForm> {
: null,
),
validator: (value) {
if (value != null && value.isBefore(DateTime.now())) {
if (value != null &&
value.isBefore(DateTime.now().subtract(Duration(days: 1)))) {
return '不能选择过去的日期';
}
return null;

View File

@@ -71,7 +71,7 @@ Widget buildTabs({
Widget buildTodoList({
required List<Todo> todos,
required ValueChanged<String> onToggleTodo,
required ValueChanged<Todo> onToggleTodo,
required ValueChanged<Todo> onEditTodo,
}) {
return ListView.separated(
@@ -90,7 +90,7 @@ Widget buildTodoList({
Widget _buildTodoItem({
required Todo todo,
required ValueChanged<String> onToggle,
required ValueChanged<Todo> onToggle,
required ValueChanged<Todo> onEdit,
}) {
return buildCard(
@@ -100,7 +100,7 @@ Widget _buildTodoItem({
width: 24,
child: Checkbox(
value: todo.isCompleted,
onChanged: (value) => onToggle(todo.id.toString()),
onChanged: (value) => onToggle(todo),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),