Przeglądaj źródła

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

Replace dialogs
Neeraj Gupta 2 lat temu
rodzic
commit
af641c1a65

+ 0 - 1
lib/services/billing_service.dart

@@ -13,7 +13,6 @@ 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";

+ 0 - 1
lib/services/hidden_service.dart

@@ -14,7 +14,6 @@ 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';
 

+ 0 - 1
lib/services/user_service.dart

@@ -30,7 +30,6 @@ 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';

+ 1 - 1
lib/ui/account/delete_account_page.dart

@@ -10,9 +10,9 @@ import 'package:photos/services/local_authentication_service.dart';
 import 'package:photos/services/user_service.dart';
 import 'package:photos/theme/ente_theme.dart';
 import 'package:photos/ui/components/button_widget.dart';
-import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/components/models/button_type.dart';
 import 'package:photos/utils/crypto_util.dart';
+import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/email_util.dart';
 
 class DeleteAccountPage extends StatelessWidget {

+ 0 - 1
lib/ui/account/password_entry_page.dart

@@ -12,7 +12,6 @@ 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';

+ 0 - 1
lib/ui/account/verify_recovery_page.dart

@@ -14,7 +14,6 @@ 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';
 

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

@@ -8,7 +8,6 @@ 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';
 
@@ -21,7 +20,9 @@ extension CollectionFileActions on CollectionActions {
     final count = selectedFiles.files.length;
     final textTheme = getEnteTextTheme(context);
     final showDeletePrompt = await _anyItemPresentOnlyInCurrentAlbum(
-        selectedFiles.files, collection.id);
+      selectedFiles.files,
+      collection.id,
+    );
     final String title =
         showDeletePrompt ? "Delete items?" : "Remove from album?";
     final String message1 = showDeletePrompt

+ 0 - 1
lib/ui/actions/collection/collection_sharing_actions.dart

@@ -11,7 +11,6 @@ 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';

+ 0 - 1
lib/ui/backup_folder_selection_page.dart

@@ -16,7 +16,6 @@ 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';
 

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

@@ -6,73 +6,8 @@ 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';
 
-///Will return null if dismissed by tapping outside
-Future<ButtonAction?> showGenericErrorDialog({
-  required BuildContext context,
-  bool isDismissible = true,
-}) async {
-  return showDialogWidget(
-    context: context,
-    title: "Error",
-    icon: Icons.error_outline_outlined,
-    body: "It looks like something went wrong. Please try again.",
-    isDismissible: isDismissible,
-    buttons: const [
-      ButtonWidget(
-        buttonType: ButtonType.secondary,
-        labelText: "OK",
-        isInAlert: true,
-      ),
-    ],
-  );
-}
-
-///Will return null if dismissed by tapping outside
-Future<ButtonAction?> showNewChoiceDialog({
-  required BuildContext context,
-  required String title,
-  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,
-  bool isDismissible = true,
-}) 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,
-    icon: icon,
-    isDismissible: isDismissible,
-  );
-}
-
 ///Will return null if dismissed by tapping outside
 Future<ButtonAction?> showDialogWidget({
   required BuildContext context,
@@ -97,7 +32,6 @@ Future<ButtonAction?> showDialogWidget({
             title: title,
             body: body,
             buttons: buttons,
-            isMobileSmall: isMobileSmall,
             icon: icon,
           ),
         ),
@@ -111,12 +45,10 @@ class DialogWidget extends StatelessWidget {
   final String? body;
   final List<ButtonWidget> buttons;
   final IconData? icon;
-  final bool isMobileSmall;
   const DialogWidget({
     required this.title,
     this.body,
     required this.buttons,
-    required this.isMobileSmall,
     this.icon,
     super.key,
   });
@@ -124,6 +56,7 @@ class DialogWidget extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     final widthOfScreen = MediaQuery.of(context).size.width;
+    final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
     final colorScheme = getEnteColorScheme(context);
     return Container(
       width: min(widthOfScreen, 320),

+ 0 - 1
lib/ui/create_collection_page.dart

@@ -14,7 +14,6 @@ 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';

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

@@ -11,7 +11,6 @@ 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';

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

@@ -3,7 +3,6 @@ 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 {

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

@@ -12,7 +12,6 @@ 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 {

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

@@ -15,7 +15,6 @@ 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';

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

@@ -16,7 +16,6 @@ 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';

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

@@ -11,10 +11,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 {

+ 46 - 76
lib/ui/settings/backup_section_widget.dart

@@ -3,7 +3,6 @@
 import 'dart:io';
 
 import 'package:flutter/material.dart';
-import 'package:photos/ente_theme_data.dart';
 import 'package:photos/models/backup_status.dart';
 import 'package:photos/models/duplicate_files.dart';
 import 'package:photos/services/deduplication_service.dart';
@@ -16,6 +15,7 @@ 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/components/models/button_type.dart';
 import 'package:photos/ui/settings/common_settings.dart';
 import 'package:photos/ui/tools/deduplicate_page.dart';
 import 'package:photos/ui/tools/free_space_page.dart';
@@ -162,45 +162,30 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
   }
 
   void _showSpaceFreedDialog(BackupStatus status) {
-    final AlertDialog alert = AlertDialog(
-      title: const Text("Success"),
-      content: Text(
-        "You have successfully freed up " + formatBytes(status.size) + "!",
-      ),
-      actions: [
-        TextButton(
-          child: Text(
-            "Rate us",
-            style: TextStyle(
-              color: Theme.of(context).colorScheme.greenAlternative,
-            ),
-          ),
-          onPressed: () {
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-            final url = UpdateService.instance.getRateDetails().item2;
-            launchUrlString(url);
-          },
-        ),
-        TextButton(
-          child: const Text(
-            "Ok",
-          ),
-          onPressed: () {
-            if (Platform.isIOS) {
-              showToast(
-                context,
-                "Also empty \"Recently Deleted\" from \"Settings\" -> \"Storage\" to claim the freed space",
-              );
-            }
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-          },
-        ),
-      ],
+    final DialogWidget dialog = choiceDialog(
+      title: "Success",
+      body: "You have successfully freed up " + formatBytes(status.size) + "!",
+      firstButtonLabel: "Rate us",
+      firstButtonOnTap: () async {
+        final url = UpdateService.instance.getRateDetails().item2;
+        launchUrlString(url);
+      },
+      firstButtonType: ButtonType.primary,
+      secondButtonLabel: "OK",
+      secondButtonOnTap: () async {
+        if (Platform.isIOS) {
+          showToast(
+            context,
+            "Also empty \"Recently Deleted\" from \"Settings\" -> \"Storage\" to claim the freed space",
+          );
+        }
+      },
     );
+
     showConfettiDialog(
       context: context,
-      builder: (BuildContext context) {
-        return alert;
+      dialogBuilder: (BuildContext context) {
+        return dialog;
       },
       barrierColor: Colors.black87,
       confettiAlignment: Alignment.topCenter,
@@ -212,48 +197,33 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
     final String countText = result.count.toString() +
         " duplicate file" +
         (result.count == 1 ? "" : "s");
-    final AlertDialog alert = AlertDialog(
-      title: const Text("✨ Success"),
-      content: Text(
-        "You have cleaned up " +
-            countText +
-            ", saving " +
-            formatBytes(result.size) +
-            "!",
-      ),
-      actions: [
-        TextButton(
-          child: Text(
-            "Rate us",
-            style: TextStyle(
-              color: Theme.of(context).colorScheme.greenAlternative,
-            ),
-          ),
-          onPressed: () {
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-            // TODO: Replace with https://pub.dev/packages/in_app_review
-            final url = UpdateService.instance.getRateDetails().item2;
-            launchUrlString(url);
-          },
-        ),
-        TextButton(
-          child: const Text(
-            "Ok",
-          ),
-          onPressed: () {
-            showShortToast(
-              context,
-              "Also empty your \"Trash\" to claim the freed up space",
-            );
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-          },
-        ),
-      ],
+    final DialogWidget dialog = choiceDialog(
+      title: "✨ Success",
+      body: "You have cleaned up " +
+          countText +
+          ", saving " +
+          formatBytes(result.size) +
+          "!",
+      firstButtonLabel: "Rate us",
+      firstButtonOnTap: () async {
+        // TODO: Replace with https://pub.dev/packages/in_app_review
+        final url = UpdateService.instance.getRateDetails().item2;
+        launchUrlString(url);
+      },
+      firstButtonType: ButtonType.primary,
+      secondButtonLabel: "OK",
+      secondButtonOnTap: () async {
+        showShortToast(
+          context,
+          "Also empty your \"Trash\" to claim the freed up space",
+        );
+      },
     );
+
     showConfettiDialog(
       context: context,
-      builder: (BuildContext context) {
-        return alert;
+      dialogBuilder: (BuildContext context) {
+        return dialog;
       },
       barrierColor: Colors.black87,
       confettiAlignment: Alignment.topCenter,

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

@@ -15,7 +15,6 @@ 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';

+ 0 - 1
lib/ui/viewer/file/fading_app_bar.dart

@@ -25,7 +25,6 @@ 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';

+ 23 - 37
lib/ui/viewer/gallery/gallery_app_bar_widget.dart

@@ -22,6 +22,7 @@ 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/components/models/button_type.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';
@@ -200,46 +201,31 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
   }
 
   void _showSpaceFreedDialog(BackupStatus status) {
-    final AlertDialog alert = AlertDialog(
-      title: const Text("Success"),
-      content: Text(
-        "You have successfully freed up " + formatBytes(status.size) + "!",
-      ),
-      actions: [
-        TextButton(
-          child: Text(
-            "Rate us",
-            style: TextStyle(
-              color: Theme.of(context).colorScheme.greenAlternative,
-            ),
-          ),
-          onPressed: () {
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-            // TODO: Replace with https://pub.dev/packages/in_app_review
-            final url = UpdateService.instance.getRateDetails().item2;
-            launchUrlString(url);
-          },
-        ),
-        TextButton(
-          child: const Text(
-            "Ok",
-          ),
-          onPressed: () {
-            if (Platform.isIOS) {
-              showToast(
-                context,
-                "Also empty \"Recently Deleted\" from \"Settings\" -> \"Storage\" to claim the freed space",
-              );
-            }
-            Navigator.of(context, rootNavigator: true).pop('dialog');
-          },
-        ),
-      ],
+    final DialogWidget dialog = choiceDialog(
+      title: "Success",
+      body: "You have successfully freed up " + formatBytes(status.size) + "!",
+      firstButtonLabel: "Rate us",
+      firstButtonOnTap: () async {
+        // TODO: Replace with https://pub.dev/packages/in_app_review
+        final url = UpdateService.instance.getRateDetails().item2;
+        launchUrlString(url);
+      },
+      firstButtonType: ButtonType.primary,
+      secondButtonLabel: "OK",
+      secondButtonOnTap: () async {
+        if (Platform.isIOS) {
+          showToast(
+            context,
+            "Also empty \"Recently Deleted\" from \"Settings\" -> \"Storage\" to claim the freed space",
+          );
+        }
+      },
     );
+
     showConfettiDialog(
       context: context,
-      builder: (BuildContext context) {
-        return alert;
+      dialogBuilder: (BuildContext context) {
+        return dialog;
       },
       barrierColor: Colors.black87,
       confettiAlignment: Alignment.topCenter,

+ 0 - 1
lib/ui/viewer/gallery/gallery_overlay_widget.dart

@@ -18,7 +18,6 @@ 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';

+ 0 - 1
lib/utils/delete_file_util.dart

@@ -24,7 +24,6 @@ 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';

+ 153 - 61
lib/utils/dialog_util.dart

@@ -1,11 +1,136 @@
-// @dart=2.9
-
 import 'dart:math';
 
 import 'package:confetti/confetti.dart';
 import 'package:flutter/material.dart';
+import 'package:photos/core/constants.dart';
 import 'package:photos/ui/common/loading_widget.dart';
 import 'package:photos/ui/common/progress_dialog.dart';
+import 'package:photos/ui/components/button_widget.dart';
+import 'package:photos/ui/components/dialog_widget.dart';
+import 'package:photos/ui/components/models/button_type.dart';
+
+typedef DialogBuilder = DialogWidget Function(BuildContext context);
+
+///Will return null if dismissed by tapping outside
+Future<ButtonAction?> showErrorDialog(
+  BuildContext context,
+  String title,
+  String? body, {
+  bool isDismissable = true,
+}) async {
+  return showDialogWidget(
+    context: context,
+    title: title,
+    body: body,
+    isDismissible: isDismissable,
+    buttons: const [
+      ButtonWidget(
+        buttonType: ButtonType.secondary,
+        labelText: "OK",
+        isInAlert: true,
+        buttonAction: ButtonAction.first,
+      ),
+    ],
+  );
+}
+
+///Will return null if dismissed by tapping outside
+Future<ButtonAction?> showGenericErrorDialog({
+  required BuildContext context,
+  bool isDismissible = true,
+}) async {
+  return showDialogWidget(
+    context: context,
+    title: "Error",
+    icon: Icons.error_outline_outlined,
+    body: "It looks like something went wrong. Please try again.",
+    isDismissible: isDismissible,
+    buttons: const [
+      ButtonWidget(
+        buttonType: ButtonType.secondary,
+        labelText: "OK",
+        isInAlert: true,
+      ),
+    ],
+  );
+}
+
+DialogWidget choiceDialog({
+  required String title,
+  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,
+}) {
+  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 DialogWidget(title: title, body: body, buttons: buttons, icon: icon);
+}
+
+///Will return null if dismissed by tapping outside
+Future<ButtonAction?> showNewChoiceDialog({
+  required BuildContext context,
+  required String title,
+  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,
+  bool isDismissible = true,
+}) 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,
+    icon: icon,
+    isDismissible: isDismissible,
+  );
+}
 
 ProgressDialog createProgressDialog(
   BuildContext context,
@@ -30,56 +155,20 @@ ProgressDialog createProgressDialog(
   return dialog;
 }
 
-Future<dynamic> showErrorDialog(
-  BuildContext context,
-  String title,
-  String content,
-) {
-  final AlertDialog alert = AlertDialog(
-    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
-    title: title.isEmpty
-        ? const SizedBox.shrink()
-        : Text(
-            title,
-            style: Theme.of(context).textTheme.headline6,
-          ),
-    content: Text(content),
-    actions: [
-      TextButton(
-        child: Text(
-          "Ok",
-          style: TextStyle(
-            color: Theme.of(context).colorScheme.onSurface,
-          ),
-        ),
-        onPressed: () {
-          Navigator.of(context, rootNavigator: true).pop('dialog');
-        },
-      ),
-    ],
-  );
-
-  return showDialog(
-    context: context,
-    builder: (BuildContext context) {
-      return alert;
-    },
-    barrierColor: Colors.black12,
-  );
-}
-
-Future<T> showConfettiDialog<T>({
-  @required BuildContext context,
-  WidgetBuilder builder,
+Future<ButtonAction?> showConfettiDialog<T>({
+  required BuildContext context,
+  required DialogBuilder dialogBuilder,
   bool barrierDismissible = true,
-  Color barrierColor,
+  Color? barrierColor,
   bool useSafeArea = true,
   bool useRootNavigator = true,
-  RouteSettings routeSettings,
+  RouteSettings? routeSettings,
   Alignment confettiAlignment = Alignment.center,
 }) {
+  final widthOfScreen = MediaQuery.of(context).size.width;
+  final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
   final pageBuilder = Builder(
-    builder: builder,
+    builder: dialogBuilder,
   );
   final ConfettiController confettiController =
       ConfettiController(duration: const Duration(seconds: 1));
@@ -87,22 +176,25 @@ Future<T> showConfettiDialog<T>({
   return showDialog(
     context: context,
     builder: (BuildContext buildContext) {
-      return Stack(
-        children: [
-          pageBuilder,
-          Align(
-            alignment: confettiAlignment,
-            child: ConfettiWidget(
-              confettiController: confettiController,
-              blastDirection: pi / 2,
-              emissionFrequency: 0,
-              numberOfParticles: 100,
-              // a lot of particles at once
-              gravity: 1,
-              blastDirectionality: BlastDirectionality.explosive,
+      return Padding(
+        padding: EdgeInsets.symmetric(horizontal: isMobileSmall ? 8 : 0),
+        child: Stack(
+          children: [
+            Align(alignment: Alignment.center, child: pageBuilder),
+            Align(
+              alignment: confettiAlignment,
+              child: ConfettiWidget(
+                confettiController: confettiController,
+                blastDirection: pi / 2,
+                emissionFrequency: 0,
+                numberOfParticles: 100,
+                // a lot of particles at once
+                gravity: 1,
+                blastDirectionality: BlastDirectionality.explosive,
+              ),
             ),
-          ),
-        ],
+          ],
+        ),
       );
     },
     barrierDismissible: barrierDismissible,

+ 0 - 1
lib/utils/email_util.dart

@@ -16,7 +16,6 @@ import 'package:photos/core/configuration.dart';
 import 'package:photos/core/error-reporting/super_logging.dart';
 import 'package:photos/ente_theme_data.dart';
 import 'package:photos/ui/common/dialogs.dart';
-import 'package:photos/ui/components/dialog_widget.dart';
 import 'package:photos/ui/tools/debug/log_file_viewer.dart';
 import 'package:photos/utils/dialog_util.dart';
 import 'package:photos/utils/toast_util.dart';

+ 0 - 1
lib/utils/share_util.dart

@@ -10,7 +10,6 @@ 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';