Skip to content

Commit

Permalink
CW-516-Improve-balance-layout-in-home-screen (#1171)
Browse files Browse the repository at this point in the history
* unavailable balance

* localization

* unavailable balance description

* add unavailable balance popup
  • Loading branch information
Serhii-Borodenko authored Nov 16, 2023
1 parent 28ad0db commit bb5336f
Show file tree
Hide file tree
Showing 30 changed files with 124 additions and 76 deletions.
2 changes: 1 addition & 1 deletion cw_core/lib/balance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ abstract class Balance {

String get formattedAdditionalBalance;

String get formattedFrozenBalance => '';
String get formattedUnAvailableBalance => '';
}
14 changes: 8 additions & 6 deletions cw_core/lib/monero_balance.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import 'package:cw_core/monero_amount_format.dart';
class MoneroBalance extends Balance {
MoneroBalance({required this.fullBalance, required this.unlockedBalance, this.frozenBalance = 0})
: formattedFullBalance = moneroAmountToString(amount: fullBalance),
formattedUnlockedBalance = moneroAmountToString(amount: unlockedBalance),
frozenFormatted = moneroAmountToString(amount: frozenBalance),
formattedUnlockedBalance = moneroAmountToString(amount: unlockedBalance - frozenBalance),
formattedLockedBalance =
moneroAmountToString(amount: frozenBalance + fullBalance - unlockedBalance),
super(unlockedBalance, fullBalance);

MoneroBalance.fromString(
{required this.formattedFullBalance,
required this.formattedUnlockedBalance,
this.frozenFormatted = '0.0'})
this.formattedLockedBalance = '0.0'})
: fullBalance = moneroParseAmount(amount: formattedFullBalance),
unlockedBalance = moneroParseAmount(amount: formattedUnlockedBalance),
frozenBalance = moneroParseAmount(amount: frozenFormatted),
frozenBalance = moneroParseAmount(amount: formattedLockedBalance),
super(moneroParseAmount(amount: formattedUnlockedBalance),
moneroParseAmount(amount: formattedFullBalance));

Expand All @@ -23,10 +24,11 @@ class MoneroBalance extends Balance {
final int frozenBalance;
final String formattedFullBalance;
final String formattedUnlockedBalance;
final String frozenFormatted;
final String formattedLockedBalance;

@override
String get formattedFrozenBalance => frozenFormatted == '0.0' ? '' : frozenFormatted;
String get formattedUnAvailableBalance =>
formattedLockedBalance == '0.0' ? '' : formattedLockedBalance;

@override
String get formattedAvailableBalance => formattedUnlockedBalance;
Expand Down
102 changes: 61 additions & 41 deletions lib/src/screens/dashboard/widgets/balance_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ class BalancePage extends StatelessWidget {
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: hasAdditionalBalance ? () => _showBalanceDescription(context) : null,
onTap: hasAdditionalBalance ? () =>
_showBalanceDescription(context, S.current.available_balance_description)
: null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down Expand Up @@ -225,47 +227,65 @@ class BalancePage extends StatelessWidget {
],
),
if (frozenBalance.isNotEmpty)
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 26),
Text(
S.current.frozen_balance,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w400,
color: Theme.of(context).extension<BalancePageTheme>()!.labelTextColor,
height: 1,
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: hasAdditionalBalance ?
() => _showBalanceDescription(context, S.current.unavailable_balance_description)
: null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 26),
Row(
children: [
Text(
S.current.unavailable_balance,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w400,
color: Theme.of(context).extension<BalancePageTheme>()!.labelTextColor,
height: 1,
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Icon(Icons.help_outline,
size: 16,
color: Theme.of(context)
.extension<BalancePageTheme>()!
.labelTextColor),
),
],
),
),
SizedBox(height: 8),
AutoSizeText(
frozenBalance,
style: TextStyle(
fontSize: 20,
fontFamily: 'Lato',
fontWeight: FontWeight.w400,
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
height: 1,
SizedBox(height: 8),
AutoSizeText(
frozenBalance,
style: TextStyle(
fontSize: 20,
fontFamily: 'Lato',
fontWeight: FontWeight.w400,
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
height: 1,
),
maxLines: 1,
textAlign: TextAlign.center,
),
maxLines: 1,
textAlign: TextAlign.center,
),
SizedBox(height: 4),
Text(
frozenFiatBalance,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w400,
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
height: 1,
SizedBox(height: 4),
Text(
frozenFiatBalance,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w400,
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor,
height: 1,
),
),
),
],
],
),
),
if (hasAdditionalBalance)
Column(
Expand Down Expand Up @@ -316,9 +336,9 @@ class BalancePage extends StatelessWidget {
);
}

