Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] Confirm before discarding sub-editor changes

r4khul54312e8cca3e
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
index cd62c60203..0948d0ff28 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart
@@ -190,7 +190,7 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
}
}
- Future<void> _showExitConfirmationDialog(BuildContext context) async {
+ Future<bool> _confirmDiscardEdits(BuildContext context) async {
final l10n = context.strings;
final actionResult = await showActionSheet(
context: context,
@@ -216,13 +216,21 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
body: l10n.doYouWantToDiscardTheEditsYouHaveMade,
actionSheetType: ActionSheetType.defaultActionSheet,
);
- if (!context.mounted) return;
- if (actionResult?.action != null &&
- actionResult!.action == ButtonAction.first) {
+ return actionResult?.action == ButtonAction.first;
+ }
+
+ Future<void> _showExitConfirmationDialog(BuildContext context) async {
+ if (await _confirmDiscardEdits(context) && context.mounted) {
replacePage(context, DetailPage(widget.detailPageConfig));
}
}
+ Future<void> _showSubEditorDiscardDialog(BuildContext context) async {
+ if (await _confirmDiscardEdits(context) && context.mounted) {
+ Navigator.of(context).pop();
+ }
+ }
+
@override
Widget build(BuildContext context) {
final isLightMode = Theme.of(context).brightness == Brightness.light;
@@ -269,7 +277,7 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
callbacks: ProImageEditorCallbacks(
onCloseEditor: (mode) {
if (mode != EditorMode.main) {
- Navigator.of(context).pop();
+ _showSubEditorDiscardDialog(context);
return;
}
editorKey.currentState?.isPopScopeDisabled = true;