mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
desktop confirm send pw field enable submit on enter pressed
This commit is contained in:
parent
236e7d87fb
commit
981b7c86d4
2 changed files with 56 additions and 40 deletions
|
@ -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<DesktopAuthSend> {
|
|||
bool hidePassword = true;
|
||||
|
||||
bool _confirmEnabled = false;
|
||||
bool _lock = false;
|
||||
|
||||
Future<bool> verifyPassphrase() async {
|
||||
return await ref
|
||||
.read(storageCryptoHandlerProvider)
|
||||
.verifyPassphrase(passwordController.text);
|
||||
Future<void> _confirmPressed() async {
|
||||
if (_lock) {
|
||||
return;
|
||||
}
|
||||
_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
|
||||
|
@ -108,6 +149,12 @@ class _DesktopAuthSendState extends ConsumerState<DesktopAuthSend> {
|
|||
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<DesktopAuthSend> {
|
|||
enabled: _confirmEnabled,
|
||||
label: "Confirm",
|
||||
buttonHeight: ButtonHeight.l,
|
||||
onPressed: () async {
|
||||
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,
|
||||
));
|
||||
}
|
||||
},
|
||||
onPressed: _confirmPressed,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue