CAKE-296 | added receiveCurrencies (list of crypto currencies without xlm and xrp) to exchange_view_model.dart; applied receiveCurrencies to receive card in the exchange_page.dart

This commit is contained in:
OleksandrSobol 2021-04-06 20:11:26 +03:00
parent d9752e5709
commit 68c12cbb79
3 changed files with 9 additions and 22 deletions

View file

@ -17,23 +17,12 @@ import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
class ChangeNowExchangeProvider extends ExchangeProvider {
ChangeNowExchangeProvider()
: super(
/*pairList: CryptoCurrency.all
pairList: CryptoCurrency.all
.map((i) => CryptoCurrency.all
.map((k) => ExchangePair(from: i, to: k, reverse: true))
.where((c) => c != null))
.expand((i) => i)
.toList());*/
pairList: CryptoCurrency.all
.map((i) => CryptoCurrency.all
.map((k) {
if ((i != CryptoCurrency.xmr)||
((k != CryptoCurrency.xrp)&&(k != CryptoCurrency.xlm))) {
return ExchangePair(from: i, to: k, reverse: true);
}
})
.where((c) => c != null))
.expand((i) => i)
.toList());
.toList());
static const apiUri = 'https://changenow.io/api/v1';
static const apiKey = secrets.changeNowApiKey;

View file

@ -248,7 +248,8 @@ class ExchangePage extends BasePage {
exchangeViewModel
.isReceiveAddressEnabled,
isAmountEstimated: true,
currencies: CryptoCurrency.all,
currencies:
exchangeViewModel.receiveCurrencies,
onCurrencySelected: (currency) =>
exchangeViewModel
.changeReceiveCurrency(
@ -464,7 +465,6 @@ class ExchangePage extends BasePage {
},
color: Theme.of(context).accentTextTheme.body2.color,
textColor: Colors.white,
isDisabled: exchangeViewModel.isDisabledExchangeButton,
isLoading:
exchangeViewModel.tradeState is TradeIsCreating)),
]),

View file

@ -57,10 +57,12 @@ abstract class ExchangeViewModelBase with Store {
_onPairChange();
}
});
receiveCurrencies = CryptoCurrency.all.where((cryptoCurrency) =>
(cryptoCurrency != CryptoCurrency.xlm)&&
(cryptoCurrency != CryptoCurrency.xrp)).toList();
_defineIsReceiveAmountEditable();
isFixedRateMode = false;
isReceiveAmountEntered = false;
isDisabledExchangeButton = false;
loadLimits();
}
@ -114,9 +116,6 @@ abstract class ExchangeViewModelBase with Store {
@observable
bool isFixedRateMode;
@observable
bool isDisabledExchangeButton;
@computed
SyncStatus get status => wallet.syncStatus;
@ -127,6 +126,8 @@ abstract class ExchangeViewModelBase with Store {
bool get hasAllAmount =>
wallet.type == WalletType.bitcoin && depositCurrency == wallet.currency;
List<CryptoCurrency> receiveCurrencies;
Limits limits;
NumberFormat _cryptoNumberFormat;
@ -378,14 +379,11 @@ abstract class ExchangeViewModelBase with Store {
_providerForPair(from: depositCurrency, to: receiveCurrency);
if (provider != null) {
isDisabledExchangeButton = false;
changeProvider(provider: provider);
}
} else {
isDisabledExchangeButton = true;
depositAmount = '';
receiveAmount = '';
limitsState = LimitsLoadedFailure(error: 'Pair is not exists');
}
}