Browse Source

Merge pull request #736 from ente-io/replace-dialogs

Replace dialog in 'Delete account'.
Ashil 2 years ago
parent
commit
a1c6e64504

+ 2 - 1
lib/services/billing_service.dart

@@ -15,6 +15,7 @@ import 'package:photos/models/subscription.dart';
 import 'package:photos/models/user_details.dart';
 import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/common/web_page.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 
 const kWebPaymentRedirectUrl = "https://payments.ente.io/frameRedirect";
@@ -194,7 +195,7 @@ class BillingService {
       );
     } catch (e) {
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
     await dialog.hide();
   }

+ 2 - 1
lib/services/hidden_service.dart

@@ -14,6 +14,7 @@ import 'package:photos/models/file.dart';
 import 'package:photos/models/magic_metadata.dart';
 import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/file_magic_service.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/crypto_util.dart';
 import 'package:photos/utils/dialog_util.dart';
 
@@ -90,7 +91,7 @@ extension HiddenService on CollectionsService {
     } catch (e, s) {
       _logger.severe("Could not hide", e, s);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
       return false;
     } finally {
       await dialog.hide();

+ 8 - 17
lib/services/user_service.dart

@@ -30,6 +30,7 @@ import 'package:photos/ui/account/password_reentry_page.dart';
 import 'package:photos/ui/account/two_factor_authentication_page.dart';
 import 'package:photos/ui/account/two_factor_recovery_page.dart';
 import 'package:photos/ui/account/two_factor_setup_page.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/crypto_util.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/navigation_util.dart';
@@ -96,7 +97,7 @@ class UserService {
         );
         return;
       }
-      unawaited(showGenericErrorDialog(context));
+      unawaited(showGenericErrorDialog(context: context));
     } on DioError catch (e) {
       await dialog.hide();
       _logger.info(e);
@@ -109,12 +110,12 @@ class UserService {
           ),
         );
       } else {
-        unawaited(showGenericErrorDialog(context));
+        unawaited(showGenericErrorDialog(context: context));
       }
     } catch (e) {
       await dialog.hide();
       _logger.severe(e);
-      unawaited(showGenericErrorDialog(context));
+      unawaited(showGenericErrorDialog(context: context));
     }
   }
 
@@ -196,7 +197,7 @@ class UserService {
     } catch (e) {
       _logger.severe(e);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 
@@ -220,7 +221,7 @@ class UserService {
     } catch (e) {
       _logger.severe(e);
       await dialog.hide();
-      await showGenericErrorDialog(context);
+      await showGenericErrorDialog(context: context);
       return null;
     }
   }
