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;
maxAmount = null;
switch (exchangeType) {
case ExchangeRateType.estimated:
if (exchangeType == ExchangeRateType.fixed &&
exchange?.name == ChangeNowExchange.exchangeName) {
await updateMarket(market, false);
} else {
final Currency? newTo = from;
final Currency? newFrom = to;
@ -409,10 +411,6 @@ class ExchangeFormState extends ChangeNotifier {
shouldNotifyListeners: false,
reversed: reversed,
);
break;
case ExchangeRateType.fixed:
await updateMarket(market, false);
break;
}
notifyListeners();

View file

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