diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index e1cc1f343..251e0b8ef 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -69,17 +69,21 @@ class _ExchangeFormState extends ConsumerState { bool _swapLock = false; void sendFieldOnChanged(String value) async { - final newFromAmount = Decimal.tryParse(value); + if (_sendFocusNode.hasFocus) { + final newFromAmount = Decimal.tryParse(value); - ref.read(exchangeFormStateProvider).fromAmount = - newFromAmount ?? Decimal.zero; + await ref + .read(exchangeFormStateProvider) + .setFromAmountAndCalculateToAmount( + newFromAmount ?? Decimal.zero, true); - if (newFromAmount == null) { - _receiveController.text = - ref.read(prefsChangeNotifierProvider).exchangeRateType == - ExchangeRateType.estimated - ? "-" - : ""; + if (newFromAmount == null) { + _receiveController.text = + ref.read(prefsChangeNotifierProvider).exchangeRateType == + ExchangeRateType.estimated + ? "-" + : ""; + } } } @@ -116,6 +120,29 @@ class _ExchangeFormState extends ConsumerState { fromTicker: fromTicker, onSelected: (from) => ref.read(exchangeFormStateProvider).updateFrom(from, true)); + + unawaited( + showDialog( + context: context, + barrierDismissible: false, + builder: (_) => WillPopScope( + onWillPop: () async => false, + child: Container( + color: Theme.of(context) + .extension()! + .overlay + .withOpacity(0.6), + child: const CustomLoadingOverlay( + message: "Updating exchange rate", + eventBus: null, + ), + ), + ), + ), + ); + + await Future.delayed(const Duration(milliseconds: 300)); + Navigator.of(context).pop(); } else { final toTicker = ref.read(exchangeFormStateProvider).toTicker ?? ""; final fromTicker = ref.read(exchangeFormStateProvider).fromTicker ?? ""; @@ -1117,38 +1144,43 @@ class _ExchangeFormState extends ConsumerState { : ref.read(exchangeFormStateProvider).toAmountString; } - _sendFocusNode.addListener(() async { - if (!_sendFocusNode.hasFocus) { - final newFromAmount = Decimal.tryParse(_sendController.text); - await ref - .read(exchangeFormStateProvider) - .setFromAmountAndCalculateToAmount( - newFromAmount ?? Decimal.zero, true); - - if (newFromAmount == null) { - _receiveController.text = - ref.read(prefsChangeNotifierProvider).exchangeRateType == - ExchangeRateType.estimated - ? "-" - : ""; - } - } - }); - _receiveFocusNode.addListener(() async { - if (!_receiveFocusNode.hasFocus) { - final newToAmount = Decimal.tryParse(_receiveController.text); - if (ref.read(prefsChangeNotifierProvider).exchangeRateType != - ExchangeRateType.estimated) { - await ref - .read(exchangeFormStateProvider) - .setToAmountAndCalculateFromAmount( - newToAmount ?? Decimal.zero, true); - } - if (newToAmount == null) { - _sendController.text = ""; - } - } - }); + // _sendFocusNode.addListener(() async { + // if (!_sendFocusNode.hasFocus) { + // final newFromAmount = Decimal.tryParse(_sendController.text); + // await ref + // .read(exchangeFormStateProvider) + // .setFromAmountAndCalculateToAmount( + // newFromAmount ?? Decimal.zero, true); + // + // debugPrint("SendFocusNode has fired"); + // + // if (newFromAmount == null) { + // _receiveController.text = + // ref.read(prefsChangeNotifierProvider).exchangeRateType == + // ExchangeRateType.estimated + // ? "-" + // : ""; + // } + // } + // }); + // + // _receiveFocusNode.addListener(() async { + // if (!_receiveFocusNode.hasFocus) { + // final newToAmount = Decimal.tryParse(_receiveController.text); + // if (ref.read(prefsChangeNotifierProvider).exchangeRateType != + // ExchangeRateType.estimated) { + // await ref + // .read(exchangeFormStateProvider) + // .setToAmountAndCalculateFromAmount( + // newToAmount ?? Decimal.zero, true); + // + // debugPrint("ReceiveFocusNode has fired"); + // } + // if (newToAmount == null) { + // _sendController.text = ""; + // } + // } + // }); super.initState(); } @@ -1164,6 +1196,7 @@ class _ExchangeFormState extends ConsumerState { Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); + // provider for simpleswap; not called rn ref.listen(currentExchangeNameStateProvider, (previous, next) { ref.read(exchangeFormStateProvider).exchange = ref.read(exchangeProvider); }); @@ -1357,13 +1390,15 @@ class _ExchangeFormState extends ConsumerState { onChanged: onRateTypeChanged, ), ), - if (ref.read(exchangeFormStateProvider).fromAmount != null && - ref.read(exchangeFormStateProvider).fromAmount != Decimal.zero) + // these reads should be watch + if (ref.watch(exchangeFormStateProvider).fromAmount != null && + ref.watch(exchangeFormStateProvider).fromAmount != Decimal.zero) SizedBox( height: isDesktop ? 20 : 12, ), - if (ref.read(exchangeFormStateProvider).fromAmount != null && - ref.read(exchangeFormStateProvider).fromAmount != Decimal.zero) + // these reads should be watch + if (ref.watch(exchangeFormStateProvider).fromAmount != null && + ref.watch(exchangeFormStateProvider).fromAmount != Decimal.zero) ExchangeProviderOptions( from: ref.watch(exchangeFormStateProvider).fromTicker, to: ref.watch(exchangeFormStateProvider).toTicker, diff --git a/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart b/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart index 70a15088b..42ffc398a 100644 --- a/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart +++ b/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart @@ -77,35 +77,43 @@ class ExchangeProviderOptions extends ConsumerWidget { SizedBox( width: 20, height: 20, - child: Radio( - activeColor: Theme.of(context) - .extension()! - .radioButtonIconEnabled, - value: ChangeNowExchange.exchangeName, - groupValue: ref - .watch(currentExchangeNameStateProvider.state) - .state, - onChanged: (value) { - if (value is String) { - ref - .read(currentExchangeNameStateProvider.state) - .state = value; - ref.read(exchangeFormStateProvider).exchange = - Exchange.fromName(ref - .read(currentExchangeNameStateProvider - .state) - .state); - } - }, + child: Padding( + padding: + EdgeInsets.only(top: isDesktop ? 20.0 : 15.0), + child: Radio( + activeColor: Theme.of(context) + .extension()! + .radioButtonIconEnabled, + value: ChangeNowExchange.exchangeName, + groupValue: ref + .watch(currentExchangeNameStateProvider.state) + .state, + onChanged: (value) { + if (value is String) { + ref + .read( + currentExchangeNameStateProvider.state) + .state = value; + ref.read(exchangeFormStateProvider).exchange = + Exchange.fromName(ref + .read(currentExchangeNameStateProvider + .state) + .state); + } + }, + ), ), ), const SizedBox( width: 14, ), - SvgPicture.asset( - Assets.exchange.changeNow, - width: isDesktop ? 32 : 24, - height: isDesktop ? 32 : 24, + Padding( + padding: const EdgeInsets.only(top: 5.0), + child: SvgPicture.asset( + Assets.exchange.changeNow, + width: isDesktop ? 32 : 24, + height: isDesktop ? 32 : 24, + ), ), const SizedBox( width: 10, diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart index f740eee12..f953a975a 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart @@ -57,7 +57,7 @@ class DeleteWalletWarningView extends ConsumerWidget { .extension()! .warningBackground, child: Text( - "You are going to permanently delete you wallet.\n\nIf you delete your wallet, the only way you can have access to your funds is by using your backup key.\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet.\n\nPLEASE SAVE YOUR BACKUP KEY.", + "You are going to permanently delete your wallet.\n\nIf you delete your wallet, the only way you can have access to your funds is by using your backup key.\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet.\n\nPLEASE SAVE YOUR BACKUP KEY.", style: STextStyles.baseXS(context).copyWith( color: Theme.of(context) .extension()! diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart index febb9f44d..e30436dc0 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart @@ -66,7 +66,7 @@ class _DesktopAttentionDeleteWallet child: Padding( padding: const EdgeInsets.all(10.0), child: Text( - "You are going to permanently delete you wallet.\n\nIf you delete your wallet, " + "You are going to permanently delete your wallet.\n\nIf you delete your wallet, " "the only way you can have access to your funds is by using your backup key." "\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet." "\n\nPLEASE SAVE YOUR BACKUP KEY.", @@ -74,7 +74,7 @@ class _DesktopAttentionDeleteWallet .copyWith( color: Theme.of(context) .extension()! - .textDark3, + .snackBarTextError, ), ), ),