diff --git a/lib/app/accounts/details/account_details_actions.dart b/lib/app/accounts/details/account_details_actions.dart index d4811a7e..5c0ab9a9 100644 --- a/lib/app/accounts/details/account_details_actions.dart +++ b/lib/app/accounts/details/account_details_actions.dart @@ -32,7 +32,7 @@ abstract class AccountDetailsActions { ? null : () async { showAccountsWarn() async => - await showConfirmDialog(context, + await confirmDialog(context, dialogTitle: t.transfer.need_two_accounts_warning_header, contentParagraphs: [ @@ -95,7 +95,7 @@ abstract class AccountDetailsActions { } static showReopenAccountDialog(BuildContext context, Account account) { - showConfirmDialog( + confirmDialog( context, showCancelButton: true, dialogTitle: t.account.reopen, @@ -141,12 +141,13 @@ abstract class AccountDetailsActions { }) { final scaffold = ScaffoldMessenger.of(context); - showConfirmDialog( + confirmDialog( context, dialogTitle: t.account.delete.warning_header, contentParagraphs: [Text(t.account.delete.warning_text)], confirmationText: t.general.continue_text, showCancelButton: true, + icon: Icons.delete, ).then((isConfirmed) { if (isConfirmed != true) return; diff --git a/lib/app/budgets/budget_details_page.dart b/lib/app/budgets/budget_details_page.dart index 865cf787..25f5983a 100644 --- a/lib/app/budgets/budget_details_page.dart +++ b/lib/app/budgets/budget_details_page.dart @@ -105,11 +105,12 @@ class _BudgetDetailsPageState extends State { icon: Icons.delete, role: ListTileActionRole.delete, onClick: () { - showConfirmDialog( + confirmDialog( context, dialogTitle: t.budgets.delete, contentParagraphs: [Text(t.budgets.delete_warning)], confirmationText: t.general.confirm, + icon: Icons.delete, ).then((confirmed) { if (confirmed != true) return; diff --git a/lib/app/categories/form/category_form.dart b/lib/app/categories/form/category_form.dart index 2386f61d..dbfd93e4 100644 --- a/lib/app/categories/form/category_form.dart +++ b/lib/app/categories/form/category_form.dart @@ -167,7 +167,7 @@ class _CategoryFormPageState extends State { value: 'merge', child: ListTile( contentPadding: EdgeInsets.zero, - leading: const Icon(Icons.merge_type), + leading: const Icon(Icons.merge_type_rounded), minLeadingWidth: 26, title: Text(t.categories.merge), )), @@ -349,8 +349,8 @@ class _CategoryFormPageState extends State { value: 'merge', child: ListTile( contentPadding: EdgeInsets.zero, - leading: - const Icon(Icons.merge_type), + leading: const Icon( + Icons.merge_type_rounded), minLeadingWidth: 26, title: Text(t.categories.merge), )), diff --git a/lib/app/categories/form/category_form_functions.dart b/lib/app/categories/form/category_form_functions.dart index e64b76c9..53075381 100644 --- a/lib/app/categories/form/category_form_functions.dart +++ b/lib/app/categories/form/category_form_functions.dart @@ -18,9 +18,10 @@ class CategoryFormFunctions { static deleteCategory(BuildContext context, String categoryId) { final t = Translations.of(context); - showConfirmDialog( + confirmDialog( context, dialogTitle: t.categories.delete_warning_header, + icon: Icons.delete, contentParagraphs: [ StreamBuilder( stream: TransactionService.instance @@ -68,9 +69,10 @@ class CategoryFormFunctions { final selCategory = value.first; - showConfirmDialog( + confirmDialog( context, dialogTitle: t.categories.merge, + icon: Icons.merge_type_rounded, contentParagraphs: [ StreamBuilder( stream: TransactionService.instance @@ -149,7 +151,7 @@ class CategoryFormFunctions { final selCategory = value.first; - showConfirmDialog( + confirmDialog( context, dialogTitle: t.categories.make_child, contentParagraphs: [ diff --git a/lib/app/currencies/currency_manager.dart b/lib/app/currencies/currency_manager.dart index 1ca04e1f..8ee30059 100644 --- a/lib/app/currencies/currency_manager.dart +++ b/lib/app/currencies/currency_manager.dart @@ -38,7 +38,7 @@ class _CurrencyManagerPageState extends State { changePreferredCurrency(Currency newCurrency) { final t = Translations.of(context); - showConfirmDialog( + confirmDialog( context, dialogTitle: t.currencies.change_preferred_currency_title, contentParagraphs: [Text(t.currencies.change_preferred_currency_msg)], diff --git a/lib/app/home/widgets/new_transaction_fl_button.dart b/lib/app/home/widgets/new_transaction_fl_button.dart index be2239a2..634109c4 100644 --- a/lib/app/home/widgets/new_transaction_fl_button.dart +++ b/lib/app/home/widgets/new_transaction_fl_button.dart @@ -13,7 +13,7 @@ class NewTransactionButton extends StatelessWidget { _showShouldCreateAccountWarn(BuildContext context) { final t = Translations.of(context); - showConfirmDialog( + confirmDialog( context, dialogTitle: t.home.should_create_account_header, contentParagraphs: [Text(t.home.should_create_account_message)], diff --git a/lib/app/transactions/transaction_details.page.dart b/lib/app/transactions/transaction_details.page.dart index 77cde02e..8b9da043 100644 --- a/lib/app/transactions/transaction_details.page.dart +++ b/lib/app/transactions/transaction_details.page.dart @@ -181,7 +181,7 @@ class _TransactionDetailsPageState extends State { showSkipTransactionModal(BuildContext context, MoneyTransaction transaction) { final nextPaymentDate = transaction.followingDateToNext; - showConfirmDialog( + confirmDialog( context, dialogTitle: t.transaction.next_payments.skip_dialog_title, confirmationText: t.general.confirm, diff --git a/lib/core/presentation/widgets/confirm_dialog.dart b/lib/core/presentation/widgets/confirm_dialog.dart index a91a4820..d670cb1a 100644 --- a/lib/core/presentation/widgets/confirm_dialog.dart +++ b/lib/core/presentation/widgets/confirm_dialog.dart @@ -1,43 +1,53 @@ import 'package:flutter/material.dart'; import 'package:monekin/i18n/translations.g.dart'; -/// Display a dialog with a title, a description and confirm/cancel buttons -Future showConfirmDialog( +/// Display a dialog with a title, a description and confirm/cancel buttons. +/// +/// When the confirm dialogs is closed, it will return `true` or `false` when one of the actions +/// button is pressed, and null if closed without tapping on any icon +Future confirmDialog( BuildContext context, { required String dialogTitle, required List contentParagraphs, bool showCancelButton = false, String? confirmationText, + IconData? icon, + bool canPop = true, }) { final t = Translations.of(context); return showDialog( context: context, - builder: (context) => AlertDialog.adaptive( - title: Text(dialogTitle), - content: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: contentParagraphs - .expand((element) => [element, const SizedBox(height: 6)]) - .toList(), + barrierDismissible: canPop, + builder: (context) => PopScope( + canPop: canPop, + child: AlertDialog.adaptive( + title: Text(dialogTitle), + icon: icon != null ? Icon(icon, size: 36) : null, + content: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: contentParagraphs + .expand((element) => [element, const SizedBox(height: 6)]) + .toList(), + ), ), - ), - actions: [ - if (showCancelButton) + actions: [ + if (showCancelButton) + TextButton( + child: Text(t.general.cancel), + onPressed: () { + Navigator.of(context, rootNavigator: true).pop(false); + }, + ), TextButton( - child: Text(t.general.cancel), + child: Text(confirmationText ?? t.general.understood), onPressed: () { - Navigator.of(context, rootNavigator: true).pop(false); + Navigator.of(context, rootNavigator: true).pop(true); }, ), - TextButton( - child: Text(confirmationText ?? t.general.understood), - onPressed: () { - Navigator.of(context, rootNavigator: true).pop(true); - }, - ), - ], + ], + ), ), ); } diff --git a/lib/core/services/view-actions/transaction_view_actions_service.dart b/lib/core/services/view-actions/transaction_view_actions_service.dart index 4c12283b..64335c47 100644 --- a/lib/core/services/view-actions/transaction_view_actions_service.dart +++ b/lib/core/services/view-actions/transaction_view_actions_service.dart @@ -37,7 +37,7 @@ class TransactionViewActionService { if (transaction.recurrentInfo.isNoRecurrent) ListTileActionItem( label: t.transaction.duplicate_short, - icon: Icons.control_point_duplicate, + icon: Icons.control_point_duplicate_rounded, onClick: () => TransactionViewActionService() .cloneTransactionWithAlertAndSnackBar(context, transaction: transaction), @@ -65,8 +65,9 @@ class TransactionViewActionService { final t = Translations.of(context); final scaffold = ScaffoldMessenger.of(context); - showConfirmDialog( + confirmDialog( context, + icon: Icons.delete, dialogTitle: !isRecurrent ? t.transaction.delete : t.recurrent_transactions.details.delete_header, @@ -108,8 +109,9 @@ class TransactionViewActionService { final t = Translations.of(context); final scaffold = ScaffoldMessenger.of(context); - showConfirmDialog( + confirmDialog( context, + icon: Icons.control_point_duplicate_rounded, dialogTitle: t.transaction.duplicate, contentParagraphs: [Text(t.transaction.duplicate_warning_message)], confirmationText: t.general.continue_text, diff --git a/lib/i18n/strings_en.json b/lib/i18n/strings_en.json index 0cf13abc..25f3bdca 100644 --- a/lib/i18n/strings_en.json +++ b/lib/i18n/strings_en.json @@ -394,7 +394,7 @@ "swift": "SWIFT" }, "DELETE": { - "warning-header": "Are you sure?", + "warning-header": "Delete account?", "warning-text": "This action will delete this account and all its transactions", "success": "Account deleted successfully" }, diff --git a/lib/i18n/strings_es.json b/lib/i18n/strings_es.json index 1c40f286..52b1bda0 100644 --- a/lib/i18n/strings_es.json +++ b/lib/i18n/strings_es.json @@ -398,8 +398,8 @@ "swift": "SWIFT" }, "DELETE": { - "warning-header": "¿Estas seguro?", - "warning-text": "Esta acción borrara esta cuenta y todas sus transacciones", + "warning-header": "¿Eliminar cuenta?", + "warning-text": "Esta acción borrara esta cuenta y todas sus transacciones. No podrás volver a recuperar esta información tras el borrado.", "success": "Cuenta eliminada correctamente" }, "CLOSE": { diff --git a/lib/i18n/translations.g.dart b/lib/i18n/translations.g.dart index b558cd2a..a5f46db9 100644 --- a/lib/i18n/translations.g.dart +++ b/lib/i18n/translations.g.dart @@ -6,7 +6,7 @@ /// Locales: 2 /// Strings: 1018 (509 per locale) /// -/// Built on 2024-01-17 at 07:50 UTC +/// Built on 2024-01-24 at 16:04 UTC // coverage:ignore-file // ignore_for_file: type=lint @@ -906,7 +906,7 @@ class _TranslationsAccountDeleteEn { final _TranslationsEn _root; // ignore: unused_field // Translations - String get warning_header => 'Are you sure?'; + String get warning_header => 'Delete account?'; String get warning_text => 'This action will delete this account and all its transactions'; String get success => 'Account deleted successfully'; } @@ -2125,8 +2125,8 @@ class _TranslationsAccountDeleteEs implements _TranslationsAccountDeleteEn { @override final _TranslationsEs _root; // ignore: unused_field // Translations - @override String get warning_header => '¿Estas seguro?'; - @override String get warning_text => 'Esta acción borrara esta cuenta y todas sus transacciones'; + @override String get warning_header => '¿Eliminar cuenta?'; + @override String get warning_text => 'Esta acción borrara esta cuenta y todas sus transacciones. No podrás volver a recuperar esta información tras el borrado.'; @override String get success => 'Cuenta eliminada correctamente'; } @@ -2940,7 +2940,7 @@ extension on _TranslationsEn { case 'account.form.tr_before_opening_date': return 'There are transactions in this account with a date before the opening date'; case 'account.form.iban': return 'IBAN'; case 'account.form.swift': return 'SWIFT'; - case 'account.delete.warning_header': return 'Are you sure?'; + case 'account.delete.warning_header': return 'Delete account?'; case 'account.delete.warning_text': return 'This action will delete this account and all its transactions'; case 'account.delete.success': return 'Account deleted successfully'; case 'account.close.title': return 'Close account'; @@ -3527,8 +3527,8 @@ extension on _TranslationsEs { case 'account.form.already_exists': return 'Ya existe otra cuenta con el mismo nombre. Por favor, escriba otro'; case 'account.form.iban': return 'IBAN'; case 'account.form.swift': return 'SWIFT'; - case 'account.delete.warning_header': return '¿Estas seguro?'; - case 'account.delete.warning_text': return 'Esta acción borrara esta cuenta y todas sus transacciones'; + case 'account.delete.warning_header': return '¿Eliminar cuenta?'; + case 'account.delete.warning_text': return 'Esta acción borrara esta cuenta y todas sus transacciones. No podrás volver a recuperar esta información tras el borrado.'; case 'account.delete.success': return 'Cuenta eliminada correctamente'; case 'account.close.title': return 'Cerrar cuenta'; case 'account.close.title_short': return 'Cerrar';