Compare commits
3
Commits
e6951b4c25
...
2c3e52ba53
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c3e52ba53 | ||
|
|
62af007799 | ||
|
|
8f3afc3bd7 |
@@ -168,14 +168,27 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||
icon: Icon(Icons.location_on),
|
||||
),
|
||||
for (final (index, alarmRequest) in alarmRequests.indexed)
|
||||
AlarmForm(
|
||||
request: alarmRequest,
|
||||
onChanged: (updated) {
|
||||
setState(() {
|
||||
alarmRequests[index] = updated;
|
||||
});
|
||||
},
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: AlarmForm(
|
||||
request: alarmRequest,
|
||||
onChanged: (updated) {
|
||||
setState(() {
|
||||
alarmRequests[index] = updated;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () => setState(() {
|
||||
alarmRequests.removeAt(index);
|
||||
}),
|
||||
icon: Icon(Icons.close),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 120),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -191,32 +204,34 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||
}
|
||||
|
||||
void onSavePressed() {
|
||||
Navigator.of(context).pop(
|
||||
CreateTaskRequest(
|
||||
title: titleController.text,
|
||||
description: descriptionController.text,
|
||||
start: null,
|
||||
due: DateTime.tryParse(
|
||||
'${dueDateController.text} ${dueTimeController.text}'.trim(),
|
||||
if (formKey.currentState!.validate()) {
|
||||
Navigator.of(context).pop(
|
||||
CreateTaskRequest(
|
||||
title: titleController.text,
|
||||
description: descriptionController.text,
|
||||
start: null,
|
||||
due: DateTime.tryParse(
|
||||
'${dueDateController.text} ${dueTimeController.text}'.trim(),
|
||||
),
|
||||
isCompleted: false,
|
||||
category: categoryController.text,
|
||||
subtasks: [],
|
||||
url: urlController.text,
|
||||
alarms: alarmRequests.map<Alarm>((e) {
|
||||
if (e is CreateFixedTimeAlarmRequest) {
|
||||
return e.toAlarm(generateId());
|
||||
}
|
||||
if (e is CreateRelativeTimeAlarmRequest) {
|
||||
return e.toAlarm(generateId());
|
||||
}
|
||||
if (e is LocationAlarm) {
|
||||
return e.toAlarm(generateId());
|
||||
}
|
||||
throw TypeError();
|
||||
}).toList(),
|
||||
),
|
||||
isCompleted: false,
|
||||
category: categoryController.text,
|
||||
subtasks: [],
|
||||
url: urlController.text,
|
||||
alarms: alarmRequests.map<Alarm>((e) {
|
||||
if (e is CreateFixedTimeAlarmRequest) {
|
||||
return e.toAlarm(generateId());
|
||||
}
|
||||
if (e is CreateRelativeTimeAlarmRequest) {
|
||||
return e.toAlarm(generateId());
|
||||
}
|
||||
if (e is LocationAlarm) {
|
||||
return e.toAlarm(generateId());
|
||||
}
|
||||
throw TypeError();
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void onPopInvoked(bool didPop, Object? result) {
|
||||
|
||||
@@ -69,7 +69,9 @@ class _FixedTimeAlarmFormState extends State<FixedTimeAlarmForm> {
|
||||
icon: Icon(Icons.calendar_month),
|
||||
),
|
||||
),
|
||||
validator: dateTimeValidator,
|
||||
validator: (value) {
|
||||
return notEmptyValidator(value) ?? dateTimeValidator(value);
|
||||
},
|
||||
keyboardType: TextInputType.datetime,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user