From 05a42efb1b30e36c124fc756fbacd01dd2c80590 Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Fri, 2 May 2025 15:35:43 +0530 Subject: [PATCH] fix: update backup failed dialog to make UX better --- mobile/lib/l10n/intl_en.arb | 1 + .../ui/settings/backup/backup_item_card.dart | 47 ++++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/mobile/lib/l10n/intl_en.arb b/mobile/lib/l10n/intl_en.arb index d01df436c2..cab5da3cf6 100644 --- a/mobile/lib/l10n/intl_en.arb +++ b/mobile/lib/l10n/intl_en.arb @@ -721,6 +721,7 @@ "type": "text" }, "backupFailed": "Backup failed", + "sorryBackupFailedDesc": "Sorry, we could not backup this file right now, we will retry later.", "couldNotBackUpTryLater": "We could not backup your data.\nWe will retry later.", "enteCanEncryptAndPreserveFilesOnlyIfYouGrant": "Ente can encrypt and preserve files only if you grant access to them", "pleaseGrantPermissions": "Please grant permissions", diff --git a/mobile/lib/ui/settings/backup/backup_item_card.dart b/mobile/lib/ui/settings/backup/backup_item_card.dart index c8f27b32bc..ff50a5dfe0 100644 --- a/mobile/lib/ui/settings/backup/backup_item_card.dart +++ b/mobile/lib/ui/settings/backup/backup_item_card.dart @@ -1,12 +1,16 @@ import "dart:async"; import 'package:flutter/material.dart'; +import "package:photos/generated/l10n.dart"; import "package:photos/models/backup/backup_item.dart"; import "package:photos/models/backup/backup_item_status.dart"; import 'package:photos/theme/ente_theme.dart'; +import "package:photos/ui/components/buttons/button_widget.dart"; +import "package:photos/ui/components/dialog_widget.dart"; +import "package:photos/ui/components/models/button_type.dart"; import "package:photos/ui/viewer/file/detail_page.dart"; import "package:photos/ui/viewer/file/thumbnail_widget.dart"; -import "package:photos/utils/dialog_util.dart"; +import "package:photos/utils/email_util.dart"; import "package:photos/utils/file_uploader.dart"; import "package:photos/utils/navigation_util.dart"; @@ -137,17 +141,36 @@ class _BackupItemCardState extends State { color: getEnteColorScheme(context).fillBase, ), onPressed: () { - String errorMessage = ""; - if (widget.item.error is Exception) { - final Exception ex = widget.item.error as Exception; - errorMessage = "Error: " + - ex.runtimeType.toString() + - " - " + - ex.toString(); - } else if (widget.item.error != null) { - errorMessage = widget.item.error.toString(); - } - showErrorDialog(context, 'Upload failed', errorMessage); + showDialogWidget( + context: context, + body: S.of(context).sorryBackupFailedDesc, + title: S.of(context).backupFailed, + icon: Icons.error_outline_outlined, + isDismissible: true, + buttons: [ + ButtonWidget( + buttonType: ButtonType.primary, + labelText: S.of(context).contactSupport, + buttonAction: ButtonAction.second, + onTap: () async { + await sendLogs( + context, + S.of(context).contactSupport, + "support@ente.io", + postShare: () {}, + ); + }, + ), + ButtonWidget( + buttonType: ButtonType.secondary, + labelText: S.of(context).ok, + buttonAction: ButtonAction.first, + onTap: () async { + Navigator.of(context).pop(); + }, + ), + ], + ); }, ), ),