feat:合并待办和提醒功能

This commit is contained in:
2025-11-09 11:16:24 +08:00
parent d5ff4c9b02
commit 7c3d35eb18
16 changed files with 259 additions and 730 deletions

View File

@@ -140,7 +140,7 @@ class _TodoFormState extends State<TodoForm> {
);
}
IconButton buildClearDateSuffixIcon() {
IconButton buildClearDueDateSuffixIcon() {
return IconButton(
icon: Icon(Icons.clear, size: 18),
onPressed: () {
@@ -152,7 +152,7 @@ class _TodoFormState extends State<TodoForm> {
);
}
FormBuilderDateTimePicker buildDateField() {
FormBuilderDateTimePicker buildDueDateField() {
return FormBuilderDateTimePicker(
name: 'dueDate',
format: DateFormat('yyyy-MM-dd'),
@@ -192,7 +192,7 @@ class _TodoFormState extends State<TodoForm> {
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
suffixIcon:
provider.formItem.dueDate != null
? buildClearDateSuffixIcon()
? buildClearDueDateSuffixIcon()
: null,
),
validator: (value) {
@@ -205,6 +205,70 @@ class _TodoFormState extends State<TodoForm> {
);
}
IconButton buildClearScheduledTimeSuffixIcon() {
return IconButton(
icon: Icon(Icons.clear, size: 18),
onPressed: () {
setState(() {
provider.formItem.scheduledTime = null;
});
widget.formKey.currentState?.fields['scheduledTime']?.didChange(null);
},
);
}
FormBuilderDateTimePicker buildScheduledTimeField() {
return FormBuilderDateTimePicker(
name: 'scheduledTime',
format: DateFormat('yyyy-MM-dd HH:mm:ss'),
initialValue: provider.formItem.scheduledTime,
inputType: InputType.both,
onChanged: (value) {
setState(() {
provider.formItem.scheduledTime = value;
});
},
decoration: InputDecoration(
labelText:
provider.formItem.scheduledTime == null
? '选择提醒日期'
: '提醒: ${DateFormat('yyyy-MM-dd HH:mm:ss').format(provider.formItem.scheduledTime!)}',
labelStyle: TextStyle(
color:
provider.formItem.scheduledTime == null
? Colors.grey
: Colors.black87,
),
prefixIcon: Icon(Icons.calendar_today, color: Colors.purple),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.grey.shade200),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.grey.shade200),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(color: Colors.orange),
),
filled: true,
fillColor: Colors.white,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 14),
suffixIcon:
provider.formItem.scheduledTime != null
? buildClearScheduledTimeSuffixIcon()
: null,
),
validator: (value) {
if (value != null && value.isBefore(DateTime.now())) {
return '不能选择过去的日期';
}
return null;
},
);
}
FormBuilderRadioGroup builderRadioGroup() {
return FormBuilderRadioGroup<TodoPriority>(
name: 'priority',
@@ -269,7 +333,9 @@ class _TodoFormState extends State<TodoForm> {
SizedBox(height: 12),
buildContentField(),
SizedBox(height: 12),
buildDateField(),
buildDueDateField(),
SizedBox(height: 12),
buildScheduledTimeField(),
SizedBox(height: 12),
buildPriorityField(),
],