Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 12329d20e8 | |||
| f7c0d1050f |
@@ -43,3 +43,4 @@ app.*.map.json
|
||||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
devtools_options.yaml
|
||||
|
||||
@@ -17,6 +17,7 @@ class TaskEditPage extends StatefulWidget {
|
||||
|
||||
class _TaskEditPageState extends State<TaskEditPage> {
|
||||
Task? task;
|
||||
bool isInitialized = true;
|
||||
final titleController = TextEditingController();
|
||||
final descriptionController = TextEditingController();
|
||||
final categoryController = TextEditingController();
|
||||
@@ -29,7 +30,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
task = ModalRoute.of(context)!.settings.arguments as Task?;
|
||||
if (task != null) {
|
||||
if (task != null && !isInitialized) {
|
||||
titleController.text = task!.title;
|
||||
descriptionController.text = task!.description;
|
||||
categoryController.text = task!.category;
|
||||
@@ -40,6 +41,7 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||
dueTimeController.text = task!.due != null
|
||||
? TimeOfDay.fromDateTime(task!.due!).format(context)
|
||||
: '';
|
||||
isInitialized = true;
|
||||
}
|
||||
pageTitle = task?.title ?? 'CreateTask';
|
||||
}
|
||||
@@ -62,81 +64,86 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||
),
|
||||
body: Form(
|
||||
autovalidateMode: AutovalidateMode.onUnfocus,
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
controller: titleController,
|
||||
decoration: InputDecoration(label: Text('Title')),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
TextFormField(
|
||||
controller: descriptionController,
|
||||
decoration: InputDecoration(label: Text('Description')),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
TextFormField(
|
||||
controller: dueDateController,
|
||||
onChanged: (value) {
|
||||
if (dateTimeValidator(value) == null) {}
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
controller: titleController,
|
||||
decoration: InputDecoration(label: Text('Title')),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
TextFormField(
|
||||
controller: descriptionController,
|
||||
decoration: InputDecoration(label: Text('Description')),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
TextFormField(
|
||||
controller: dueDateController,
|
||||
onChanged: (value) {
|
||||
if (dateTimeValidator(value) == null) {}
|
||||
|
||||
setState(() {});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
label: Text('Due Date'),
|
||||
suffix: IconButton(
|
||||
onPressed: () async {
|
||||
final result = await onOpenCalendarPickerPressed();
|
||||
if (result != null) {
|
||||
dueDateController.text = getIsoDateString(result);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
icon: Icon(Icons.calendar_month),
|
||||
setState(() {});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
label: Text('Due Date'),
|
||||
suffix: IconButton(
|
||||
onPressed: () async {
|
||||
final result = await onOpenCalendarPickerPressed();
|
||||
if (result != null) {
|
||||
dueDateController.text = getIsoDateString(result);
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
icon: Icon(Icons.calendar_month),
|
||||
),
|
||||
),
|
||||
validator: dateTimeValidator,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
validator: dateTimeValidator,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
TextFormField(
|
||||
controller: dueTimeController,
|
||||
enabled: DateTime.tryParse(dueDateController.text) != null
|
||||
? true
|
||||
: false,
|
||||
decoration: InputDecoration(
|
||||
label: Text('Due Time'),
|
||||
suffix: IconButton(
|
||||
onPressed: () async {
|
||||
final result = await onOpenTimePickerPressed();
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
dueTimeController.text = result.format(context);
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: Icon(Icons.schedule),
|
||||
TextFormField(
|
||||
controller: dueTimeController,
|
||||
enabled: DateTime.tryParse(dueDateController.text) != null
|
||||
? true
|
||||
: false,
|
||||
decoration: InputDecoration(
|
||||
label: Text('Due Time'),
|
||||
suffix: IconButton(
|
||||
onPressed: () async {
|
||||
final result = await onOpenTimePickerPressed();
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
dueTimeController.text = result.format(context);
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: Icon(Icons.schedule),
|
||||
),
|
||||
),
|
||||
validator: timeValidator,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
validator: timeValidator,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
TextFormField(
|
||||
controller: categoryController,
|
||||
decoration: InputDecoration(label: Text('Category')),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
TextFormField(
|
||||
controller: urlController,
|
||||
decoration: InputDecoration(label: Text('Url')),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
],
|
||||
TextFormField(
|
||||
controller: categoryController,
|
||||
decoration: InputDecoration(label: Text('Category')),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
TextFormField(
|
||||
controller: urlController,
|
||||
decoration: InputDecoration(label: Text('Url')),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
|
||||
Reference in New Issue
Block a user