mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 08:22:16 +03:00
Use one global key for search field
This commit is contained in:
parent
832051932c
commit
1495dd0f9e
@ -24,8 +24,6 @@ import 'package:window_manager/window_manager.dart';
|
||||
import '../about_page.dart';
|
||||
import '../core/state.dart';
|
||||
import '../desktop/state.dart';
|
||||
import '../fido/keys.dart';
|
||||
import '../oath/keys.dart';
|
||||
import 'message.dart';
|
||||
import 'models.dart';
|
||||
import 'state.dart';
|
||||
@ -131,17 +129,11 @@ class GlobalShortcuts extends ConsumerWidget {
|
||||
return null;
|
||||
}),
|
||||
SearchIntent: CallbackAction<SearchIntent>(onInvoke: (intent) {
|
||||
// If the OATH or passkeys view doesn't have focus, but is shown, find and select the search bar.
|
||||
final accountsSearchContext = searchAccountsField.currentContext;
|
||||
if (accountsSearchContext != null) {
|
||||
if (!Navigator.of(accountsSearchContext).canPop()) {
|
||||
return Actions.maybeInvoke(accountsSearchContext, intent);
|
||||
}
|
||||
}
|
||||
final passkeysSearchContext = searchPasskeysField.currentContext;
|
||||
if (passkeysSearchContext != null) {
|
||||
if (!Navigator.of(passkeysSearchContext).canPop()) {
|
||||
return Actions.maybeInvoke(passkeysSearchContext, intent);
|
||||
// If the view doesn't have focus, but is shown, find and select the search bar.
|
||||
final searchContext = searchField.currentContext;
|
||||
if (searchContext != null) {
|
||||
if (!Navigator.of(searchContext).canPop()) {
|
||||
return Actions.maybeInvoke(searchContext, intent);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -18,6 +18,8 @@ import 'package:flutter/material.dart';
|
||||
|
||||
// global keys
|
||||
final scaffoldGlobalKey = GlobalKey<ScaffoldState>();
|
||||
// This is global so we can access it from the global Ctrl+F shortcut.
|
||||
final searchField = GlobalKey();
|
||||
|
||||
const _prefix = 'app.keys';
|
||||
const deviceInfoListTile = Key('$_prefix.device_info_list_tile');
|
||||
|
@ -21,9 +21,6 @@ const _keyAction = '$_prefix.actions';
|
||||
const _credentialAction = '$_prefix.credential.actions';
|
||||
const _fingerprintAction = '$_prefix.fingerprint.actions';
|
||||
|
||||
// This is global so we can access it from the global Ctrl+F shortcut.
|
||||
final searchPasskeysField = GlobalKey();
|
||||
|
||||
// Key actions
|
||||
const managePinAction = Key('$_keyAction.manage_pin');
|
||||
const addFingerprintAction = Key('$_keyAction.add_fingerprint');
|
||||
|
@ -30,6 +30,7 @@ import '../../app/views/action_list.dart';
|
||||
import '../../app/views/app_failure_page.dart';
|
||||
import '../../app/views/app_list_item.dart';
|
||||
import '../../app/views/app_page.dart';
|
||||
import '../../app/views/keys.dart';
|
||||
import '../../app/views/message_page.dart';
|
||||
import '../../app/views/message_page_not_initialized.dart';
|
||||
import '../../core/state.dart';
|
||||
@ -39,7 +40,6 @@ import '../../widgets/app_input_decoration.dart';
|
||||
import '../../widgets/app_text_form_field.dart';
|
||||
import '../../widgets/list_title.dart';
|
||||
import '../features.dart' as features;
|
||||
import '../keys.dart' as keys;
|
||||
import '../models.dart';
|
||||
import '../state.dart';
|
||||
import 'actions.dart';
|
||||
@ -367,7 +367,7 @@ class _FidoUnlockedPageState extends ConsumerState<_FidoUnlockedPage> {
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: AppTextFormField(
|
||||
key: keys.searchPasskeysField,
|
||||
key: searchField,
|
||||
controller: searchController,
|
||||
focusNode: searchFocus,
|
||||
// Use the default style, but with a smaller font size:
|
||||
|
@ -20,9 +20,6 @@ const _prefix = 'oath.keys';
|
||||
const _keyAction = '$_prefix.actions';
|
||||
const _accountAction = '$_prefix.account.actions';
|
||||
|
||||
// This is global so we can access it from the global Ctrl+F shortcut.
|
||||
final searchAccountsField = GlobalKey();
|
||||
|
||||
// Key actions
|
||||
const setOrManagePasswordAction =
|
||||
Key('$_keyAction.action.set_or_manage_password');
|
||||
|
@ -30,6 +30,7 @@ import '../../app/state.dart';
|
||||
import '../../app/views/action_list.dart';
|
||||
import '../../app/views/app_failure_page.dart';
|
||||
import '../../app/views/app_page.dart';
|
||||
import '../../app/views/keys.dart';
|
||||
import '../../app/views/message_page.dart';
|
||||
import '../../app/views/message_page_not_initialized.dart';
|
||||
import '../../core/state.dart';
|
||||
@ -377,7 +378,7 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: AppTextFormField(
|
||||
key: keys.searchAccountsField,
|
||||
key: searchField,
|
||||
controller: searchController,
|
||||
focusNode: searchFocus,
|
||||
// Use the default style, but with a smaller font size:
|
||||
|
Loading…
Reference in New Issue
Block a user