Browse Source

Merge pull request #734 from ente-io/fix_discard_edit_ui

Switch to new actionSheet for discard edit warning
Neeraj Gupta 2 years ago
parent
commit
fda4985b6f
1 changed files with 25 additions and 22 deletions
  1. 25 22
      lib/ui/tools/editor/image_editor_page.dart

+ 25 - 22
lib/ui/tools/editor/image_editor_page.dart

@@ -18,6 +18,9 @@ import 'package:photos/models/location.dart';
 import 'package:photos/services/local_sync_service.dart';
 import 'package:photos/services/local_sync_service.dart';
 import 'package:photos/services/sync_service.dart';
 import 'package:photos/services/sync_service.dart';
 import 'package:photos/ui/common/loading_widget.dart';
 import 'package:photos/ui/common/loading_widget.dart';
+import 'package:photos/ui/components/action_sheet_widget.dart';
+import 'package:photos/ui/components/button_widget.dart';
+import 'package:photos/ui/components/models/button_type.dart';
 import 'package:photos/ui/tools/editor/filtered_image.dart';
 import 'package:photos/ui/tools/editor/filtered_image.dart';
 import 'package:photos/ui/viewer/file/detail_page.dart';
 import 'package:photos/ui/viewer/file/detail_page.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/dialog_util.dart';
@@ -495,31 +498,31 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
   }
   }
 
 
   Future<void> _showExitConfirmationDialog() async {
   Future<void> _showExitConfirmationDialog() async {
-    final AlertDialog alert = AlertDialog(
-      title: const Text("Discard edits?"),
-      actions: [
-        TextButton(
-          child: const Text("Yes", style: TextStyle(color: Colors.red)),
-          onPressed: () {
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-            replacePage(context, DetailPage(widget.detailPageConfig));
-          },
+    final actionResult = await showActionSheet(
+      context: context,
+      buttons: [
+        const ButtonWidget(
+          labelText: "Yes, discard changes",
+          buttonType: ButtonType.critical,
+          buttonSize: ButtonSize.large,
+          shouldStickToDarkTheme: true,
+          buttonAction: ButtonAction.first,
+          isInAlert: true,
         ),
         ),
-        TextButton(
-          child: const Text("No", style: TextStyle(color: Colors.white)),
-          onPressed: () {
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-          },
+        const ButtonWidget(
+          labelText: "No",
+          buttonType: ButtonType.secondary,
+          buttonSize: ButtonSize.large,
+          buttonAction: ButtonAction.second,
+          shouldStickToDarkTheme: true,
+          isInAlert: true,
         ),
         ),
       ],
       ],
+      body: "Do you want to discard the edits you have made?",
+      actionSheetType: ActionSheetType.defaultActionSheet,
     );
     );
-
-    await showDialog(
-      context: context,
-      builder: (BuildContext context) {
-        return alert;
-      },
-      barrierColor: Colors.black87,
-    );
+    if (actionResult != null && actionResult == ButtonAction.first) {
+      replacePage(context, DetailPage(widget.detailPageConfig));
+    }
   }
   }
 }
 }