@@ -229,8 +230,6 @@ class UserService {
     BuildContext context,
     String challengeResponse,
   ) async {
-    final dialog = createProgressDialog(context, "Deleting account...");
-    await dialog.show();
     try {
       final response = await _enteDio.delete(
         "/users/delete",
@@ -241,20 +240,12 @@ class UserService {
       if (response != null && response.statusCode == 200) {
         // clear data
         await Configuration.instance.logout();
-        await dialog.hide();
-        showToast(
-          context,
-          "We have deleted your account and scheduled your uploaded data "
-          "for deletion.",
-        );
-        Navigator.of(context).popUntil((route) => route.isFirst);
       } else {
         throw Exception("delete action failed");
       }
     } catch (e) {
       _logger.severe(e);
-      await dialog.hide();
-      showGenericErrorDialog(context);
+      rethrow;
     }
   }
 
@@ -657,7 +648,7 @@ class UserService {
     try {
       recoveryKey = await getOrCreateRecoveryKey(context);
     } catch (e) {
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
       return false;
     }
     final dialog = createProgressDialog(context, "Verifying...");

+ 26 - 17
lib/ui/account/delete_account_page.dart

@@ -8,8 +8,9 @@ import 'package:photos/core/configuration.dart';
 import 'package:photos/models/delete_account.dart';
 import 'package:photos/services/local_authentication_service.dart';
 import 'package:photos/services/user_service.dart';
-import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/common/gradient_button.dart';
+import 'package:photos/ui/components/button_widget.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/crypto_util.dart';
 import 'package:photos/utils/email_util.dart';
 
@@ -150,26 +151,34 @@ class DeleteAccountPage extends StatelessWidget {
     );
 
     if (hasAuthenticated) {
-      final choice = await showChoiceDialog(
-        context,
-        'Are you sure you want to delete your account?',
-        'Your uploaded data will be scheduled for deletion, and your account '
+      final choice = await showNewChoiceDialog(
+        context: context,
+        title: 'Are you sure you want to delete your account?',
+        body:
+            'Your uploaded data will be scheduled for deletion, and your account'
             'will be permanently deleted. \n\nThis action is not reversible.',
-        firstAction: 'Cancel',
-        secondAction: 'Delete',
-        firstActionColor: Theme.of(context).colorScheme.onSurface,
-        secondActionColor: Colors.red,
+        firstButtonLabel: "Delete my account",
+        isCritical: true,
+        firstButtonOnTap: () async {
+          final decryptChallenge = CryptoUtil.openSealSync(
+            Sodium.base642bin(response.encryptedChallenge),
+            Sodium.base642bin(
+              Configuration.instance.getKeyAttributes().publicKey,
+            ),
+            Configuration.instance.getSecretKey(),
+          );
+          final challengeResponseStr = utf8.decode(decryptChallenge);
+          await UserService.instance
+              .deleteAccount(context, challengeResponseStr);
+        },
       );
-      if (choice != DialogUserChoice.secondChoice) {
+      if (choice == ButtonAction.error) {
+        showGenericErrorDialog(context: context);
+      }
+      if (choice != ButtonAction.first) {
         return;
       }
-      final decryptChallenge = CryptoUtil.openSealSync(
-        Sodium.base642bin(response.encryptedChallenge),
-        Sodium.base642bin(Configuration.instance.getKeyAttributes().publicKey),
-        Configuration.instance.getSecretKey(),
-      );
-      final challengeResponseStr = utf8.decode(decryptChallenge);
-      await UserService.instance.deleteAccount(context, challengeResponseStr);
+      Navigator.of(context).popUntil((route) => route.isFirst);
     }
   }
 

+ 4 - 3
lib/ui/account/password_entry_page.dart

@@ -12,6 +12,7 @@ import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/account/recovery_key_page.dart';
 import 'package:photos/ui/common/dynamic_fab.dart';
 import 'package:photos/ui/common/web_page.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/payment/subscription.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/navigation_util.dart';
@@ -399,7 +400,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
     } catch (e, s) {
       _logger.severe(e, s);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 
@@ -429,7 +430,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
         } catch (e, s) {
           _logger.severe(e, s);
           await dialog.hide();
-          showGenericErrorDialog(context);
+          showGenericErrorDialog(context: context);
         }
       }
 
@@ -454,7 +455,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
           "Sorry, we could not generate secure keys on this device.\n\nplease sign up from a different device.",
         );
       } else {
-        showGenericErrorDialog(context);
+        showGenericErrorDialog(context: context);
       }
     }
   }

+ 3 - 2
lib/ui/account/verify_recovery_page.dart

@@ -14,6 +14,7 @@ import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/account/recovery_key_page.dart';
 import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/common/gradient_button.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/navigation_util.dart';
 
@@ -49,7 +50,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
               "Please check your internet connection and try again.",
             );
           } else {
-            await showGenericErrorDialog(context);
+            await showGenericErrorDialog(context: context);
           }
           return;
         }
@@ -111,7 +112,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
           ),
         );
       } catch (e) {
-        showGenericErrorDialog(context);
+        showGenericErrorDialog(context: context);
         return;
       }
     }

+ 6 - 3
lib/ui/actions/collection/collection_file_actions.dart

