From b3c8be4ba847d8ef1fb05799516421e414dd234a Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Mon, 8 Jan 2024 16:05:35 +0200 Subject: [PATCH] Improve balance card UI (#1259) * Improve balance card UI * Disable normal USDC polygon for ChangeNow * UI enhancements * Add Kaspa Minor UI fix * Add kaspa icon [skip ci] --- assets/images/kaspa_icon.png | Bin 0 -> 6921 bytes cw_core/lib/crypto_currency.dart | 2 + .../provider/changenow_exchange_provider.dart | 3 + .../screens/dashboard/pages/balance_page.dart | 66 ++++++++++++++---- .../exchange_trade/exchange_trade_page.dart | 2 +- lib/src/screens/send/send_page.dart | 2 +- 6 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 assets/images/kaspa_icon.png diff --git a/assets/images/kaspa_icon.png b/assets/images/kaspa_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..5201174ef9491aa31531ef37acde91280188e8af GIT binary patch literal 6921 zcmZ{p2T)U8+pd$)LMT!~hY*U9-b*Ob5fBI>T{@vkAfXD<5)hCsNEM`r6cLaP0%GV* zKv9Ym2?A0?383^>5AQkieKTkN`Df4G&ziOF>webSZS6fP=@!a>0m2Od000a|hI+Rz zBmUnVOnrIm*Ki%b3~;pJZBqc?KH{?e0RV9JZ~GPi5F!Hr?6?2`s`&r_2d=2oT>Y|v z+RfNN5AgTjt@KUR>|hhV6|psgkj^1|)m0^Q*HCEuN*e4?)hp&WLugcbbT-xV8?VZr zI>m8cyP%`Uh`qhtH*c{q=ZiXeuUF^H0!jrEd~>>ms=<)38-`(bs&rByz~6 zDVr@=0rE*)m@q#uY!d1IwH$v1O5l~D<^?6-qY2Ae{0$b_j#`}_3VB=@lNu&nJ4#JX!w+O8``+=C@d2Pal>d z54gz`9A@bb6XFyoW(#B45G6R<3rORuL9yTMl%(zX+iK-m?xRD0W4$Dph3tMc-jJ#J z0kHwtP<$s)xsD@^r?sRT^hpr`Q%4()XnpNC^HhU{a%Hgxl>oPs4Nf_U)$u5$!5jQu1_WX00;Ev2tMu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js5c7uD@G0%@5Ug~Rg$baeaW-@MiX&%N({e9g-M)uDzxJ>fF*z@zLLh^b;2I) zlAnZT1NGGJ9|QKzi|Hl8+1`~a%jfi;Z6AS}qMXzJ%&ucuigfOK*~(cJsFQ_Af4Mzg zvJIu8mVCFuF;3QJ8qpQt)<$I$VToHn!XWEsBY)8B15q2QQGjMPk>{*K=LRAUJkwNB z*C~GSndxk?EufUf7r~-P$2ksR)6i;ALSCuH%#Q4oQ=W#s6(Td3|7aAn*j$X0aBQ_- zf13K9%_S>s8P!cl3dQQzB-2Vdf;?f&38o+q)0X*mNPG-3 zd)Dn8&n#fryv8H&ZPDj&UoUe+jF^exoKI(#55O4TB3ORO+kfzpzDS>Bd&jsT%mFAt zy_3HvvdYTa#w(1Qzc4A~*ifN(bzkQT;Ii)y_&R}tz#vyAkxP@EJ$+M|0hA<+(7vZS z(#A%|Au>(CA#k~UJm64x9!OG)mEbl2^!oZiuov+T+&du}L3M_A2E5hUW(_7PBgAX8 zA$;(UoL;U7P3)In1t)(OTU@2fb37R?S4ge~>)Qsqy9Rrxq60lH13*qjPC-&eR#FCO zDJ!cgr=TjMATA@LDkH=Ebg$?C1N^Y=KAz$KJK#dJ0bK$j|IHBW~eMAn3M%4%|pzS4mbyNl8*pO4g=s!QfJi z_>b7n)j!136&)NB=n)9G6vDlOgK?_T()aG&lk)LEOQF4aV*n with Serializable implemen CryptoCurrency.banano, CryptoCurrency.usdtPoly, CryptoCurrency.usdcEPoly, + CryptoCurrency.kaspa, ]; static const havenCurrencies = [ @@ -206,6 +207,7 @@ class CryptoCurrency extends EnumerableItem with Serializable implemen static const banano = CryptoCurrency(title: 'BAN', fullName: 'Banano', raw: 86, name: 'banano', iconPath: 'assets/images/nano_icon.png', decimals: 29); static const usdtPoly = CryptoCurrency(title: 'USDT', tag: 'POLY', fullName: 'Tether USD (PoS)', raw: 87, name: 'usdtpoly', iconPath: 'assets/images/usdt_icon.png', decimals: 6); static const usdcEPoly = CryptoCurrency(title: 'USDC.E', tag: 'POLY', fullName: 'USD Coin (PoS)', raw: 88, name: 'usdcepoly', iconPath: 'assets/images/usdc_icon.png', decimals: 6); + static const kaspa = CryptoCurrency(title: 'KAS', fullName: 'Kaspa', raw: 89, name: 'kaspa', iconPath: 'assets/images/kaspa_icon.png', decimals: 8); static final Map _rawCurrencyMap = diff --git a/lib/exchange/provider/changenow_exchange_provider.dart b/lib/exchange/provider/changenow_exchange_provider.dart index 300741a08..c4a96bc5b 100644 --- a/lib/exchange/provider/changenow_exchange_provider.dart +++ b/lib/exchange/provider/changenow_exchange_provider.dart @@ -265,6 +265,9 @@ class ChangeNowExchangeProvider extends ExchangeProvider { } String _normalizeCurrency(CryptoCurrency currency) { + if (currency.title == "USDC" && currency.tag == "POLY") { + throw "Only Bridged USDC (USDC.e) is allowed in ChangeNow"; + } switch (currency) { case CryptoCurrency.zec: return 'zec'; diff --git a/lib/src/screens/dashboard/pages/balance_page.dart b/lib/src/screens/dashboard/pages/balance_page.dart index 283d2171d..6ddd8f6e1 100644 --- a/lib/src/screens/dashboard/pages/balance_page.dart +++ b/lib/src/screens/dashboard/pages/balance_page.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:auto_size_text/auto_size_text.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/reactions/wallet_connect.dart'; @@ -14,6 +16,7 @@ import 'package:cake_wallet/utils/feature_flag.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/view_model/dashboard/nft_view_model.dart'; +import 'package:cw_core/crypto_currency.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; @@ -200,7 +203,7 @@ class CryptoBalanceWidget extends StatelessWidget { additionalFiatBalance: balance.fiatAdditionalBalance, frozenBalance: balance.frozenBalance, frozenFiatBalance: balance.fiatFrozenBalance, - currency: balance.formattedAssetTitle, + currency: balance.asset, hasAdditionalBalance: dashboardViewModel.balanceViewModel.hasAdditionalBalance, ); @@ -216,7 +219,7 @@ class CryptoBalanceWidget extends StatelessWidget { } class BalanceRowWidget extends StatelessWidget { - const BalanceRowWidget({ + BalanceRowWidget({ required this.availableBalanceLabel, required this.availableBalance, required this.availableFiatBalance, @@ -238,7 +241,7 @@ class BalanceRowWidget extends StatelessWidget { final String additionalFiatBalance; final String frozenBalance; final String frozenFiatBalance; - final String currency; + final CryptoCurrency currency; final bool hasAdditionalBalance; // void _showBalanceDescription(BuildContext context) { @@ -268,7 +271,7 @@ class BalanceRowWidget extends StatelessWidget { children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ GestureDetector( behavior: HitTestBehavior.opaque, @@ -325,13 +328,48 @@ class BalanceRowWidget extends StatelessWidget { ], ), ), - Text(currency, - style: TextStyle( - fontSize: 28, - fontFamily: 'Lato', - fontWeight: FontWeight.w800, - color: Theme.of(context).extension()!.assetTitleColor, - height: 1)), + SizedBox( + width: MediaQuery.of(context).size.width * 0.18, + child: Center( + child: Column( + children: [ + currency.iconPath != null + ? Container( + child: Image.asset( + currency.iconPath!, + height: 30.0, + width: 30.0, + ), + ) + : Container( + height: 30.0, + width: 30.0, + child: Center( + child: Text( + currency.title.substring(0, min(currency.title.length, 2)), + style: TextStyle(fontSize: 11), + ), + ), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.grey.shade400, + ), + ), + const SizedBox(height: 10), + Text( + currency.title, + style: TextStyle( + fontSize: 18, + fontFamily: 'Lato', + fontWeight: FontWeight.w800, + color: Theme.of(context).extension()!.assetTitleColor, + height: 1, + ), + ), + ], + ), + ), + ), ], ), if (frozenBalance.isNotEmpty) @@ -374,7 +412,9 @@ class BalanceRowWidget extends StatelessWidget { fontSize: 20, fontFamily: 'Lato', fontWeight: FontWeight.w400, - color: Theme.of(context).extension()!.textColor, + color: Theme.of(context) + .extension()! + .balanceAmountColor, height: 1, ), maxLines: 1, @@ -388,7 +428,7 @@ class BalanceRowWidget extends StatelessWidget { fontSize: 12, fontFamily: 'Lato', fontWeight: FontWeight.w400, - color: Theme.of(context).extension()!.textColor, + color: Theme.of(context).extension()!.textColor, height: 1, ), ), diff --git a/lib/src/screens/exchange_trade/exchange_trade_page.dart b/lib/src/screens/exchange_trade/exchange_trade_page.dart index e72b0f0a8..7930c9c82 100644 --- a/lib/src/screens/exchange_trade/exchange_trade_page.dart +++ b/lib/src/screens/exchange_trade/exchange_trade_page.dart @@ -261,7 +261,7 @@ class ExchangeTradeState extends State { fee: S.of(popupContext).send_fee, feeValue: widget.exchangeTradeViewModel.sendViewModel .pendingTransaction!.feeFormatted, - rightButtonText: S.of(popupContext).ok, + rightButtonText: S.of(popupContext).send, leftButtonText: S.of(popupContext).cancel, actionRightButton: () async { Navigator.of(popupContext).pop(); diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index b20b94cba..3746118d8 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -423,7 +423,7 @@ class SendPage extends BasePage { feeValue: sendViewModel.pendingTransaction!.feeFormatted, feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted, outputs: sendViewModel.outputs, - rightButtonText: S.of(_dialogContext).ok, + rightButtonText: S.of(_dialogContext).send, leftButtonText: S.of(_dialogContext).cancel, actionRightButton: () { Navigator.of(_dialogContext).pop();