exchange swap currency fix

This commit is contained in:
julian 2022-10-14 11:41:10 -06:00
parent 907f55a418
commit b7d8e5db63
2 changed files with 28 additions and 39 deletions

View file

@ -395,8 +395,10 @@ 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) {
await updateMarket(market, false);
} else {
final Currency? newTo = from; final Currency? newTo = from;
final Currency? newFrom = to; final Currency? newFrom = to;
@ -409,10 +411,6 @@ class ExchangeFormState extends ChangeNotifier {
shouldNotifyListeners: false, shouldNotifyListeners: false,
reversed: reversed, reversed: reversed,
); );
break;
case ExchangeRateType.fixed:
await updateMarket(market, false);
break;
} }
notifyListeners(); notifyListeners();

View file

@ -294,11 +294,9 @@ 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) {
case ChangeNowExchange.exchangeName:
final from = ref.read(exchangeFormStateProvider).fromTicker; final from = ref.read(exchangeFormStateProvider).fromTicker;
final to = ref.read(exchangeFormStateProvider).toTicker; final to = ref.read(exchangeFormStateProvider).toTicker;
@ -309,18 +307,11 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
.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; } else {
case SimpleSwapExchange.exchangeName:
await ref.read(exchangeFormStateProvider).swap(); await ref.read(exchangeFormStateProvider).swap();
break;
default:
//
}
} }
if (mounted) { if (mounted) {
Navigator.of(context).pop(); Navigator.of(context).pop();