feat:增加待办提醒功能

This commit is contained in:
2026-04-29 19:21:57 +08:00
parent 3804164cfd
commit 0e6fe4ad4b
16 changed files with 297 additions and 64 deletions

View File

@@ -19,6 +19,7 @@ class _TaskDialogState extends State<TaskDialog> {
late Priority _selectedPriority;
DateTime? _selectedDueDate;
DateTime? _selectedScheduleTime;
DateTime? _createTime;
final _formKey = GlobalKey<FormState>();
@override
@@ -29,6 +30,7 @@ class _TaskDialogState extends State<TaskDialog> {
_selectedPriority = widget.task?.priority ?? Priority.medium;
_selectedDueDate = widget.task?.dueDate;
_selectedScheduleTime = widget.task?.scheduleTime;
_createTime = widget.task?.createTime;
}
@override
@@ -38,8 +40,22 @@ class _TaskDialogState extends State<TaskDialog> {
super.dispose();
}
void onConfirmClick() {
void onConfirmClick() async {
if (_formKey.currentState!.validate()) {
if (_selectedScheduleTime != null &&
_selectedScheduleTime!.isBefore(DateTime.now())) {
await displayInfoBar(
context,
builder: (context, close) {
return InfoBar(
title: const Text('提醒时间不能早于当前时间'),
severity: InfoBarSeverity.error,
);
},
);
return;
}
final task = Task(
id: widget.task?.id,
title: _titleController.text,
@@ -48,6 +64,7 @@ class _TaskDialogState extends State<TaskDialog> {
scheduleTime: _selectedScheduleTime,
priority: _selectedPriority,
isCompleted: widget.task?.isCompleted ?? false,
createTime: _createTime,
);
widget.onSave(task);
Navigator.pop(context);