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]
This commit is contained in:
Omar Hatem 2024-01-08 16:05:35 +02:00 committed by GitHub
parent 2a1bdf69ef
commit b3c8be4ba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 60 additions and 15 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View file

@ -95,6 +95,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
CryptoCurrency.banano, CryptoCurrency.banano,
CryptoCurrency.usdtPoly, CryptoCurrency.usdtPoly,
CryptoCurrency.usdcEPoly, CryptoCurrency.usdcEPoly,
CryptoCurrency.kaspa,
]; ];
static const havenCurrencies = [ static const havenCurrencies = [
@ -206,6 +207,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
static const banano = CryptoCurrency(title: 'BAN', fullName: 'Banano', raw: 86, name: 'banano', iconPath: 'assets/images/nano_icon.png', decimals: 29); 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 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 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<int, CryptoCurrency> _rawCurrencyMap = static final Map<int, CryptoCurrency> _rawCurrencyMap =

View file

@ -265,6 +265,9 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
} }
String _normalizeCurrency(CryptoCurrency currency) { String _normalizeCurrency(CryptoCurrency currency) {
if (currency.title == "USDC" && currency.tag == "POLY") {
throw "Only Bridged USDC (USDC.e) is allowed in ChangeNow";
}
switch (currency) { switch (currency) {
case CryptoCurrency.zec: case CryptoCurrency.zec:
return 'zec'; return 'zec';

View file

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:auto_size_text/auto_size_text.dart'; import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/reactions/wallet_connect.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/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.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:cake_wallet/view_model/dashboard/nft_view_model.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_mobx/flutter_mobx.dart';
@ -200,7 +203,7 @@ class CryptoBalanceWidget extends StatelessWidget {
additionalFiatBalance: balance.fiatAdditionalBalance, additionalFiatBalance: balance.fiatAdditionalBalance,
frozenBalance: balance.frozenBalance, frozenBalance: balance.frozenBalance,
frozenFiatBalance: balance.fiatFrozenBalance, frozenFiatBalance: balance.fiatFrozenBalance,
currency: balance.formattedAssetTitle, currency: balance.asset,
hasAdditionalBalance: hasAdditionalBalance:
dashboardViewModel.balanceViewModel.hasAdditionalBalance, dashboardViewModel.balanceViewModel.hasAdditionalBalance,
); );
@ -216,7 +219,7 @@ class CryptoBalanceWidget extends StatelessWidget {
} }
class BalanceRowWidget extends StatelessWidget { class BalanceRowWidget extends StatelessWidget {
const BalanceRowWidget({ BalanceRowWidget({
required this.availableBalanceLabel, required this.availableBalanceLabel,
required this.availableBalance, required this.availableBalance,
required this.availableFiatBalance, required this.availableFiatBalance,
@ -238,7 +241,7 @@ class BalanceRowWidget extends StatelessWidget {
final String additionalFiatBalance; final String additionalFiatBalance;
final String frozenBalance; final String frozenBalance;
final String frozenFiatBalance; final String frozenFiatBalance;
final String currency; final CryptoCurrency currency;
final bool hasAdditionalBalance; final bool hasAdditionalBalance;
// void _showBalanceDescription(BuildContext context) { // void _showBalanceDescription(BuildContext context) {
@ -268,7 +271,7 @@ class BalanceRowWidget extends StatelessWidget {
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
GestureDetector( GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
@ -325,13 +328,48 @@ class BalanceRowWidget extends StatelessWidget {
], ],
), ),
), ),
Text(currency, SizedBox(
style: TextStyle( width: MediaQuery.of(context).size.width * 0.18,
fontSize: 28, child: Center(
fontFamily: 'Lato', child: Column(
fontWeight: FontWeight.w800, children: [
color: Theme.of(context).extension<BalancePageTheme>()!.assetTitleColor, currency.iconPath != null
height: 1)), ? 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<BalancePageTheme>()!.assetTitleColor,
height: 1,
),
),
],
),
),
),
], ],
), ),
if (frozenBalance.isNotEmpty) if (frozenBalance.isNotEmpty)
@ -374,7 +412,9 @@ class BalanceRowWidget extends StatelessWidget {
fontSize: 20, fontSize: 20,
fontFamily: 'Lato', fontFamily: 'Lato',
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor, color: Theme.of(context)
.extension<BalancePageTheme>()!
.balanceAmountColor,
height: 1, height: 1,
), ),
maxLines: 1, maxLines: 1,
@ -388,7 +428,7 @@ class BalanceRowWidget extends StatelessWidget {
fontSize: 12, fontSize: 12,
fontFamily: 'Lato', fontFamily: 'Lato',
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: Theme.of(context).extension<DashboardPageTheme>()!.textColor, color: Theme.of(context).extension<BalancePageTheme>()!.textColor,
height: 1, height: 1,
), ),
), ),

View file

@ -261,7 +261,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
fee: S.of(popupContext).send_fee, fee: S.of(popupContext).send_fee,
feeValue: widget.exchangeTradeViewModel.sendViewModel feeValue: widget.exchangeTradeViewModel.sendViewModel
.pendingTransaction!.feeFormatted, .pendingTransaction!.feeFormatted,
rightButtonText: S.of(popupContext).ok, rightButtonText: S.of(popupContext).send,
leftButtonText: S.of(popupContext).cancel, leftButtonText: S.of(popupContext).cancel,
actionRightButton: () async { actionRightButton: () async {
Navigator.of(popupContext).pop(); Navigator.of(popupContext).pop();

View file

@ -423,7 +423,7 @@ class SendPage extends BasePage {
feeValue: sendViewModel.pendingTransaction!.feeFormatted, feeValue: sendViewModel.pendingTransaction!.feeFormatted,
feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted, feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted,
outputs: sendViewModel.outputs, outputs: sendViewModel.outputs,
rightButtonText: S.of(_dialogContext).ok, rightButtonText: S.of(_dialogContext).send,
leftButtonText: S.of(_dialogContext).cancel, leftButtonText: S.of(_dialogContext).cancel,
actionRightButton: () { actionRightButton: () {
Navigator.of(_dialogContext).pop(); Navigator.of(_dialogContext).pop();