diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart index b574d377e..aba28300b 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart @@ -26,9 +26,9 @@ import 'package:stackwallet/widgets/stack_text_field.dart'; class DesktopAuthSend extends ConsumerStatefulWidget { const DesktopAuthSend({ - Key? key, + super.key, required this.coin, - }) : super(key: key); + }); final Coin coin; @@ -43,11 +43,52 @@ class _DesktopAuthSendState extends ConsumerState { bool hidePassword = true; bool _confirmEnabled = false; + bool _lock = false; - Future verifyPassphrase() async { - return await ref - .read(storageCryptoHandlerProvider) - .verifyPassphrase(passwordController.text); + Future _confirmPressed() async { + if (_lock) { + return; + } + _lock = true; + + try { + unawaited( + showDialog( + context: context, + builder: (context) => const Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + LoadingIndicator( + width: 200, + height: 200, + ), + ], + ), + ), + ); + + await Future.delayed(const Duration(seconds: 1)); + + final passwordIsValid = await ref + .read(storageCryptoHandlerProvider) + .verifyPassphrase(passwordController.text); + + if (mounted) { + Navigator.of(context).pop(); + Navigator.of( + context, + rootNavigator: true, + ).pop(passwordIsValid); + await Future.delayed( + const Duration( + milliseconds: 100, + ), + ); + } + } finally { + _lock = false; + } } @override @@ -108,6 +149,12 @@ class _DesktopAuthSendState extends ConsumerState { obscureText: hidePassword, enableSuggestions: false, autocorrect: false, + autofocus: true, + onSubmitted: (_) { + if (_confirmEnabled) { + _confirmPressed(); + } + }, decoration: standardInputDecoration( "Enter password", passwordFocusNode, @@ -173,38 +220,7 @@ class _DesktopAuthSendState extends ConsumerState { enabled: _confirmEnabled, label: "Confirm", buttonHeight: ButtonHeight.l, - onPressed: () async { - unawaited( - showDialog( - context: context, - builder: (context) => Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: const [ - LoadingIndicator( - width: 200, - height: 200, - ), - ], - ), - ), - ); - - await Future.delayed(const Duration(seconds: 1)); - - final passwordIsValid = await verifyPassphrase(); - - if (mounted) { - Navigator.of(context).pop(); - Navigator.of( - context, - rootNavigator: true, - ).pop(passwordIsValid); - await Future.delayed(const Duration( - milliseconds: 100, - )); - } - }, + onPressed: _confirmPressed, ), ), ], diff --git a/pubspec.lock b/pubspec.lock index b07d3ab62..7681556d6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1740,8 +1740,8 @@ packages: dependency: "direct main" description: path: "." - ref: f31f8f857665d85338824ae171aba4c629c3ba6f - resolved-ref: f31f8f857665d85338824ae171aba4c629c3ba6f + ref: "13fa937ea9a9fc34caf047e068df9535f65c27ad" + resolved-ref: "13fa937ea9a9fc34caf047e068df9535f65c27ad" url: "https://github.com/cypherstack/tezart.git" source: git version: "2.0.5"