@@ -8,6 +8,7 @@ import 'package:photos/services/favorites_service.dart';
 import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
 import 'package:photos/ui/common/progress_dialog.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/toast_util.dart';
 
@@ -51,8 +52,10 @@ extension CollectionFileActions on CollectionActions {
           isDestructiveAction: true,
           onPressed: () async {
             Navigator.of(context, rootNavigator: true).pop();
-            final dialog = createProgressDialog(context,
-                showDeletePrompt ? "Deleting files..." : "Removing files...",);
+            final dialog = createProgressDialog(
+              context,
+              showDeletePrompt ? "Deleting files..." : "Removing files...",
+            );
             await dialog.show();
             try {
               await collectionsService.removeFromCollection(
@@ -64,7 +67,7 @@ extension CollectionFileActions on CollectionActions {
             } catch (e, s) {
               logger.severe(e, s);
               await dialog.hide();
-              showGenericErrorDialog(context);
+              showGenericErrorDialog(context: context);
             }
           },
           child: Text(showDeletePrompt ? "Yes, delete" : "Yes, remove"),

+ 6 - 5
lib/ui/actions/collection/collection_sharing_actions.dart

@@ -11,6 +11,7 @@ import 'package:photos/services/hidden_service.dart';
 import 'package:photos/services/user_service.dart';
 import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/ui/common/dialogs.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/payment/subscription.dart';
 import 'package:photos/utils/date_time_util.dart';
 import 'package:photos/utils/dialog_util.dart';
@@ -60,7 +61,7 @@ class CollectionActions {
         _showUnSupportedAlert(context);
       } else {
         logger.severe("Failed to update shareUrl collection", e);
-        showGenericErrorDialog(context);
+        showGenericErrorDialog(context: context);
       }
       return false;
     }
@@ -105,7 +106,7 @@ class CollectionActions {
       return collection;
     } catch (e, s) {
       dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
       logger.severe("Failing to create link for selected files", e, s);
     }
     return null;
@@ -142,7 +143,7 @@ class CollectionActions {
     } catch (e, s) {
       Logger("EmailItemWidget").severe(e, s);
       await dialog.hide();
-      await showGenericErrorDialog(context);
+      await showGenericErrorDialog(context: context);
       return false;
     }
   }
@@ -182,7 +183,7 @@ class CollectionActions {
         await dialog.hide();
       } catch (e) {
         logger.severe("Failed to get public key", e);
-        showGenericErrorDialog(context);
+        showGenericErrorDialog(context: context);
         await dialog.hide();
       }
     }
@@ -238,7 +239,7 @@ class CollectionActions {
           _showUnSupportedAlert(context);
         } else {
           logger.severe("failed to share collection", e);
-          showGenericErrorDialog(context);
+          showGenericErrorDialog(context: context);
         }
         return false;
       }

+ 2 - 1
lib/ui/backup_folder_selection_page.dart

@@ -16,6 +16,7 @@ import 'package:photos/models/device_collection.dart';
 import 'package:photos/models/file.dart';
 import 'package:photos/services/remote_sync_service.dart';
 import 'package:photos/ui/common/loading_widget.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 