void _showBalanceDescription(BuildContext context) {
void _showBalanceDescription(BuildContext context, String content) {
showPopUp<void>(
context: context,
builder: (_) => InformationPage(information: S.current.available_balance_description));
builder: (_) => InformationPage(information: content));
}
}
2 changes: 1 addition & 1 deletion lib/view_model/dashboard/balance_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,6 @@ abstract class BalanceViewModelBase with Store {
}
}

String getFormattedFrozenBalance(Balance walletBalance) => walletBalance.formattedFrozenBalance;
String getFormattedFrozenBalance(Balance walletBalance) => walletBalance.formattedUnAvailableBalance;
}

5 changes: 3 additions & 2 deletions res/values/strings_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@
"sweeping_wallet_alert": "لن يستغرق هذا وقتًا طويلاً. لا تترك هذه الشاشة وإلا فقد يتم فقد أموال سويبت",
"decimal_places_error": "عدد كبير جدًا من المنازل العشرية",
"edit_node": "تحرير العقدة",
"frozen_balance": "الرصيد المجمد",
"invoice_details": "تفاصيل الفاتورة",
"donation_link_details": "تفاصيل رابط التبرع",
"anonpay_description": "توليد ${type}. يمكن للمستلم ${method} بأي عملة مشفرة مدعومة ، وستتلقى أموالاً في هذه",
Expand Down Expand Up @@ -727,5 +726,7 @@
"require_for_exchanges_to_external_wallets": "ﺔﻴﺟﺭﺎﺧ ﻆﻓﺎﺤﻣ ﻰﻟﺇ ﺕﻻﺩﺎﺒﺘﻟﺍ ﺐﻠﻄﺘﺗ",
"camera_permission_is_required": ".ﺍﺮﻴﻣﺎﻜﻟﺍ ﻥﺫﺇ ﺏﻮﻠﻄﻣ",
"switchToETHWallet": "ﻯﺮﺧﺃ ﺓﺮﻣ ﺔﻟﻭﺎﺤﻤﻟﺍﻭ Ethereum ﺔﻈﻔﺤﻣ ﻰﻟﺇ ﻞﻳﺪﺒﺘﻟﺍ ﻰﺟﺮﻳ",
"unavailable_balance": " ﺮﻓﻮﺘﻣ ﺮﻴﻏ ﺪﻴﺻﺭ",
"unavailable_balance_description": ".ﺎﻫﺪﻴﻤﺠﺗ ءﺎﻐﻟﺇ ﺭﺮﻘﺗ ﻰﺘﺣ ﺕﻼﻣﺎﻌﻤﻠﻟ ﻝﻮﺻﻮﻠﻟ ﺔﻠﺑﺎﻗ ﺮﻴﻏ ﺓﺪﻤﺠﻤﻟﺍ ﺓﺪﺻﺭﻷﺍ ﻞﻈﺗ ﺎﻤﻨﻴﺑ ،ﺎﻬﺑ ﺔﺻﺎﺨﻟﺍ ﺕﻼﻣﺎﻌﻤﻟﺍ ﻝﺎﻤﺘﻛﺍ ﺩﺮﺠﻤﺑ ﺔﺣﺎﺘﻣ ﺔﻠﻔﻘﻤﻟﺍ ﺓﺪﺻﺭﻷﺍ ﺢﺒﺼﺘﺳ .ﻚﺑ ﺔﺻﺎﺨﻟﺍ ﺕﻼﻤﻌﻟﺍ ﻲﻓ ﻢﻜﺤﺘﻟﺍ ﺕﺍﺩﺍﺪﻋﺇ ﻲﻓ ﻂﺸﻧ ﻞﻜﺸﺑ ﺎﻫﺪﻴﻤﺠﺘﺑ ﺖﻤﻗ",
"unspent_change": "يتغير"
}
}
3 changes: 2 additions & 1 deletion res/values/strings_bg.arb
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@
"error_dialog_content": "Получихме грешка.\n\nМоля, изпратете доклада до нашия отдел поддръжка, за да подобрим приложението.",
"decimal_places_error": "Твърде много знаци след десетичната запетая",
"edit_node": "Редактиране на възел",
"frozen_balance": "Замразен баланс",
"invoice_details": "IДанни за фактура",
"donation_link_details": "Подробности за връзката за дарение",
"anonpay_description": "Генерирайте ${type}. Получателят може да ${method} с всяка поддържана криптовалута и вие ще получите средства в този портфейл.",
Expand Down Expand Up @@ -723,5 +722,7 @@
"require_for_exchanges_to_external_wallets": "Изискване за обмен към външни портфейли",
"camera_permission_is_required": "Изисква се разрешение за камерата.\nМоля, активирайте го от настройките на приложението.",
"switchToETHWallet": "Моля, преминете към портфейл Ethereum и опитайте отново",
"unavailable_balance": "Неналично салдо",
"unavailable_balance_description": "Неналично салдо: Тази обща сума включва средства, които са заключени в чакащи транзакции и тези, които сте замразили активно в настройките за контрол на монетите. Заключените баланси ще станат достъпни, след като съответните им транзакции бъдат завършени, докато замразените баланси остават недостъпни за транзакции, докато не решите да ги размразите.",
"unspent_change": "Промяна"
}
3 changes: 2 additions & 1 deletion res/values/strings_cs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@
"error_dialog_content": "Nastala chyba.\n\nProsím odešlete zprávu o chybě naší podpoře, aby mohli zajistit opravu.",
"decimal_places_error": "Příliš mnoho desetinných míst",
"edit_node": "Upravit uzel",
"frozen_balance": "Zmrazená bilance",
"invoice_details": "detaily faktury",
"donation_link_details": "Podrobnosti odkazu na darování",
"anonpay_description": "Vygenerujte ${type}. Příjemce může ${method} s jakoukoli podporovanou kryptoměnou a vy obdržíte prostředky v této peněžence.",
Expand Down Expand Up @@ -723,5 +722,7 @@
"require_for_exchanges_to_external_wallets": "Vyžadovat pro výměny do externích peněženek",
"camera_permission_is_required": "Vyžaduje se povolení fotoaparátu.\nPovolte jej v nastavení aplikace.",
"switchToETHWallet": "Přejděte na peněženku Ethereum a zkuste to znovu",
"unavailable_balance": "Nedostupný zůstatek",
"unavailable_balance_description": "Nedostupný zůstatek: Tento součet zahrnuje prostředky, které jsou uzamčeny v nevyřízených transakcích a ty, které jste aktivně zmrazili v nastavení kontroly mincí. Uzamčené zůstatky budou k dispozici po dokončení příslušných transakcí, zatímco zmrazené zůstatky zůstanou pro transakce nepřístupné, dokud se nerozhodnete je uvolnit.",
"unspent_change": "Změna"
}
3 changes: 2 additions & 1 deletion res/values/strings_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@
"sweeping_wallet_alert": "Das sollte nicht lange dauern. VERLASSEN SIE DIESEN BILDSCHIRM NICHT, ANDERNFALLS KÖNNEN DIE GELDER VERLOREN GEHEN",
"decimal_places_error": "Zu viele Nachkommastellen",
"edit_node": "Knoten bearbeiten",
"frozen_balance": "Gefrorenes Guthaben",
"invoice_details": "Rechnungs-Details",
"donation_link_details": "Details zum Spendenlink",
"anonpay_description": "Generieren Sie ${type}. Der Empfänger kann ${method} mit jeder unterstützten Kryptowährung verwenden, und Sie erhalten Geld in dieser Wallet.",
Expand Down Expand Up @@ -731,5 +730,7 @@
"require_for_exchanges_to_external_wallets": "Erforderlich für den Umtausch in externe Wallets",
"camera_permission_is_required": "Eine Kameraerlaubnis ist erforderlich.\nBitte aktivieren Sie es in den App-Einstellungen.",
"switchToETHWallet": "Bitte wechseln Sie zu einem Ethereum-Wallet und versuchen Sie es erneut",
"unavailable_balance": "Nicht verfügbares Guthaben",
"unavailable_balance_description": "Nicht verfügbares Guthaben: Diese Summe umfasst Gelder, die in ausstehenden Transaktionen gesperrt sind, und solche, die Sie in Ihren Münzkontrolleinstellungen aktiv eingefroren haben. Gesperrte Guthaben werden verfügbar, sobald die entsprechenden Transaktionen abgeschlossen sind, während eingefrorene Guthaben für Transaktionen nicht zugänglich bleiben, bis Sie sich dazu entschließen, sie wieder freizugeben.",
"unspent_change": "Wechselgeld"
}
3 changes: 2 additions & 1 deletion res/values/strings_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,6 @@
"onion_link": "Onion link",
"decimal_places_error": "Too many decimal places",
"edit_node": "Edit Node",
"frozen_balance": "Frozen Balance",
"settings": "Settings",
"sell_monero_com_alert_content": "Selling Monero is not supported yet",
"error_text_input_below_minimum_limit": "Amount is less than the minimum",
Expand Down Expand Up @@ -732,5 +731,7 @@
"require_for_exchanges_to_external_wallets": "Require for exchanges to external wallets",
"camera_permission_is_required": "Camera permission is required. \nPlease enable it from app settings.",
"switchToETHWallet": "Please switch to an Ethereum wallet and try again",
"unavailable_balance": "Unavailable balance",
"unavailable_balance_description": "Unavailable Balance: This total includes funds that are locked in pending transactions and those you have actively frozen in your coin control settings. Locked balances will become available once their respective transactions are completed, while frozen balances remain inaccessible for transactions until you decide to unfreeze them.",
"unspent_change": "Change"
}
3 changes: 2 additions & 1 deletion res/values/strings_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@
"sweeping_wallet_alert": "Esto no debería llevar mucho tiempo. NO DEJES ESTA PANTALLA O SE PUEDEN PERDER LOS FONDOS BARRIDOS",
"decimal_places_error": "Demasiados lugares decimales",
"edit_node": "Editar nodo",
"frozen_balance": "Balance congelado",
"invoice_details": "Detalles de la factura",
"donation_link_details": "Detalles del enlace de donación",
"anonpay_description": "Genera ${type}. El destinatario puede ${method} con cualquier criptomoneda admitida, y recibirá fondos en esta billetera.",
Expand Down Expand Up @@ -731,5 +730,7 @@
"require_for_exchanges_to_external_wallets": "Requerido para intercambios a billeteras externas",
"camera_permission_is_required": "Se requiere permiso de la cámara.\nHabilítelo desde la configuración de la aplicación.",
"switchToETHWallet": "Cambie a una billetera Ethereum e inténtelo nuevamente.",
"unavailable_balance": "Saldo no disponible",
"unavailable_balance_description": "Saldo no disponible: este total incluye fondos que están bloqueados en transacciones pendientes y aquellos que usted ha congelado activamente en su configuración de control de monedas. Los saldos bloqueados estarán disponibles una vez que se completen sus respectivas transacciones, mientras que los saldos congelados permanecerán inaccesibles para las transacciones hasta que usted decida descongelarlos.",
"unspent_change": "Cambiar"
}
3 changes: 2 additions & 1 deletion res/values/strings_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@
"sweeping_wallet_alert": "Cette opération ne devrait pas prendre longtemps. NE QUITTEZ PAS CET ÉCRAN OU LES FONDS CONSOLIDÉS POURRAIENT ÊTRE PERDUS",
"decimal_places_error": "Trop de décimales",
"edit_node": "Modifier le nœud",
"frozen_balance": "Solde gelé",
"invoice_details": "Détails de la facture",
"donation_link_details": "Détails du lien de don",
"anonpay_description": "Générez ${type}. Le destinataire peut ${method} avec n'importe quelle crypto-monnaie prise en charge, et vous recevrez des fonds dans ce portefeuille (wallet).",
Expand Down Expand Up @@ -729,6 +728,8 @@
"exchange_provider_unsupported": "${providerName} n'est plus pris en charge !",
"domain_looks_up": "Résolution de nom",
"require_for_exchanges_to_external_wallets": "Exiger pour les échanges vers des portefeuilles externes",
"unavailable_balance": "Solde indisponible",
"unavailable_balance_description": "Solde indisponible : ce total comprend les fonds bloqués dans les transactions en attente et ceux que vous avez activement gelés dans vos paramètres de contrôle des pièces. Les soldes bloqués deviendront disponibles une fois leurs transactions respectives terminées, tandis que les soldes gelés resteront inaccessibles aux transactions jusqu'à ce que vous décidiez de les débloquer.",
"camera_permission_is_required": "L'autorisation d'accès à la caméra est requise.\nVeuillez l'activer depuis les paramètres de l'application.",
"switchToETHWallet": "Veuillez passer à un portefeuille (wallet) Ethereum et réessayer",
"unspent_change": "Changement"
Expand Down
3 changes: 2 additions & 1 deletion res/values/strings_ha.arb
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@
"onion_link": "Lambar onion",
"decimal_places_error": "Wadannan suna da tsawon harsuna",
"edit_node": "Shirya Node",
"frozen_balance": "Falin kuma maɓallin",
"settings": "Saiti",
"sell_monero_com_alert_content": "Selling Monero bai sami ƙarshen mai bukatar samun ba",
"error_text_input_below_minimum_limit": "Kudin ba a kamai",
Expand Down Expand Up @@ -709,5 +708,7 @@
"require_for_exchanges_to_external_wallets": "Bukatar musanya zuwa wallet na waje",
"camera_permission_is_required": "Ana buƙatar izinin kyamara.\nDa fatan za a kunna shi daga saitunan app.",
"switchToETHWallet": "Da fatan za a canza zuwa walat ɗin Ethereum kuma a sake gwadawa",
"unavailable_balance": "Ma'aunin da ba ya samuwa",
"unavailable_balance_description": "Ma'auni Babu: Wannan jimlar ya haɗa da kuɗi waɗanda ke kulle a cikin ma'amaloli da ke jiran aiki da waɗanda kuka daskare sosai a cikin saitunan sarrafa kuɗin ku. Ma'auni da aka kulle za su kasance da zarar an kammala ma'amalolinsu, yayin da daskararrun ma'auni ba za su iya samun damar yin ciniki ba har sai kun yanke shawarar cire su.",
"unspent_change": "Canza"
}
Loading

0 comments on commit bb5336f

Please sign in to comment.