From c34c3b0737d268a4116d701b110181115db3fedd Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Fri, 21 Oct 2022 22:06:59 +0200 Subject: [PATCH] Cw 199 add wallet deletion confirmation (#555) * Fix Slidable for deleting wallet Add confirmation dialog for deleting wallet * Swap confirmation dialog buttons to be consistent with other alerts --- .../screens/wallet_list/wallet_list_page.dart | 74 +++++++++++++------ res/values/strings_de.arb | 4 +- res/values/strings_en.arb | 4 +- res/values/strings_es.arb | 4 +- res/values/strings_fr.arb | 4 +- res/values/strings_hi.arb | 4 +- res/values/strings_hr.arb | 4 +- res/values/strings_it.arb | 4 +- res/values/strings_ja.arb | 4 +- res/values/strings_ko.arb | 4 +- res/values/strings_nl.arb | 4 +- res/values/strings_pl.arb | 4 +- res/values/strings_pt.arb | 4 +- res/values/strings_ru.arb | 4 +- res/values/strings_uk.arb | 4 +- res/values/strings_zh.arb | 4 +- 16 files changed, 95 insertions(+), 39 deletions(-) diff --git a/lib/src/screens/wallet_list/wallet_list_page.dart b/lib/src/screens/wallet_list/wallet_list_page.dart index d08126407..8c0f99e67 100644 --- a/lib/src/screens/wallet_list/wallet_list_page.dart +++ b/lib/src/screens/wallet_list/wallet_list_page.dart @@ -156,22 +156,14 @@ class WalletListBodyState extends State { ), )); - // FIX-ME: Slidable for current - return row; - // return wallet.isCurrent - // ? row - // : Slidable( - // key: Key('${wallet.key}'), - // actionPane: SlidableDrawerActionPane(), - // child: row, - // secondaryActions: [ - // IconSlideAction( - // caption: S.of(context).delete, - // color: Colors.red, - // icon: CupertinoIcons.delete, - // onTap: () async => _removeWallet(wallet), - // ) - // ]); + return wallet.isCurrent + ? row + : Slidable( + key: Key('${wallet.key}'), + startActionPane: _actionPane(wallet), + endActionPane: _actionPane(wallet), + child: row, + ); }), ), ), @@ -256,14 +248,34 @@ class WalletListBodyState extends State { return; } - try { - auth.changeProcessText( - S.of(context).wallet_list_removing_wallet(wallet.name)); - await widget.walletListViewModel.remove(wallet); - } catch (e) { - auth.changeProcessText(S - .of(context) - .wallet_list_failed_to_remove(wallet.name, e.toString())); + bool confirmed = false; + + await showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithTwoActions( + alertTitle: S.of(context).delete_wallet, + alertContent: S.of(context).delete_wallet_confirm_message(wallet.name), + leftButtonText: S.of(context).cancel, + rightButtonText: S.of(context).delete, + actionLeftButton: () => Navigator.of(context).pop(), + actionRightButton: () { + confirmed = true; + Navigator.of(context).pop(); + }, + ); + }); + + if (confirmed) { + try { + auth.changeProcessText( + S.of(context).wallet_list_removing_wallet(wallet.name)); + await widget.walletListViewModel.remove(wallet); + } catch (e) { + auth.changeProcessText(S + .of(context) + .wallet_list_failed_to_remove(wallet.name, e.toString())); + } } auth.close(); @@ -279,4 +291,18 @@ class WalletListBodyState extends State { // _progressBar?.dismiss(); // _progressBar = null; } + + ActionPane _actionPane(WalletListItem wallet) => ActionPane( + motion: const ScrollMotion(), + extentRatio: 0.3, + children: [ + SlidableAction( + onPressed: (_) => _removeWallet(wallet), + backgroundColor: Colors.red, + foregroundColor: Colors.white, + icon: CupertinoIcons.delete, + label: S.of(context).delete, + ), + ], + ); } diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb index 3457f8ab2..33b6be87e 100644 --- a/res/values/strings_de.arb +++ b/res/values/strings_de.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Wähle aus verfügbaren Optionen:", "custom_redeem_amount": "Benutzerdefinierter Einlösungsbetrag", "add_custom_redemption": "Benutzerdefinierte Einlösung hinzufügen", - "remaining": "Rest" + "remaining": "Rest", + "delete_wallet": "Geldbörse löschen", + "delete_wallet_confirm_message" : "Sind Sie sicher, dass Sie das ${wallet_name} Wallet löschen möchten?" } diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index ef8e6e495..bf9c6e3ab 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Choose from the available options:", "custom_redeem_amount": "Custom Redeem Amount", "add_custom_redemption": "Add Custom Redemption", - "remaining": "remaining" + "remaining": "remaining", + "delete_wallet": "Delete wallet", + "delete_wallet_confirm_message" : "Are you sure that you want to delete ${wallet_name} wallet?" } diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index 7c996134e..1a355b0df 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Elija entre las opciones disponibles:", "custom_redeem_amount": "Cantidad de canje personalizada", "add_custom_redemption": "Agregar redención personalizada", - "remaining": "restante" + "remaining": "restante", + "delete_wallet": "Eliminar billetera", + "delete_wallet_confirm_message" : "¿Está seguro de que desea eliminar la billetera ${wallet_name}?" } diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index b347086ae..4088c5d5b 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -641,5 +641,7 @@ "choose_from_available_options": "Choisissez parmi les options disponibles :", "custom_redeem_amount": "Montant d'échange personnalisé", "add_custom_redemption": "Ajouter un remboursement personnalisé", - "remaining": "restant" + "remaining": "restant", + "delete_wallet": "Supprimer le portefeuille", + "delete_wallet_confirm_message" : "Êtes-vous sûr de vouloir supprimer le portefeuille ${wallet_name}?" } diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb index 83c0808c4..779648f96 100644 --- a/res/values/strings_hi.arb +++ b/res/values/strings_hi.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "उपलब्ध विकल्पों में से चुनें:", "custom_redeem_amount": "कस्टम रिडीम राशि", "add_custom_redemption": "कस्टम रिडेम्पशन जोड़ें", - "remaining": "शेष" + "remaining": "शेष", + "delete_wallet": "वॉलेट हटाएं", + "delete_wallet_confirm_message" : "क्या आप वाकई ${wallet_name} वॉलेट हटाना चाहते हैं?" } diff --git a/res/values/strings_hr.arb b/res/values/strings_hr.arb index 97d4d335c..98ed901fd 100644 --- a/res/values/strings_hr.arb +++ b/res/values/strings_hr.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Odaberite neku od dostupnih opcija:", "custom_redeem_amount": "Prilagođeni iznos otkupa", "add_custom_redemption": "Dodaj prilagođeni otkup", - "remaining": "preostalo" + "remaining": "preostalo", + "delete_wallet": "Izbriši novčanik", + "delete_wallet_confirm_message" : "Jeste li sigurni da želite izbrisati ${wallet_name} novčanik?" } diff --git a/res/values/strings_it.arb b/res/values/strings_it.arb index cd779471f..6247d83f7 100644 --- a/res/values/strings_it.arb +++ b/res/values/strings_it.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Scegli tra le opzioni disponibili:", "custom_redeem_amount": "Importo di riscatto personalizzato", "add_custom_redemption": "Aggiungi riscatto personalizzato", - "remaining": "rimanente" + "remaining": "rimanente", + "delete_wallet": "Elimina portafoglio", + "delete_wallet_confirm_message" : "Sei sicuro di voler eliminare il portafoglio ${wallet_name}?" } diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb index 2b3920862..6b738c787 100644 --- a/res/values/strings_ja.arb +++ b/res/values/strings_ja.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "利用可能なオプションから選択してください:", "custom_redeem_amount": "カスタム交換金額", "add_custom_redemption": "カスタム引き換えを追加", - "remaining": "残り" + "remaining": "残り", + "delete_wallet": "ウォレットを削除", + "delete_wallet_confirm_message" : "${wallet_name} ウォレットを削除してもよろしいですか?" } diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb index 85ece0603..885f569db 100644 --- a/res/values/strings_ko.arb +++ b/res/values/strings_ko.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "사용 가능한 옵션에서 선택:", "custom_redeem_amount": "사용자 지정 상환 금액", "add_custom_redemption": "사용자 지정 상환 추가", - "remaining": "남은" + "remaining": "남은", + "delete_wallet": "지갑 삭제", + "delete_wallet_confirm_message" : "${wallet_name} 지갑을 삭제하시겠습니까?" } diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb index 15da6fd7b..7de7cab33 100644 --- a/res/values/strings_nl.arb +++ b/res/values/strings_nl.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Kies uit de beschikbare opties:", "custom_redeem_amount": "Aangepast inwisselbedrag", "add_custom_redemption": "Voeg aangepaste inwisseling toe", - "remaining": "resterende" + "remaining": "resterende", + "delete_wallet": "Portemonnee verwijderen", + "delete_wallet_confirm_message" : "Weet u zeker dat u de portemonnee van ${wallet_name} wilt verwijderen?" } diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb index 26d8a38d4..87f2bbacb 100644 --- a/res/values/strings_pl.arb +++ b/res/values/strings_pl.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Wybierz z dostępnych opcji:", "custom_redeem_amount": "Niestandardowa kwota wykorzystania", "add_custom_redemption": "Dodaj niestandardowe wykorzystanie", - "remaining": "pozostałe" + "remaining": "pozostałe", + "delete_wallet": "Usuń portfel", + "delete_wallet_confirm_message" : "Czy na pewno chcesz usunąć portfel ${wallet_name}?" } diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb index bfb4a2d0a..7f1bed93c 100644 --- a/res/values/strings_pt.arb +++ b/res/values/strings_pt.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Escolha entre as opções disponíveis:", "custom_redeem_amount": "Valor de resgate personalizado", "add_custom_redemption": "Adicionar resgate personalizado", - "remaining": "restante" + "remaining": "restante", + "delete_wallet": "Excluir carteira", + "delete_wallet_confirm_message" : "Tem certeza de que deseja excluir a carteira ${wallet_name}?" } diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb index 94a5b3c0b..8cbf48793 100644 --- a/res/values/strings_ru.arb +++ b/res/values/strings_ru.arb @@ -643,5 +643,7 @@ "choose_from_available_options": "Выберите из доступных вариантов:", "custom_redeem_amount": "Пользовательская сумма погашения", "add_custom_redemption": "Добавить пользовательское погашение", - "remaining": "осталось" + "remaining": "осталось", + "delete_wallet": "Удалить кошелек", + "delete_wallet_confirm_message" : "Вы уверены, что хотите удалить кошелек ${wallet_name}?" } diff --git a/res/values/strings_uk.arb b/res/values/strings_uk.arb index b139750be..2f8de2884 100644 --- a/res/values/strings_uk.arb +++ b/res/values/strings_uk.arb @@ -642,5 +642,7 @@ "choose_from_available_options": "Виберіть із доступних варіантів:", "custom_redeem_amount": "Власна сума викупу", "add_custom_redemption": "Додати спеціальне погашення", - "remaining": "залишилося" + "remaining": "залишилося", + "delete_wallet": "Видалити гаманець", + "delete_wallet_confirm_message" : "Ви впевнені, що хочете видалити гаманець ${wallet_name}?" } diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb index 487c6be52..025470941 100644 --- a/res/values/strings_zh.arb +++ b/res/values/strings_zh.arb @@ -641,5 +641,7 @@ "choose_from_available_options": "从可用选项中选择:", "custom_redeem_amount": "自定义兑换金额", "add_custom_redemption": "添加自定义兑换", - "remaining": "剩余" + "remaining": "剩余", + "delete_wallet": "删除钱包", + "delete_wallet_confirm_message" : "您确定要删除 ${wallet_name} 钱包吗?" }