@@ -228,7 +229,7 @@ class _BackupFolderSelectionPageState extends State<BackupFolderSelectionPage> {
     } catch (e, s) {
       _logger.severe("Failed to updated backup folder", e, s);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 

+ 2 - 2
lib/ui/components/button_widget.dart

@@ -56,7 +56,7 @@ class ButtonWidget extends StatelessWidget {
   final bool isInAlert;
   const ButtonWidget({
     required this.buttonType,
-    required this.buttonSize,
+    this.buttonSize = ButtonSize.large,
     this.icon,
     this.labelText,
     this.onTap,
@@ -357,7 +357,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
       if (executionState == ExecutionState.inProgress) {
         setState(() {
           executionState = ExecutionState.successful;
-          Future.delayed(Duration(seconds: widget.isInAlert ? 1 : 2), () {
+          Future.delayed(const Duration(seconds: 2), () {
             widget.isInAlert
                 ? Navigator.of(context, rootNavigator: true)
                     .pop(widget.buttonAction)

+ 59 - 1
lib/ui/components/dialog_widget.dart

@@ -6,9 +6,67 @@ import 'package:photos/theme/colors.dart';
 import 'package:photos/theme/effects.dart';
 import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/ui/components/button_widget.dart';
+import 'package:photos/ui/components/models/button_type.dart';
 import 'package:photos/utils/separators_util.dart';
 
-Future<dynamic> showDialogWidget({
+Future<ButtonAction?> showGenericErrorDialog({
+  required BuildContext context,
+}) async {
+  return showDialogWidget(
+    context: context,
+    title: "Error",
+    icon: Icons.error_outline_outlined,
+    body: "It looks like something went wrong. Please try again.",
+    buttons: const [
+      ButtonWidget(
+        buttonType: ButtonType.secondary,
+        labelText: "OK",
+        isInAlert: true,
+      ),
+    ],
+  );
+}
+
+Future<ButtonAction?> showNewChoiceDialog({
+  required BuildContext context,
+  required String title,
+  required String body,
+  required String firstButtonLabel,
+  String secondButtonLabel = "Cancel",
+  ButtonType firstButtonType = ButtonType.neutral,
+  ButtonType secondButtonType = ButtonType.secondary,
+  ButtonAction firstButtonAction = ButtonAction.first,
+  ButtonAction secondButtonAction = ButtonAction.cancel,
+  FutureVoidCallback? firstButtonOnTap,
+  FutureVoidCallback? secondButtonOnTap,
+  bool isCritical = false,
+  IconData? icon,
+}) async {
+  final buttons = [
+    ButtonWidget(
+      buttonType: isCritical ? ButtonType.critical : firstButtonType,
+      labelText: firstButtonLabel,
+      isInAlert: true,
+      onTap: firstButtonOnTap,
+      buttonAction: firstButtonAction,
+    ),
+    ButtonWidget(
+      buttonType: secondButtonType,
+      labelText: secondButtonLabel,
+      isInAlert: true,
+      onTap: secondButtonOnTap,
+      buttonAction: secondButtonAction,
+    ),
+  ];
+  return showDialogWidget(
+    context: context,
+    title: title,
+    body: body,
+    buttons: buttons,
+  );
+}
+
+Future<ButtonAction?> showDialogWidget({
   required BuildContext context,
   required String title,
   required String body,

+ 5 - 4
lib/ui/create_collection_page.dart

@@ -14,6 +14,7 @@ import 'package:photos/services/ignored_files_service.dart';
 import 'package:photos/services/remote_sync_service.dart';
 import 'package:photos/ui/common/gradient_button.dart';
 import 'package:photos/ui/common/loading_widget.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/viewer/file/no_thumbnail_widget.dart';
 import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
 import 'package:photos/ui/viewer/gallery/collection_page.dart';
@@ -323,7 +324,7 @@ class _CreateCollectionPageState extends State<CreateCollectionPage> {
     } catch (e, s) {
       _logger.severe("Could not move to album", e, s);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
       return false;
     }
   }
@@ -345,7 +346,7 @@ class _CreateCollectionPageState extends State<CreateCollectionPage> {
     } catch (e, s) {
       _logger.severe("Could not move to album", e, s);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
       return false;
     }
   }
@@ -391,7 +392,7 @@ class _CreateCollectionPageState extends State<CreateCollectionPage> {
     } catch (e, s) {
       _logger.severe("Could not add to album", e, s);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
     return false;
   }
@@ -405,7 +406,7 @@ class _CreateCollectionPageState extends State<CreateCollectionPage> {
     } catch (e, s) {
       _logger.severe(e, s);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     } finally {
       await dialog.hide();
     }

+ 2 - 1
lib/ui/notification/prompts/password_reminder.dart

@@ -11,6 +11,7 @@ import 'package:photos/theme/colors.dart';
 import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/ui/account/password_entry_page.dart';
 import 'package:photos/ui/common/gradient_button.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/home_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/navigation_util.dart';
@@ -93,7 +94,7 @@ class _PasswordReminderState extends State<PasswordReminder> {
         );
       }
     } catch (e) {
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
       return;
     }
   }

+ 2 - 1
lib/ui/payment/child_subscription_widget.dart

@@ -5,6 +5,7 @@ import 'package:photos/ente_theme_data.dart';
 import 'package:photos/models/user_details.dart';
 import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/common/dialogs.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 
 class ChildSubscriptionWidget extends StatelessWidget {
@@ -140,7 +141,7 @@ class ChildSubscriptionWidget extends StatelessWidget {
       Navigator.of(context).pop('');
     } catch (e) {
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 }

+ 2 - 1
lib/ui/payment/payment_web_page.dart

@@ -12,6 +12,7 @@ import 'package:photos/services/billing_service.dart';
 import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/common/loading_widget.dart';
 import 'package:photos/ui/common/progress_dialog.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 
 class PaymentWebPage extends StatefulWidget {
@@ -186,7 +187,7 @@ class _PaymentWebPageState extends State<PaymentWebPage> {
     } else {
       // should never reach here
       _logger.severe("unexpected status", uri.toString());
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 

+ 2 - 1
lib/ui/payment/stripe_subscription_page.dart

@@ -15,6 +15,7 @@ import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/common/loading_widget.dart';
 import 'package:photos/ui/common/progress_dialog.dart';
 import 'package:photos/ui/common/web_page.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/payment/child_subscription_widget.dart';
 import 'package:photos/ui/payment/payment_web_page.dart';
 import 'package:photos/ui/payment/skip_subscription_widget.dart';
@@ -323,7 +324,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
       ).then((value) => onWebPaymentGoBack);
     } catch (e) {
       await _dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
     await _dialog.hide();
   }

+ 2 - 1
lib/ui/payment/subscription_page.dart

@@ -16,6 +16,7 @@ import 'package:photos/services/billing_service.dart';
 import 'package:photos/services/user_service.dart';
 import 'package:photos/ui/common/loading_widget.dart';
 import 'package:photos/ui/common/progress_dialog.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/payment/child_subscription_widget.dart';
 import 'package:photos/ui/payment/skip_subscription_widget.dart';
 import 'package:photos/ui/payment/subscription_common_widgets.dart';
@@ -403,7 +404,7 @@ class _SubscriptionPageState extends State<SubscriptionPage> {
                   "Could not find products: " + response.notFoundIDs.toString(),
                 );
                 await _dialog.hide();
-                showGenericErrorDialog(context);
+                showGenericErrorDialog(context: context);
                 return;
               }
               final isCrossGradingOnAndroid = Platform.isAndroid &&

+ 3 - 3
lib/ui/settings/account_section_widget.dart

@@ -13,10 +13,10 @@ import 'package:photos/ui/account/delete_account_page.dart';
 import 'package:photos/ui/account/password_entry_page.dart';
 import 'package:photos/ui/account/recovery_key_page.dart';
 import 'package:photos/ui/components/captioned_text_widget.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/components/expandable_menu_item_widget.dart';
 import 'package:photos/ui/components/menu_item_widget.dart';
 import 'package:photos/ui/settings/common_settings.dart';
-import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/navigation_util.dart';
 
 class AccountSectionWidget extends StatelessWidget {
@@ -53,7 +53,7 @@ class AccountSectionWidget extends StatelessWidget {
               try {
                 recoveryKey = await _getOrCreateRecoveryKey(context);
               } catch (e) {
-                await showGenericErrorDialog(context);
+                await showGenericErrorDialog(context: context);
                 return;
               }
               unawaited(
@@ -158,7 +158,7 @@ class AccountSectionWidget extends StatelessWidget {
     );
   }
 
-    Future<void> _onLogoutTapped(BuildContext context) async {
+  Future<void> _onLogoutTapped(BuildContext context) async {
     final AlertDialog alert = AlertDialog(
       title: const Text(
         "Logout",

+ 3 - 2
lib/ui/settings/backup_section_widget.dart

@@ -13,6 +13,7 @@ import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/ui/backup_folder_selection_page.dart';
 import 'package:photos/ui/backup_settings_screen.dart';
 import 'package:photos/ui/components/captioned_text_widget.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/components/expandable_menu_item_widget.dart';
 import 'package:photos/ui/components/menu_item_widget.dart';
 import 'package:photos/ui/settings/common_settings.dart';
@@ -95,7 +96,7 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
               status = await SyncService.instance.getBackupStatus();
             } catch (e) {
               await dialog.hide();
-              showGenericErrorDialog(context);
+              showGenericErrorDialog(context: context);
               return;
             }
 
@@ -132,7 +133,7 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
                   await DeduplicationService.instance.getDuplicateFiles();
             } catch (e) {
               await dialog.hide();
-              showGenericErrorDialog(context);
+              showGenericErrorDialog(context: context);
               return;
             }
 

+ 2 - 1
lib/ui/sharing/manage_links_widget.dart

@@ -15,6 +15,7 @@ import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';
 import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/components/captioned_text_widget.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/components/divider_widget.dart';
 import 'package:photos/ui/components/menu_item_widget.dart';
 import 'package:photos/ui/components/menu_section_description_widget.dart';
@@ -494,7 +495,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
       showShortToast(context, "Album updated");
     } catch (e) {
       await dialog.hide();
-      await showGenericErrorDialog(context);
+      await showGenericErrorDialog(context: context);
     }
   }
 

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

@@ -25,6 +25,7 @@ import 'package:photos/services/hidden_service.dart';
 import 'package:photos/services/ignored_files_service.dart';
 import 'package:photos/services/local_sync_service.dart';
 import 'package:photos/ui/common/progress_dialog.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/create_collection_page.dart';
 import 'package:photos/ui/viewer/file/custom_app_bar.dart';
 import 'package:photos/utils/delete_file_util.dart';
@@ -264,7 +265,7 @@ class FadingAppBarState extends State<FadingAppBar> {
       }
     } catch (e, s) {
       _logger.severe("failed to update file visibility", e, s);
-      await showGenericErrorDialog(context);
+      await showGenericErrorDialog(context: context);
     }
   }
 
@@ -469,7 +470,7 @@ class FadingAppBarState extends State<FadingAppBar> {
     } catch (e) {
       _logger.warning("Failed to save file", e);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 
@@ -517,7 +518,7 @@ class FadingAppBarState extends State<FadingAppBar> {
     } catch (e) {
       dialog.hide();
       _logger.severe("Failed to use as", e);
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 }

+ 6 - 5
lib/ui/viewer/gallery/gallery_app_bar_widget.dart

@@ -21,6 +21,7 @@ import 'package:photos/services/sync_service.dart';
 import 'package:photos/services/update_service.dart';
 import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/common/rename_dialog.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/sharing/album_participants_page.dart';
 import 'package:photos/ui/sharing/share_collection_page.dart';
 import 'package:photos/ui/tools/free_space_page.dart';
@@ -132,7 +133,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
       }
     } catch (e) {
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 
@@ -159,7 +160,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
       }
     } catch (e) {
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 
@@ -176,7 +177,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
           .getBackupStatus(pathID: widget.deviceCollection.id);
     } catch (e) {
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
       return;
     }
 
@@ -423,7 +424,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
     } catch (e, s) {
       _logger.severe("failed to trash collection", e, s);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 
@@ -454,7 +455,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
       }
     } catch (e, s) {
       _logger.severe(e, s);
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
     }
   }
 }

+ 4 - 3
lib/ui/viewer/gallery/gallery_overlay_widget.dart

@@ -18,6 +18,7 @@ import 'package:photos/models/magic_metadata.dart';
 import 'package:photos/models/selected_files.dart';
 import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/hidden_service.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/create_collection_page.dart';
 import 'package:photos/utils/delete_file_util.dart';
 import 'package:photos/utils/dialog_util.dart';
@@ -511,7 +512,7 @@ class _OverlayWidgetState extends State<OverlayWidget> {
       );
     } catch (e, s) {
       _logger.severe("failed to update file visibility", e, s);
-      await showGenericErrorDialog(context);
+      await showGenericErrorDialog(context: context);
     } finally {
       _clearSelectedFiles();
     }
@@ -528,7 +529,7 @@ class _OverlayWidgetState extends State<OverlayWidget> {
       }
     } catch (e, s) {
       _logger.severe("failed to update file visibility", e, s);
-      await showGenericErrorDialog(context);
+      await showGenericErrorDialog(context: context);
     }
   }
 
@@ -665,7 +666,7 @@ class _OverlayWidgetState extends State<OverlayWidget> {
             } catch (e, s) {
               _logger.severe(e, s);
               await dialog.hide();
-              showGenericErrorDialog(context);
+              showGenericErrorDialog(context: context);
             }
           },
           child: const Text("Remove"),

