Another one day, another fixes batch.

This commit is contained in:
M 2022-03-23 13:09:05 +01:00
parent e4d7d6d5a7
commit 81024480a2
4 changed files with 34 additions and 27 deletions

View file

@ -8,7 +8,8 @@ final moneroAmountFormat = NumberFormat()
..minimumFractionDigits = 1; ..minimumFractionDigits = 1;
String moneroAmountToString({int amount}) => moneroAmountFormat String moneroAmountToString({int amount}) => moneroAmountFormat
.format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider)); .format(cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider))
.replaceAll(',', '');
double moneroAmountToDouble({int amount}) => double moneroAmountToDouble({int amount}) =>
cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider); cryptoAmountToDouble(amount: amount, divider: moneroAmountDivider);

View file

@ -259,20 +259,21 @@ class SendPage extends BasePage {
EdgeInsets.only(left: 24, right: 24, bottom: 24), EdgeInsets.only(left: 24, right: 24, bottom: 24),
bottomSection: Column( bottomSection: Column(
children: [ children: [
Observer(builder: (_) => if (sendViewModel.hasCurrecyChanger)
Padding( Observer(builder: (_) =>
padding: EdgeInsets.only(bottom: 12), Padding(
child: PrimaryButton( padding: EdgeInsets.only(bottom: 12),
onPressed: () => presentCurrencyPicker(context), child: PrimaryButton(
text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})', onPressed: () => presentCurrencyPicker(context),
color: Colors.transparent, text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})',
textColor: Theme.of(context) color: Colors.transparent,
.accentTextTheme textColor: Theme.of(context)
.display2 .accentTextTheme
.decorationColor, .display2
.decorationColor,
)
) )
) ),
),
if (sendViewModel.hasMultiRecipient) if (sendViewModel.hasMultiRecipient)
Padding( Padding(
padding: EdgeInsets.only(bottom: 12), padding: EdgeInsets.only(bottom: 12),
@ -395,7 +396,7 @@ class SendPage extends BasePage {
return AlertWithOneAction( return AlertWithOneAction(
alertTitle: '', alertTitle: '',
alertContent: S.of(context).send_success( alertContent: S.of(context).send_success(
sendViewModel.currency.toString()), sendViewModel.selectedCryptoCurrency.toString()),
buttonText: S.of(context).ok, buttonText: S.of(context).ok,
buttonAction: () => buttonAction: () =>
Navigator.of(context).pop()); Navigator.of(context).pop());

View file

@ -79,12 +79,7 @@ abstract class DashboardViewModelBase with Store {
isShowFirstYatIntroduction = false; isShowFirstYatIntroduction = false;
isShowSecondYatIntroduction = false; isShowSecondYatIntroduction = false;
isShowThirdYatIntroduction = false; isShowThirdYatIntroduction = false;
isEnabledExchangeAction = wallet.type != WalletType.haven; updateActions();
hasExchangeAction = !isHaven;
isEnabledBuyAction = wallet.type != WalletType.haven;
hasBuyAction = !isMoneroOnly && !isHaven;
isEnabledSellAction = wallet.type != WalletType.haven;
hasSellAction = !isMoneroOnly && !isHaven;
final _wallet = wallet; final _wallet = wallet;
@ -277,12 +272,7 @@ abstract class DashboardViewModelBase with Store {
name = wallet.name; name = wallet.name;
isOutdatedElectrumWallet = isOutdatedElectrumWallet =
wallet.type == WalletType.bitcoin && wallet.seed.split(' ').length < 24; wallet.type == WalletType.bitcoin && wallet.seed.split(' ').length < 24;
isEnabledExchangeAction = wallet.type != WalletType.haven; updateActions();
hasExchangeAction = !isHaven;
isEnabledBuyAction = wallet.type != WalletType.haven;
hasBuyAction = !isMoneroOnly && !isHaven;
isEnabledSellAction = wallet.type != WalletType.haven;
hasSellAction = !isMoneroOnly && !isHaven;
if (wallet.type == WalletType.monero) { if (wallet.type == WalletType.monero) {
subname = monero.getCurrentAccount(wallet)?.label; subname = monero.getCurrentAccount(wallet)?.label;
@ -345,4 +335,16 @@ abstract class DashboardViewModelBase with Store {
balanceViewModel: balanceViewModel, balanceViewModel: balanceViewModel,
settingsStore: appStore.settingsStore))); 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;
}
} }

View file

@ -154,6 +154,9 @@ abstract class SendViewModelBase with Store {
out.parsedAddress.parseFrom == ParseFrom.yatRecord); out.parsedAddress.parseFrom == ParseFrom.yatRecord);
WalletType get walletType => _wallet.type; WalletType get walletType => _wallet.type;
bool get hasCurrecyChanger => walletType == WalletType.haven;
final WalletBase _wallet; final WalletBase _wallet;
final SettingsStore _settingsStore; final SettingsStore _settingsStore;
final SendTemplateViewModel sendTemplateViewModel; final SendTemplateViewModel sendTemplateViewModel;