From 81024480a25888cace2b044b44083026d78cb1a7 Mon Sep 17 00:00:00 2001 From: M Date: Wed, 23 Mar 2022 13:09:05 +0100 Subject: [PATCH] Another one day, another fixes batch. --- cw_core/lib/monero_amount_format.dart | 3 +- lib/src/screens/send/send_page.dart | 29 ++++++++++--------- .../dashboard/dashboard_view_model.dart | 26 +++++++++-------- lib/view_model/send/send_view_model.dart | 3 ++ 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/cw_core/lib/monero_amount_format.dart b/cw_core/lib/monero_amount_format.dart index ab8ef891c..92bf0da25 100644 --- a/cw_core/lib/monero_amount_format.dart +++ b/cw_core/lib/monero_amount_format.dart @@ -8,7 +8,8 @@ final moneroAmountFormat = NumberFormat() ..minimumFractionDigits = 1; String moneroAmountToString({int amount}) => moneroAmountFormat - .format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider)); + .format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider)) + .replaceAll(',', ''); double moneroAmountToDouble({int amount}) => cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider); diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 666289998..4a423a263 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -259,20 +259,21 @@ class SendPage extends BasePage { EdgeInsets.only(left: 24, right: 24, bottom: 24), bottomSection: Column( children: [ - Observer(builder: (_) => - Padding( - padding: EdgeInsets.only(bottom: 12), - child: PrimaryButton( - onPressed: () => presentCurrencyPicker(context), - text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})', - color: Colors.transparent, - textColor: Theme.of(context) - .accentTextTheme - .display2 - .decorationColor, + if (sendViewModel.hasCurrecyChanger) + Observer(builder: (_) => + Padding( + padding: EdgeInsets.only(bottom: 12), + child: PrimaryButton( + onPressed: () => presentCurrencyPicker(context), + text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})', + color: Colors.transparent, + textColor: Theme.of(context) + .accentTextTheme + .display2 + .decorationColor, + ) ) - ) - ), + ), if (sendViewModel.hasMultiRecipient) Padding( padding: EdgeInsets.only(bottom: 12), @@ -395,7 +396,7 @@ class SendPage extends BasePage { return AlertWithOneAction( alertTitle: '', alertContent: S.of(context).send_success( - sendViewModel.currency.toString()), + sendViewModel.selectedCryptoCurrency.toString()), buttonText: S.of(context).ok, buttonAction: () => Navigator.of(context).pop()); diff --git a/lib/view_model/dashboard/dashboard_view_model.dart b/lib/view_model/dashboard/dashboard_view_model.dart index 3c442568f..1a7a44406 100644 --- a/lib/view_model/dashboard/dashboard_view_model.dart +++ b/lib/view_model/dashboard/dashboard_view_model.dart @@ -79,12 +79,7 @@ abstract class DashboardViewModelBase with Store { isShowFirstYatIntroduction = false; isShowSecondYatIntroduction = false; isShowThirdYatIntroduction = false; - isEnabledExchangeAction = wallet.type != WalletType.haven; - hasExchangeAction = !isHaven; - isEnabledBuyAction = wallet.type != WalletType.haven; - hasBuyAction = !isMoneroOnly && !isHaven; - isEnabledSellAction = wallet.type != WalletType.haven; - hasSellAction = !isMoneroOnly && !isHaven; + updateActions(); final _wallet = wallet; @@ -277,12 +272,7 @@ abstract class DashboardViewModelBase with Store { name = wallet.name; isOutdatedElectrumWallet = wallet.type == WalletType.bitcoin && wallet.seed.split(' ').length < 24; - isEnabledExchangeAction = wallet.type != WalletType.haven; - hasExchangeAction = !isHaven; - isEnabledBuyAction = wallet.type != WalletType.haven; - hasBuyAction = !isMoneroOnly && !isHaven; - isEnabledSellAction = wallet.type != WalletType.haven; - hasSellAction = !isMoneroOnly && !isHaven; + updateActions(); if (wallet.type == WalletType.monero) { subname = monero.getCurrentAccount(wallet)?.label; @@ -345,4 +335,16 @@ abstract class DashboardViewModelBase with Store { balanceViewModel: balanceViewModel, settingsStore: appStore.settingsStore))); } + + void updateActions() { + isEnabledExchangeAction = wallet.type != WalletType.haven; + hasExchangeAction = !isHaven; + isEnabledBuyAction = wallet.type != WalletType.haven + && wallet.type != WalletType.monero; + hasBuyAction = !isMoneroOnly && !isHaven; + isEnabledSellAction = wallet.type != WalletType.haven + && wallet.type != WalletType.monero + && wallet.type != WalletType.litecoin; + hasSellAction = !isMoneroOnly && !isHaven; + } } diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index c1f768224..5c4a15c27 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -154,6 +154,9 @@ abstract class SendViewModelBase with Store { out.parsedAddress.parseFrom == ParseFrom.yatRecord); WalletType get walletType => _wallet.type; + + bool get hasCurrecyChanger => walletType == WalletType.haven; + final WalletBase _wallet; final SettingsStore _settingsStore; final SendTemplateViewModel sendTemplateViewModel;