desktop confirm send pw field enable submit on enter pressed

This commit is contained in:
sneurlax 2024-05-03 18:56:27 -06:00 committed by julian
parent 236e7d87fb
commit 981b7c86d4
2 changed files with 56 additions and 40 deletions

View file

@ -26,9 +26,9 @@ import 'package:stackwallet/widgets/stack_text_field.dart';
class DesktopAuthSend extends ConsumerStatefulWidget { class DesktopAuthSend extends ConsumerStatefulWidget {
const DesktopAuthSend({ const DesktopAuthSend({
Key? key, super.key,
required this.coin, required this.coin,
}) : super(key: key); });
final Coin coin; final Coin coin;
@ -43,11 +43,52 @@ class _DesktopAuthSendState extends ConsumerState<DesktopAuthSend> {
bool hidePassword = true; bool hidePassword = true;
bool _confirmEnabled = false; bool _confirmEnabled = false;
bool _lock = false;
Future<bool> verifyPassphrase() async { Future<void> _confirmPressed() async {
return await ref if (_lock) {
.read(storageCryptoHandlerProvider) return;
.verifyPassphrase(passwordController.text); }
_lock = true;
try {
unawaited(
showDialog<void>(
context: context,
builder: (context) => const Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
LoadingIndicator(
width: 200,
height: 200,
),
],
),
),
);
await Future<void>.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<void>.delayed(
const Duration(
milliseconds: 100,
),
);
}
} finally {
_lock = false;
}
} }
@override @override
@ -108,6 +149,12 @@ class _DesktopAuthSendState extends ConsumerState<DesktopAuthSend> {
obscureText: hidePassword, obscureText: hidePassword,
enableSuggestions: false, enableSuggestions: false,
autocorrect: false, autocorrect: false,
autofocus: true,
onSubmitted: (_) {
if (_confirmEnabled) {
_confirmPressed();
}
},
decoration: standardInputDecoration( decoration: standardInputDecoration(
"Enter password", "Enter password",
passwordFocusNode, passwordFocusNode,
@ -173,38 +220,7 @@ class _DesktopAuthSendState extends ConsumerState<DesktopAuthSend> {
enabled: _confirmEnabled, enabled: _confirmEnabled,
label: "Confirm", label: "Confirm",
buttonHeight: ButtonHeight.l, buttonHeight: ButtonHeight.l,
onPressed: () async { onPressed: _confirmPressed,
unawaited(
showDialog<void>(
context: context,
builder: (context) => Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: const [
LoadingIndicator(
width: 200,
height: 200,
),
],
),
),
);
await Future<void>.delayed(const Duration(seconds: 1));
final passwordIsValid = await verifyPassphrase();
if (mounted) {
Navigator.of(context).pop();
Navigator.of(
context,
rootNavigator: true,
).pop(passwordIsValid);
await Future<void>.delayed(const Duration(
milliseconds: 100,
));
}
},
), ),
), ),
], ],

View file

@ -1740,8 +1740,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: f31f8f857665d85338824ae171aba4c629c3ba6f ref: "13fa937ea9a9fc34caf047e068df9535f65c27ad"
resolved-ref: f31f8f857665d85338824ae171aba4c629c3ba6f resolved-ref: "13fa937ea9a9fc34caf047e068df9535f65c27ad"
url: "https://github.com/cypherstack/tezart.git" url: "https://github.com/cypherstack/tezart.git"
source: git source: git
version: "2.0.5" version: "2.0.5"