mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-26 04:05:53 +00:00
currency select function fix
This commit is contained in:
parent
5aab115b96
commit
4345a67d3f
2 changed files with 20 additions and 18 deletions
|
@ -654,7 +654,7 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateFrom(
|
Future<void> updateSendCurrency(
|
||||||
Currency sendCurrency,
|
Currency sendCurrency,
|
||||||
bool shouldNotifyListeners,
|
bool shouldNotifyListeners,
|
||||||
) async {
|
) async {
|
||||||
|
@ -667,15 +667,15 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
shouldNotifyListeners: false,
|
shouldNotifyListeners: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (shouldNotifyListeners) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log("$e\n$s", level: LogLevel.Error);
|
Logging.instance.log("$e\n$s", level: LogLevel.Error);
|
||||||
}
|
}
|
||||||
if (shouldNotifyListeners) {
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateTo(
|
Future<void> updateReceivingCurrency(
|
||||||
Currency receiveCurrency,
|
Currency receiveCurrency,
|
||||||
bool shouldNotifyListeners,
|
bool shouldNotifyListeners,
|
||||||
) async {
|
) async {
|
||||||
|
@ -689,12 +689,12 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
shouldNotifyListeners: false,
|
shouldNotifyListeners: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (shouldNotifyListeners) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log("$e\n$s", level: LogLevel.Error);
|
Logging.instance.log("$e\n$s", level: LogLevel.Error);
|
||||||
}
|
}
|
||||||
if (shouldNotifyListeners) {
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> swap({
|
Future<void> swap({
|
||||||
|
|
|
@ -121,10 +121,10 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
await _showCurrencySelectionSheet(
|
await _showCurrencySelectionSheet(
|
||||||
willChange: ref.read(exchangeFormStateProvider(type)).sendCurrency,
|
willChange: ref.read(exchangeFormStateProvider(type)).sendCurrency,
|
||||||
paired: ref.read(exchangeFormStateProvider(type)).receiveCurrency,
|
paired: ref.read(exchangeFormStateProvider(type)).receiveCurrency,
|
||||||
isFixedRate: ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
isFixedRate: type == ExchangeRateType.fixed,
|
||||||
ExchangeRateType.fixed,
|
onSelected: (selectedCurrency) => ref
|
||||||
onSelected: (to) =>
|
.read(exchangeFormStateProvider(type))
|
||||||
ref.read(exchangeFormStateProvider(type)).updateTo(to, true),
|
.updateSendCurrency(selectedCurrency, true),
|
||||||
);
|
);
|
||||||
|
|
||||||
unawaited(
|
unawaited(
|
||||||
|
@ -167,10 +167,10 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
await _showCurrencySelectionSheet(
|
await _showCurrencySelectionSheet(
|
||||||
willChange: ref.read(exchangeFormStateProvider(type)).receiveCurrency,
|
willChange: ref.read(exchangeFormStateProvider(type)).receiveCurrency,
|
||||||
paired: ref.read(exchangeFormStateProvider(type)).sendCurrency,
|
paired: ref.read(exchangeFormStateProvider(type)).sendCurrency,
|
||||||
isFixedRate: ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
isFixedRate: type == ExchangeRateType.fixed,
|
||||||
ExchangeRateType.fixed,
|
onSelected: (selectedCurrency) => ref
|
||||||
onSelected: (to) =>
|
.read(exchangeFormStateProvider(type))
|
||||||
ref.read(exchangeFormStateProvider(type)).updateTo(to, true),
|
.updateReceivingCurrency(selectedCurrency, true),
|
||||||
);
|
);
|
||||||
|
|
||||||
unawaited(
|
unawaited(
|
||||||
|
@ -389,10 +389,12 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
_receiveController.text = "";
|
_receiveController.text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
await ref.read(exchangeFormStateProvider(type)).updateTo(to, false);
|
|
||||||
await ref
|
await ref
|
||||||
.read(exchangeFormStateProvider(type))
|
.read(exchangeFormStateProvider(type))
|
||||||
.updateFrom(from, true);
|
.updateReceivingCurrency(to, false);
|
||||||
|
await ref
|
||||||
|
.read(exchangeFormStateProvider(type))
|
||||||
|
.updateSendCurrency(from, true);
|
||||||
|
|
||||||
_receiveController.text =
|
_receiveController.text =
|
||||||
ref.read(exchangeFormStateProvider(type)).toAmountString.isEmpty
|
ref.read(exchangeFormStateProvider(type)).toAmountString.isEmpty
|
||||||
|
|
Loading…
Reference in a new issue