Browse Source

Fix: Add cancel option for file delete prompts

Neeraj Gupta 2 years ago
parent
commit
0d1d3bc803
2 changed files with 17 additions and 3 deletions
  1. 1 0
      lib/ui/components/button_widget.dart
  2. 16 3
      lib/ui/viewer/file/fading_app_bar.dart

+ 1 - 0
lib/ui/components/button_widget.dart

@@ -24,6 +24,7 @@ enum ButtonAction {
   first,
   second,
   third,
+  fourth,
   cancel,
   error;
 }

+ 16 - 3
lib/ui/viewer/file/fading_app_bar.dart

@@ -357,11 +357,11 @@ class FadingAppBarState extends State<FadingAppBar> {
     const String bodyHighlight = "It will be deleted from all albums.";
     String body = "";
     if (isBothLocalAndRemote) {
-      body = "This photo is in both ente and your device.";
+      body = "This $fileType is in both ente and your device.";
     } else if (isRemoteOnly) {
-      body = "This photo will be deleted from ente.";
+      body = "This $fileType will be deleted from ente.";
     } else if (isLocalOnly) {
-      body = "This photo will be deleted from your device.";
+      body = "This $fileType will be deleted from your device.";
     } else {
       throw AssertionError("Unexpected state");
     }
@@ -425,6 +425,16 @@ class FadingAppBarState extends State<FadingAppBar> {
         ),
       );
     }
+    buttons.add(
+      const ButtonWidget(
+        labelText: "Cancel",
+        buttonType: ButtonType.secondary,
+        buttonSize: ButtonSize.large,
+        shouldStickToDarkTheme: true,
+        buttonAction: ButtonAction.fourth,
+        isInAlert: true,
+      ),
+    );
     final ButtonAction? result = await showActionSheet(
       context: context,
       buttons: buttons,
@@ -433,6 +443,9 @@ class FadingAppBarState extends State<FadingAppBar> {
       body: body,
       bodyHighlight: bodyHighlight,
     );
+    if (result != null && result == ButtonAction.error) {
+      showGenericErrorDialog(context: context);
+    }
   }
 
   Future<void> _download(File file) async {