+ 5 - 4
lib/utils/delete_file_util.dart

@@ -24,6 +24,7 @@ import 'package:photos/services/sync_service.dart';
 import 'package:photos/services/trash_sync_service.dart';
 import 'package:photos/ui/common/dialogs.dart';
 import 'package:photos/ui/common/linear_progress_dialog.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/file_util.dart';
 import 'package:photos/utils/toast_util.dart';
@@ -107,7 +108,7 @@ Future<void> deleteFilesFromEverywhere(
     } catch (e) {
       _logger.severe(e);
       await dialog.hide();
-      showGenericErrorDialog(context);
+      showGenericErrorDialog(context: context);
       rethrow;
     }
     for (final collectionID in updatedCollectionIDs) {
@@ -172,7 +173,7 @@ Future<void> deleteFilesFromRemoteOnly(
   } catch (e, s) {
     _logger.severe("Failed to delete files from remote", e, s);
     await dialog.hide();
-    showGenericErrorDialog(context);
+    showGenericErrorDialog(context: context);
     rethrow;
   }
   for (final collectionID in updatedCollectionIDs) {
@@ -288,7 +289,7 @@ Future<bool> deleteFromTrash(BuildContext context, List<File> files) async {
   } catch (e, s) {
     _logger.info("failed to delete from trash", e, s);
     await dialog.hide();
-    await showGenericErrorDialog(context);
+    await showGenericErrorDialog(context: context);
     return false;
   }
 }
@@ -314,7 +315,7 @@ Future<bool> emptyTrash(BuildContext context) async {
   } catch (e, s) {
     _logger.info("failed empty trash", e, s);
     await dialog.hide();
-    await showGenericErrorDialog(context);
+    await showGenericErrorDialog(context: context);
     return false;
   }
 }

+ 0 - 4
lib/utils/dialog_util.dart

@@ -68,10 +68,6 @@ Future<dynamic> showErrorDialog(
   );
 }
 
-Future<dynamic> showGenericErrorDialog(BuildContext context) {
-  return showErrorDialog(context, "Something went wrong", "Please try again.");
-}
-
 Future<T> showConfettiDialog<T>({
   @required BuildContext context,
   WidgetBuilder builder,

+ 2 - 1
lib/utils/share_util.dart

@@ -10,6 +10,7 @@ import 'package:photos/core/configuration.dart';
 import 'package:photos/core/constants.dart';
 import 'package:photos/models/file.dart';
 import 'package:photos/models/file_type.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/utils/date_time_util.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/exif_util.dart';
@@ -61,7 +62,7 @@ Future<void> share(
       s,
     );
     await dialog.hide();
-    await showGenericErrorDialog(context);
+    await showGenericErrorDialog(context: context);
   }
 }