Skip to content

Commit

Permalink
feat: Add icons in some confirmation dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
enrique-lozano committed Jan 24, 2024
1 parent eac8cb2 commit 304d4cc
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 34 deletions.
1 change: 1 addition & 0 deletions lib/app/accounts/details/account_details_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ abstract class AccountDetailsActions {
contentParagraphs: [Text(t.account.delete.warning_text)],
confirmationText: t.general.continue_text,
showCancelButton: true,
icon: Icons.delete,
).then((isConfirmed) {
if (isConfirmed != true) return;

Expand Down
1 change: 1 addition & 0 deletions lib/app/budgets/budget_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class _BudgetDetailsPageState extends State<BudgetDetailsPage> {
dialogTitle: t.budgets.delete,
contentParagraphs: [Text(t.budgets.delete_warning)],
confirmationText: t.general.confirm,
icon: Icons.delete,
).then((confirmed) {
if (confirmed != true) return;

Expand Down
6 changes: 3 additions & 3 deletions lib/app/categories/form/category_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class _CategoryFormPageState extends State<CategoryFormPage> {
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),
)),
Expand Down Expand Up @@ -349,8 +349,8 @@ class _CategoryFormPageState extends State<CategoryFormPage> {
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),
)),
Expand Down
2 changes: 2 additions & 0 deletions lib/app/categories/form/category_form_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CategoryFormFunctions {
confirmDialog(
context,
dialogTitle: t.categories.delete_warning_header,
icon: Icons.delete,
contentParagraphs: [
StreamBuilder(
stream: TransactionService.instance
Expand Down Expand Up @@ -71,6 +72,7 @@ class CategoryFormFunctions {
confirmDialog(
context,
dialogTitle: t.categories.merge,
icon: Icons.merge_type_rounded,
contentParagraphs: [
StreamBuilder(
stream: TransactionService.instance
Expand Down
47 changes: 27 additions & 20 deletions lib/core/presentation/widgets/confirm_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,43 @@ Future<bool?> confirmDialog(
required List<Widget> contentParagraphs,
bool showCancelButton = false,
String? confirmationText,
IconData? icon,
bool canPop = true,
}) {
final t = Translations.of(context);

return showDialog<bool>(
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);
},
),
],
],
),
),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -67,6 +67,7 @@ class TransactionViewActionService {

confirmDialog(
context,
icon: Icons.delete,
dialogTitle: !isRecurrent
? t.transaction.delete
: t.recurrent_transactions.details.delete_header,
Expand Down Expand Up @@ -110,6 +111,7 @@ class TransactionViewActionService {

confirmDialog(
context,
icon: Icons.control_point_duplicate_rounded,
dialogTitle: t.transaction.duplicate,
contentParagraphs: [Text(t.transaction.duplicate_warning_message)],
confirmationText: t.general.continue_text,
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions lib/i18n/strings_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 7 additions & 7 deletions lib/i18n/translations.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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';
}
Expand Down Expand Up @@ -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';
}

Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 304d4cc

Please sign in to comment.