Skip to content

Commit 6076f62

Browse files
committed
feat: add save button and review changes dialog
1 parent 46fe9ac commit 6076f62

File tree

1 file changed

+122
-116
lines changed

1 file changed

+122
-116
lines changed

lib/app/modules/detailRoute/views/detail_route_view.dart

Lines changed: 122 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -119,122 +119,128 @@ class DetailRouteView extends GetView<DetailRouteController> {
119119
return true;
120120
},
121121
child: Scaffold(
122-
backgroundColor: tColors.primaryBackgroundColor,
123-
appBar: AppBar(
124-
leading: BackButton(color: TaskWarriorColors.white),
125-
backgroundColor: Palette.kToDark,
126-
title: Text(
127-
'${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.detailPageID}: ${(controller.modify.id == 0) ? '-' : controller.modify.id}',
128-
style: TextStyle(
129-
color: TaskWarriorColors.white,
130-
),
131-
)),
132-
body: Padding(
133-
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
134-
child: Obx(
135-
() => ListView(
136-
padding:
137-
const EdgeInsets.symmetric(vertical: 4, horizontal: 2),
138-
children: [
139-
for (var entry in {
140-
'description': controller.descriptionValue.value,
141-
'status': controller.statusValue.value,
142-
'entry': controller.entryValue.value,
143-
'modified': controller.modifiedValue.value,
144-
'start': controller.startValue.value,
145-
'end': controller.endValue.value,
146-
'due': controller.dueValue.value,
147-
'wait': controller.waitValue.value,
148-
'until': controller.untilValue.value,
149-
'priority': controller.priorityValue?.value,
150-
'project': controller.projectValue?.value,
151-
'tags': controller.tagsValue?.value,
152-
'urgency': controller.urgencyValue.value,
153-
}.entries)
154-
AttributeWidget(
155-
name: entry.key,
156-
value: entry.value,
157-
callback: (newValue) =>
158-
controller.setAttribute(entry.key, newValue),
159-
waitKey: controller.waitKey,
160-
dueKey: controller.dueKey,
161-
untilKey: controller.untilKey,
162-
priorityKey: controller.priorityKey,
163-
),
164-
],
165-
),
166-
)),
167-
floatingActionButton: controller.modify.changes.isEmpty
168-
? const SizedBox.shrink()
169-
: FloatingActionButton(
170-
backgroundColor: tColors.primaryTextColor,
171-
foregroundColor: tColors.secondaryBackgroundColor,
172-
splashColor: tColors.primaryTextColor,
173-
heroTag: "btn1",
174-
onPressed: () {
175-
showDialog(
176-
context: context,
177-
builder: (context) {
178-
return AlertDialog(
179-
scrollable: true,
180-
title: Text(
181-
'${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.reviewChanges}:',
182-
style: TextStyle(
183-
color: tColors.primaryTextColor,
184-
),
185-
),
186-
content: SingleChildScrollView(
187-
scrollDirection: Axis.horizontal,
188-
child: Text(
189-
controller.modify.changes.entries
190-
.map((entry) => '${entry.key}:\n'
191-
' ${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.oldChanges}: ${entry.value['old']}\n'
192-
' ${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.newChanges}: ${entry.value['new']}')
193-
.toList()
194-
.join('\n'),
195-
style: TextStyle(
196-
color: tColors.primaryTextColor,
197-
),
198-
),
199-
),
200-
actions: [
201-
TextButton(
202-
onPressed: () {
203-
Get.back();
204-
},
205-
child: Text(
206-
SentenceManager(
207-
currentLanguage:
208-
AppSettings.selectedLanguage)
209-
.sentences
210-
.cancel,
211-
style: TextStyle(
212-
color: tColors.primaryTextColor,
213-
),
214-
),
215-
),
216-
TextButton(
217-
onPressed: () {
218-
controller.saveChanges();
219-
},
220-
child: Text(
221-
SentenceManager(
222-
currentLanguage:
223-
AppSettings.selectedLanguage)
224-
.sentences
225-
.submit,
226-
style: TextStyle(
227-
color: tColors.primaryBackgroundColor,
228-
),
229-
),
230-
),
231-
],
232-
);
233-
},
234-
);
235-
},
236-
child: const Icon(Icons.save),
237-
)),
122+
backgroundColor: tColors.primaryBackgroundColor,
123+
appBar: AppBar(
124+
leading: BackButton(color: TaskWarriorColors.white),
125+
backgroundColor: Palette.kToDark,
126+
title: Text(
127+
'${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.detailPageID}: ${(controller.modify.id == 0) ? '-' : controller.modify.id}',
128+
style: TextStyle(
129+
color: TaskWarriorColors.white,
130+
),
131+
)),
132+
body: Padding(
133+
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
134+
child: Obx(
135+
() => ListView(
136+
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 2),
137+
children: [
138+
for (var entry in {
139+
'description': controller.descriptionValue.value,
140+
'status': controller.statusValue.value,
141+
'entry': controller.entryValue.value,
142+
'modified': controller.modifiedValue.value,
143+
'start': controller.startValue.value,
144+
'end': controller.endValue.value,
145+
'due': controller.dueValue.value,
146+
'wait': controller.waitValue.value,
147+
'until': controller.untilValue.value,
148+
'priority': controller.priorityValue?.value,
149+
'project': controller.projectValue?.value,
150+
'tags': controller.tagsValue?.value,
151+
'urgency': controller.urgencyValue.value,
152+
}.entries)
153+
AttributeWidget(
154+
name: entry.key,
155+
value: entry.value,
156+
callback: (newValue) =>
157+
controller.setAttribute(entry.key, newValue),
158+
waitKey: controller.waitKey,
159+
dueKey: controller.dueKey,
160+
untilKey: controller.untilKey,
161+
priorityKey: controller.priorityKey,
162+
),
163+
],
164+
),
165+
)),
166+
167+
// SAVE BUTTON — Bottom Right
168+
169+
floatingActionButton: Obx(() {
170+
if (!controller.onEdit.value) {
171+
return const SizedBox.shrink();
172+
}
173+
174+
return FloatingActionButton(
175+
onPressed: () => _showReviewChangesDialog(context, tColors),
176+
backgroundColor: tColors.primaryTextColor,
177+
foregroundColor: tColors.secondaryBackgroundColor,
178+
splashColor: tColors.primaryTextColor,
179+
child: const Icon(Icons.save),
180+
);
181+
}),
182+
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
183+
),
184+
);
185+
}
186+
187+
// REVIEW CHANGES DIALOG
188+
void _showReviewChangesDialog(
189+
BuildContext context, TaskwarriorColorTheme tColors) {
190+
final sentences =
191+
SentenceManager(currentLanguage: AppSettings.selectedLanguage)
192+
.sentences;
193+
194+
showDialog(
195+
context: context,
196+
builder: (context) {
197+
return AlertDialog(
198+
scrollable: true,
199+
title: Text(
200+
'${sentences.reviewChanges}:',
201+
style: TextStyle(color: tColors.primaryTextColor),
202+
),
203+
content: SingleChildScrollView(
204+
scrollDirection: Axis.horizontal,
205+
child: Text(
206+
controller.modify.changes.entries
207+
.map((entry) => '${entry.key}:\n'
208+
' ${sentences.oldChanges}: ${entry.value['old']}\n'
209+
' ${sentences.newChanges}: ${entry.value['new']}')
210+
.toList()
211+
.join('\n'),
212+
style: TextStyle(color: tColors.primaryTextColor),
213+
),
214+
),
215+
actions: [
216+
TextButton(
217+
onPressed: () => Get.back(),
218+
child: Text(
219+
sentences.cancel,
220+
style: TextStyle(color: tColors.primaryTextColor),
221+
),
222+
),
223+
TextButton(
224+
onPressed: () {
225+
Get.back();
226+
controller.saveChanges();
227+
228+
ScaffoldMessenger.of(context).showSnackBar(
229+
SnackBar(
230+
content: Text(sentences.taskUpdated),
231+
behavior: SnackBarBehavior.floating,
232+
duration: const Duration(seconds: 2),
233+
),
234+
);
235+
},
236+
child: Text(
237+
sentences.submit,
238+
style: const TextStyle(color: Colors.white),
239+
),
240+
),
241+
],
242+
);
243+
},
238244
);
239245
}
240246
}

0 commit comments

Comments
 (0)