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
OleksandrSobol committed
Apr 6, 2021 at 20:11 UTC
68c12cbb79efa2573574e1ec49b7a1e64d3aafbe
3 files changed
+9
-22
lib/exchange/changenow/changenow_exchange_provider.dart
+2
-13
@@ -17,23 +17,12 @@ import 'package:cake_wallet/exchange/trade_not_created_exeption.dart';
17
class ChangeNowExchangeProvider extends ExchangeProvider {
18
ChangeNowExchangeProvider()
19
: super(
20
- /*pairList: CryptoCurrency.all
20
+ pairList: CryptoCurrency.all
21
.map((i) => CryptoCurrency.all
22
.map((k) => ExchangePair(from: i, to: k, reverse: true))
23
.where((c) => c != null))
24
.expand((i) => i)
25
- .toList());*/
26
- pairList: CryptoCurrency.all
27
- .map((i) => CryptoCurrency.all
28
- .map((k) {
29
- if ((i != CryptoCurrency.xmr)||
30
- ((k != CryptoCurrency.xrp)&&(k != CryptoCurrency.xlm))) {
31
- return ExchangePair(from: i, to: k, reverse: true);
32
- }
33
- })
34
- .where((c) => c != null))
35
- .expand((i) => i)
36
- .toList());
25
+ .toList());
26
27
static const apiUri = 'https://changenow.io/api/v1';
28
static const apiKey = secrets.changeNowApiKey;
lib/src/screens/exchange/exchange_page.dart
+2
-2
@@ -248,7 +248,8 @@ class ExchangePage extends BasePage {
248
exchangeViewModel
249
.isReceiveAddressEnabled,
250
isAmountEstimated: true,
251
- currencies: CryptoCurrency.all,
251
+ currencies:
252
+ exchangeViewModel.receiveCurrencies,
253
onCurrencySelected: (currency) =>
254
exchangeViewModel
255
.changeReceiveCurrency(
@@ -464,7 +465,6 @@ class ExchangePage extends BasePage {
465
},
466
color: Theme.of(context).accentTextTheme.body2.color,
467
textColor: Colors.white,
467
- isDisabled: exchangeViewModel.isDisabledExchangeButton,
468
isLoading:
469
exchangeViewModel.tradeState is TradeIsCreating)),
470
]),
lib/view_model/exchange/exchange_view_model.dart
+5
-7
@@ -57,10 +57,12 @@ abstract class ExchangeViewModelBase with Store {
57
_onPairChange();
58
}
59
});
60
+ receiveCurrencies = CryptoCurrency.all.where((cryptoCurrency) =>
61
+ (cryptoCurrency != CryptoCurrency.xlm)&&
62
+ (cryptoCurrency != CryptoCurrency.xrp)).toList();
63
_defineIsReceiveAmountEditable();
64
isFixedRateMode = false;
65
isReceiveAmountEntered = false;
63
- isDisabledExchangeButton = false;
66
loadLimits();
67
}
68
@@ -114,9 +116,6 @@ abstract class ExchangeViewModelBase with Store {
116
@observable
117
bool isFixedRateMode;
118
117
- @observable
118
- bool isDisabledExchangeButton;
119
-
119
@computed
120
SyncStatus get status => wallet.syncStatus;
121
@@ -127,6 +126,8 @@ abstract class ExchangeViewModelBase with Store {
126
bool get hasAllAmount =>
127
wallet.type == WalletType.bitcoin && depositCurrency == wallet.currency;
128
129
+ List<CryptoCurrency> receiveCurrencies;
130
+
131
Limits limits;
132
133
NumberFormat _cryptoNumberFormat;
@@ -378,14 +379,11 @@ abstract class ExchangeViewModelBase with Store {
379
_providerForPair(from: depositCurrency, to: receiveCurrency);
380
381
if (provider != null) {
381
- isDisabledExchangeButton = false;
382
changeProvider(provider: provider);
383
}
384
} else {
385
- isDisabledExchangeButton = true;
385
depositAmount = '';
386
receiveAmount = '';
388
- limitsState = LimitsLoadedFailure(error: 'Pair is not exists');
387
}
388
}
389