-
Notifications
You must be signed in to change notification settings - Fork 142
feat: Unsaved changes indicator with review dialog on Edit Task screen #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -119,122 +119,128 @@ class DetailRouteView extends GetView<DetailRouteController> { | |||||||||||||||||
| return true; | ||||||||||||||||||
| }, | ||||||||||||||||||
| child: Scaffold( | ||||||||||||||||||
| backgroundColor: tColors.primaryBackgroundColor, | ||||||||||||||||||
| appBar: AppBar( | ||||||||||||||||||
| leading: BackButton(color: TaskWarriorColors.white), | ||||||||||||||||||
| backgroundColor: Palette.kToDark, | ||||||||||||||||||
| title: Text( | ||||||||||||||||||
| '${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.detailPageID}: ${(controller.modify.id == 0) ? '-' : controller.modify.id}', | ||||||||||||||||||
| style: TextStyle( | ||||||||||||||||||
| color: TaskWarriorColors.white, | ||||||||||||||||||
| ), | ||||||||||||||||||
| )), | ||||||||||||||||||
| body: Padding( | ||||||||||||||||||
| padding: const EdgeInsets.only(left: 8.0, right: 8.0), | ||||||||||||||||||
| child: Obx( | ||||||||||||||||||
| () => ListView( | ||||||||||||||||||
| padding: | ||||||||||||||||||
| const EdgeInsets.symmetric(vertical: 4, horizontal: 2), | ||||||||||||||||||
| children: [ | ||||||||||||||||||
| for (var entry in { | ||||||||||||||||||
| 'description': controller.descriptionValue.value, | ||||||||||||||||||
| 'status': controller.statusValue.value, | ||||||||||||||||||
| 'entry': controller.entryValue.value, | ||||||||||||||||||
| 'modified': controller.modifiedValue.value, | ||||||||||||||||||
| 'start': controller.startValue.value, | ||||||||||||||||||
| 'end': controller.endValue.value, | ||||||||||||||||||
| 'due': controller.dueValue.value, | ||||||||||||||||||
| 'wait': controller.waitValue.value, | ||||||||||||||||||
| 'until': controller.untilValue.value, | ||||||||||||||||||
| 'priority': controller.priorityValue?.value, | ||||||||||||||||||
| 'project': controller.projectValue?.value, | ||||||||||||||||||
| 'tags': controller.tagsValue?.value, | ||||||||||||||||||
| 'urgency': controller.urgencyValue.value, | ||||||||||||||||||
| }.entries) | ||||||||||||||||||
| AttributeWidget( | ||||||||||||||||||
| name: entry.key, | ||||||||||||||||||
| value: entry.value, | ||||||||||||||||||
| callback: (newValue) => | ||||||||||||||||||
| controller.setAttribute(entry.key, newValue), | ||||||||||||||||||
| waitKey: controller.waitKey, | ||||||||||||||||||
| dueKey: controller.dueKey, | ||||||||||||||||||
| untilKey: controller.untilKey, | ||||||||||||||||||
| priorityKey: controller.priorityKey, | ||||||||||||||||||
| ), | ||||||||||||||||||
| ], | ||||||||||||||||||
| ), | ||||||||||||||||||
| )), | ||||||||||||||||||
| floatingActionButton: controller.modify.changes.isEmpty | ||||||||||||||||||
| ? const SizedBox.shrink() | ||||||||||||||||||
| : FloatingActionButton( | ||||||||||||||||||
| backgroundColor: tColors.primaryTextColor, | ||||||||||||||||||
| foregroundColor: tColors.secondaryBackgroundColor, | ||||||||||||||||||
| splashColor: tColors.primaryTextColor, | ||||||||||||||||||
| heroTag: "btn1", | ||||||||||||||||||
| onPressed: () { | ||||||||||||||||||
| showDialog( | ||||||||||||||||||
| context: context, | ||||||||||||||||||
| builder: (context) { | ||||||||||||||||||
| return AlertDialog( | ||||||||||||||||||
| scrollable: true, | ||||||||||||||||||
| title: Text( | ||||||||||||||||||
| '${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.reviewChanges}:', | ||||||||||||||||||
| style: TextStyle( | ||||||||||||||||||
| color: tColors.primaryTextColor, | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| content: SingleChildScrollView( | ||||||||||||||||||
| scrollDirection: Axis.horizontal, | ||||||||||||||||||
| child: Text( | ||||||||||||||||||
| controller.modify.changes.entries | ||||||||||||||||||
| .map((entry) => '${entry.key}:\n' | ||||||||||||||||||
| ' ${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.oldChanges}: ${entry.value['old']}\n' | ||||||||||||||||||
| ' ${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.newChanges}: ${entry.value['new']}') | ||||||||||||||||||
| .toList() | ||||||||||||||||||
| .join('\n'), | ||||||||||||||||||
| style: TextStyle( | ||||||||||||||||||
| color: tColors.primaryTextColor, | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| actions: [ | ||||||||||||||||||
| TextButton( | ||||||||||||||||||
| onPressed: () { | ||||||||||||||||||
| Get.back(); | ||||||||||||||||||
| }, | ||||||||||||||||||
| child: Text( | ||||||||||||||||||
| SentenceManager( | ||||||||||||||||||
| currentLanguage: | ||||||||||||||||||
| AppSettings.selectedLanguage) | ||||||||||||||||||
| .sentences | ||||||||||||||||||
| .cancel, | ||||||||||||||||||
| style: TextStyle( | ||||||||||||||||||
| color: tColors.primaryTextColor, | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| TextButton( | ||||||||||||||||||
| onPressed: () { | ||||||||||||||||||
| controller.saveChanges(); | ||||||||||||||||||
| }, | ||||||||||||||||||
| child: Text( | ||||||||||||||||||
| SentenceManager( | ||||||||||||||||||
| currentLanguage: | ||||||||||||||||||
| AppSettings.selectedLanguage) | ||||||||||||||||||
| .sentences | ||||||||||||||||||
| .submit, | ||||||||||||||||||
| style: TextStyle( | ||||||||||||||||||
| color: tColors.primaryBackgroundColor, | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| ], | ||||||||||||||||||
| ); | ||||||||||||||||||
| }, | ||||||||||||||||||
| ); | ||||||||||||||||||
| }, | ||||||||||||||||||
| child: const Icon(Icons.save), | ||||||||||||||||||
| )), | ||||||||||||||||||
| backgroundColor: tColors.primaryBackgroundColor, | ||||||||||||||||||
| appBar: AppBar( | ||||||||||||||||||
| leading: BackButton(color: TaskWarriorColors.white), | ||||||||||||||||||
| backgroundColor: Palette.kToDark, | ||||||||||||||||||
| title: Text( | ||||||||||||||||||
| '${SentenceManager(currentLanguage: AppSettings.selectedLanguage).sentences.detailPageID}: ${(controller.modify.id == 0) ? '-' : controller.modify.id}', | ||||||||||||||||||
| style: TextStyle( | ||||||||||||||||||
| color: TaskWarriorColors.white, | ||||||||||||||||||
| ), | ||||||||||||||||||
| )), | ||||||||||||||||||
| body: Padding( | ||||||||||||||||||
| padding: const EdgeInsets.only(left: 8.0, right: 8.0), | ||||||||||||||||||
| child: Obx( | ||||||||||||||||||
| () => ListView( | ||||||||||||||||||
| padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 2), | ||||||||||||||||||
| children: [ | ||||||||||||||||||
| for (var entry in { | ||||||||||||||||||
| 'description': controller.descriptionValue.value, | ||||||||||||||||||
| 'status': controller.statusValue.value, | ||||||||||||||||||
| 'entry': controller.entryValue.value, | ||||||||||||||||||
| 'modified': controller.modifiedValue.value, | ||||||||||||||||||
| 'start': controller.startValue.value, | ||||||||||||||||||
| 'end': controller.endValue.value, | ||||||||||||||||||
| 'due': controller.dueValue.value, | ||||||||||||||||||
| 'wait': controller.waitValue.value, | ||||||||||||||||||
| 'until': controller.untilValue.value, | ||||||||||||||||||
| 'priority': controller.priorityValue?.value, | ||||||||||||||||||
| 'project': controller.projectValue?.value, | ||||||||||||||||||
| 'tags': controller.tagsValue?.value, | ||||||||||||||||||
| 'urgency': controller.urgencyValue.value, | ||||||||||||||||||
| }.entries) | ||||||||||||||||||
| AttributeWidget( | ||||||||||||||||||
| name: entry.key, | ||||||||||||||||||
| value: entry.value, | ||||||||||||||||||
| callback: (newValue) => | ||||||||||||||||||
| controller.setAttribute(entry.key, newValue), | ||||||||||||||||||
| waitKey: controller.waitKey, | ||||||||||||||||||
| dueKey: controller.dueKey, | ||||||||||||||||||
| untilKey: controller.untilKey, | ||||||||||||||||||
| priorityKey: controller.priorityKey, | ||||||||||||||||||
| ), | ||||||||||||||||||
| ], | ||||||||||||||||||
| ), | ||||||||||||||||||
| )), | ||||||||||||||||||
|
|
||||||||||||||||||
| // SAVE BUTTON — Bottom Right | ||||||||||||||||||
|
|
||||||||||||||||||
| floatingActionButton: Obx(() { | ||||||||||||||||||
| if (!controller.onEdit.value) { | ||||||||||||||||||
| return const SizedBox.shrink(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| return FloatingActionButton( | ||||||||||||||||||
| onPressed: () => _showReviewChangesDialog(context, tColors), | ||||||||||||||||||
| backgroundColor: tColors.primaryTextColor, | ||||||||||||||||||
| foregroundColor: tColors.secondaryBackgroundColor, | ||||||||||||||||||
| splashColor: tColors.primaryTextColor, | ||||||||||||||||||
| child: const Icon(Icons.save), | ||||||||||||||||||
| ); | ||||||||||||||||||
| }), | ||||||||||||||||||
| floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, | ||||||||||||||||||
| ), | ||||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| // REVIEW CHANGES DIALOG | ||||||||||||||||||
| void _showReviewChangesDialog( | ||||||||||||||||||
| BuildContext context, TaskwarriorColorTheme tColors) { | ||||||||||||||||||
| final sentences = | ||||||||||||||||||
| SentenceManager(currentLanguage: AppSettings.selectedLanguage) | ||||||||||||||||||
| .sentences; | ||||||||||||||||||
|
|
||||||||||||||||||
| showDialog( | ||||||||||||||||||
| context: context, | ||||||||||||||||||
| builder: (context) { | ||||||||||||||||||
| return AlertDialog( | ||||||||||||||||||
| scrollable: true, | ||||||||||||||||||
| title: Text( | ||||||||||||||||||
| '${sentences.reviewChanges}:', | ||||||||||||||||||
| style: TextStyle(color: tColors.primaryTextColor), | ||||||||||||||||||
| ), | ||||||||||||||||||
| content: SingleChildScrollView( | ||||||||||||||||||
| scrollDirection: Axis.horizontal, | ||||||||||||||||||
| child: Text( | ||||||||||||||||||
| controller.modify.changes.entries | ||||||||||||||||||
| .map((entry) => '${entry.key}:\n' | ||||||||||||||||||
| ' ${sentences.oldChanges}: ${entry.value['old']}\n' | ||||||||||||||||||
| ' ${sentences.newChanges}: ${entry.value['new']}') | ||||||||||||||||||
| .toList() | ||||||||||||||||||
| .join('\n'), | ||||||||||||||||||
| style: TextStyle(color: tColors.primaryTextColor), | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| actions: [ | ||||||||||||||||||
| TextButton( | ||||||||||||||||||
| onPressed: () => Get.back(), | ||||||||||||||||||
| child: Text( | ||||||||||||||||||
| sentences.cancel, | ||||||||||||||||||
| style: TextStyle(color: tColors.primaryTextColor), | ||||||||||||||||||
| ), | ||||||||||||||||||
| ), | ||||||||||||||||||
| TextButton( | ||||||||||||||||||
| onPressed: () { | ||||||||||||||||||
| Get.back(); | ||||||||||||||||||
| controller.saveChanges(); | ||||||||||||||||||
|
|
||||||||||||||||||
| ScaffoldMessenger.of(context).showSnackBar( | ||||||||||||||||||
| SnackBar( | ||||||||||||||||||
| content: Text(sentences.taskUpdated), | ||||||||||||||||||
| behavior: SnackBarBehavior.floating, | ||||||||||||||||||
| duration: const Duration(seconds: 2), | ||||||||||||||||||
| ), | ||||||||||||||||||
| ); | ||||||||||||||||||
|
Comment on lines
+224
to
+234
|
||||||||||||||||||
| ScaffoldMessenger.of(context).showSnackBar( | |
| SnackBar( | |
| content: Text(sentences.taskUpdated), | |
| behavior: SnackBarBehavior.floating, | |
| duration: const Duration(seconds: 2), | |
| ), | |
| ); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,11 +21,16 @@ class PriorityWidget extends StatelessWidget { | |||||
|
|
||||||
| @override | ||||||
| Widget build(BuildContext context) { | ||||||
| TaskwarriorColorTheme tColors = Theme.of(context).extension<TaskwarriorColorTheme>()!; | ||||||
| TaskwarriorColorTheme tColors = | ||||||
| Theme.of(context).extension<TaskwarriorColorTheme>()!; | ||||||
| final Color? textColor = isEditable | ||||||
| ? tColors.primaryTextColor | ||||||
| : tColors.primaryDisabledTextColor; | ||||||
|
|
||||||
| // Normalize value: null → X | ||||||
| final String priority = | ||||||
| (value == null || value == '') ? 'X' : value.toString(); | ||||||
|
|
||||||
| return Card( | ||||||
| key: globalKey, | ||||||
| color: tColors.secondaryBackgroundColor, | ||||||
|
|
@@ -48,7 +53,7 @@ class PriorityWidget extends StatelessWidget { | |||||
| ), | ||||||
| ), | ||||||
| TextSpan( | ||||||
| text: value ?? "not selected", | ||||||
| text: priority, // Always show X / H / M / L | ||||||
| style: GoogleFonts.poppins( | ||||||
| fontSize: TaskWarriorFonts.fontSizeMedium, | ||||||
| color: textColor, | ||||||
|
|
@@ -60,18 +65,24 @@ class PriorityWidget extends StatelessWidget { | |||||
| ], | ||||||
| ), | ||||||
| ), | ||||||
| onTap: () { | ||||||
| switch (value) { | ||||||
| case 'H': | ||||||
| return callback('M'); | ||||||
| case 'M': | ||||||
| return callback('L'); | ||||||
| case 'L': | ||||||
| return callback(null); | ||||||
| default: | ||||||
| return callback('H'); | ||||||
| } | ||||||
| }, | ||||||
| onTap: isEditable | ||||||
| ? () { | ||||||
| switch (priority) { | ||||||
| case 'X': | ||||||
| callback('H'); | ||||||
| break; | ||||||
| case 'H': | ||||||
| callback('M'); | ||||||
| break; | ||||||
| case 'M': | ||||||
| callback('L'); | ||||||
| break; | ||||||
| case 'L': | ||||||
| callback('X'); | ||||||
|
||||||
| callback('X'); | |
| callback(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment should be properly formatted with consistent spacing. Comments should start with a space after the double-slash to follow Dart style conventions.