mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +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;
|
||||
maxAmount = null;
|
||||
|
||||
switch (exchangeType) {
|
||||
case ExchangeRateType.estimated:
|
||||
final Currency? newTo = from;
|
||||
final Currency? newFrom = to;
|
||||
if (exchangeType == ExchangeRateType.fixed &&
|
||||
exchange?.name == ChangeNowExchange.exchangeName) {
|
||||
await updateMarket(market, false);
|
||||
} else {
|
||||
final Currency? newTo = from;
|
||||
final Currency? newFrom = to;
|
||||
|
||||
_to = newTo;
|
||||
_from = newFrom;
|
||||
_to = newTo;
|
||||
_from = newFrom;
|
||||
|
||||
await updateRanges(shouldNotifyListeners: false);
|
||||
await updateRanges(shouldNotifyListeners: false);
|
||||
|
||||
await updateEstimate(
|
||||
shouldNotifyListeners: false,
|
||||
reversed: reversed,
|
||||
);
|
||||
break;
|
||||
case ExchangeRateType.fixed:
|
||||
await updateMarket(market, false);
|
||||
break;
|
||||
await updateEstimate(
|
||||
shouldNotifyListeners: false,
|
||||
reversed: reversed,
|
||||
);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
|
|
@ -294,33 +294,24 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
|||
);
|
||||
|
||||
if (ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
||||
ExchangeRateType.estimated) {
|
||||
await ref.read(exchangeFormStateProvider).swap();
|
||||
} else {
|
||||
switch (ref.read(currentExchangeNameStateProvider.state).state) {
|
||||
case ChangeNowExchange.exchangeName:
|
||||
final from = ref.read(exchangeFormStateProvider).fromTicker;
|
||||
final to = ref.read(exchangeFormStateProvider).toTicker;
|
||||
ExchangeRateType.fixed &&
|
||||
ref.read(exchangeFormStateProvider).exchange?.name ==
|
||||
ChangeNowExchange.exchangeName) {
|
||||
final from = ref.read(exchangeFormStateProvider).fromTicker;
|
||||
final to = ref.read(exchangeFormStateProvider).toTicker;
|
||||
|
||||
if (to != null && from != null) {
|
||||
final markets = ref
|
||||
.read(availableChangeNowCurrenciesProvider)
|
||||
.markets
|
||||
.where((e) => e.from == to && e.to == from);
|
||||
if (to != null && from != null) {
|
||||
final markets = ref
|
||||
.read(availableChangeNowCurrenciesProvider)
|
||||
.markets
|
||||
.where((e) => e.from == to && e.to == from);
|
||||
|
||||
if (markets.isNotEmpty) {
|
||||
await ref
|
||||
.read(exchangeFormStateProvider)
|
||||
.swap(market: markets.first);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SimpleSwapExchange.exchangeName:
|
||||
await ref.read(exchangeFormStateProvider).swap();
|
||||
break;
|
||||
default:
|
||||
//
|
||||
if (markets.isNotEmpty) {
|
||||
await ref.read(exchangeFormStateProvider).swap(market: markets.first);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await ref.read(exchangeFormStateProvider).swap();
|
||||
}
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
|
|
Loading…
Reference in a new issue