mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
exchange swap currency fix
This commit is contained in:
parent
907f55a418
commit
b7d8e5db63
2 changed files with 28 additions and 39 deletions
|
@ -395,24 +395,22 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
minAmount = null;
|
minAmount = null;
|
||||||
maxAmount = null;
|
maxAmount = null;
|
||||||
|
|
||||||
switch (exchangeType) {
|
if (exchangeType == ExchangeRateType.fixed &&
|
||||||
case ExchangeRateType.estimated:
|
exchange?.name == ChangeNowExchange.exchangeName) {
|
||||||
final Currency? newTo = from;
|
await updateMarket(market, false);
|
||||||
final Currency? newFrom = to;
|
} else {
|
||||||
|
final Currency? newTo = from;
|
||||||
|
final Currency? newFrom = to;
|
||||||
|
|
||||||
_to = newTo;
|
_to = newTo;
|
||||||
_from = newFrom;
|
_from = newFrom;
|
||||||
|
|
||||||
await updateRanges(shouldNotifyListeners: false);
|
await updateRanges(shouldNotifyListeners: false);
|
||||||
|
|
||||||
await updateEstimate(
|
await updateEstimate(
|
||||||
shouldNotifyListeners: false,
|
shouldNotifyListeners: false,
|
||||||
reversed: reversed,
|
reversed: reversed,
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
case ExchangeRateType.fixed:
|
|
||||||
await updateMarket(market, false);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
|
@ -294,33 +294,24 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
if (ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
||||||
ExchangeRateType.estimated) {
|
ExchangeRateType.fixed &&
|
||||||
await ref.read(exchangeFormStateProvider).swap();
|
ref.read(exchangeFormStateProvider).exchange?.name ==
|
||||||
} else {
|
ChangeNowExchange.exchangeName) {
|
||||||
switch (ref.read(currentExchangeNameStateProvider.state).state) {
|
final from = ref.read(exchangeFormStateProvider).fromTicker;
|
||||||
case ChangeNowExchange.exchangeName:
|
final to = ref.read(exchangeFormStateProvider).toTicker;
|
||||||
final from = ref.read(exchangeFormStateProvider).fromTicker;
|
|
||||||
final to = ref.read(exchangeFormStateProvider).toTicker;
|
|
||||||
|
|
||||||
if (to != null && from != null) {
|
if (to != null && from != null) {
|
||||||
final markets = ref
|
final markets = ref
|
||||||
.read(availableChangeNowCurrenciesProvider)
|
.read(availableChangeNowCurrenciesProvider)
|
||||||
.markets
|
.markets
|
||||||
.where((e) => e.from == to && e.to == from);
|
.where((e) => e.from == to && e.to == from);
|
||||||
|
|
||||||
if (markets.isNotEmpty) {
|
if (markets.isNotEmpty) {
|
||||||
await ref
|
await ref.read(exchangeFormStateProvider).swap(market: markets.first);
|
||||||
.read(exchangeFormStateProvider)
|
}
|
||||||
.swap(market: markets.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SimpleSwapExchange.exchangeName:
|
|
||||||
await ref.read(exchangeFormStateProvider).swap();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
await ref.read(exchangeFormStateProvider).swap();
|
||||||
}
|
}
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
Loading…
Reference in a new issue