From 6a22c23ece12024eb0c1bc46a886e75aad60b40d Mon Sep 17 00:00:00 2001 From: Adam Velebil Date: Thu, 4 Jul 2024 14:36:42 +0200 Subject: [PATCH] improved fingerprint views --- lib/fido/views/add_fingerprint_dialog.dart | 8 ++++++-- lib/fido/views/rename_fingerprint_dialog.dart | 13 ++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/fido/views/add_fingerprint_dialog.dart b/lib/fido/views/add_fingerprint_dialog.dart index 69b2392a..231808b9 100755 --- a/lib/fido/views/add_fingerprint_dialog.dart +++ b/lib/fido/views/add_fingerprint_dialog.dart @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Yubico. + * Copyright (C) 2022-2024 Yubico. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -255,7 +255,11 @@ class _AddFingerprintDialogState extends ConsumerState }); }, onFieldSubmitted: (_) { - _submit(); + if (_label.isNotEmpty) { + _submit(); + } else { + _nameFocus.requestFocus(); + } }, ).init(), ) diff --git a/lib/fido/views/rename_fingerprint_dialog.dart b/lib/fido/views/rename_fingerprint_dialog.dart index 2c6c783c..c20cb6fc 100755 --- a/lib/fido/views/rename_fingerprint_dialog.dart +++ b/lib/fido/views/rename_fingerprint_dialog.dart @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Yubico. + * Copyright (C) 2022-2024 Yubico. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,12 +41,20 @@ class RenameFingerprintDialog extends ConsumerStatefulWidget { class _RenameAccountDialogState extends ConsumerState { late String _label; + late FocusNode _labelFocus; _RenameAccountDialogState(); @override void initState() { super.initState(); _label = widget.fingerprint.name ?? ''; + _labelFocus = FocusNode(); + } + + @override + void dispose() { + _labelFocus.dispose(); + super.dispose(); } _submit() async { @@ -94,6 +102,7 @@ class _RenameAccountDialogState extends ConsumerState { Text(l10n.p_will_change_label_fp), AppTextFormField( initialValue: _label, + focusNode: _labelFocus, maxLength: 15, inputFormatters: [limitBytesLength(15)], buildCounter: buildByteCounterFor(_label), @@ -110,6 +119,8 @@ class _RenameAccountDialogState extends ConsumerState { onFieldSubmitted: (_) { if (_label.isNotEmpty) { _submit(); + } else { + _labelFocus.requestFocus(); } }, ).init(),