mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-24 18:52:55 +03:00
Add workaround for device picker losing focus on device change.
This commit is contained in:
parent
38528c81ae
commit
f81d2d06bc
@ -40,9 +40,48 @@ class _HiddenDevicesNotifier extends StateNotifier<List<String>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DevicePickerDialog extends ConsumerWidget {
|
class DevicePickerDialog extends StatefulWidget {
|
||||||
const DevicePickerDialog({super.key});
|
const DevicePickerDialog({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => _DevicePickerDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DevicePickerDialogState extends State<DevicePickerDialog> {
|
||||||
|
late FocusScopeNode _focus;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_focus = FocusScopeNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_focus.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// This keeps the focus in the dialog, even if the underlying page
|
||||||
|
// changes as it does when a new device is selected.
|
||||||
|
return FocusScope(
|
||||||
|
node: _focus,
|
||||||
|
autofocus: true,
|
||||||
|
onFocusChange: (focused) {
|
||||||
|
if (!focused) {
|
||||||
|
_focus.requestFocus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const _DevicePickerContent(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DevicePickerContent extends ConsumerWidget {
|
||||||
|
const _DevicePickerContent();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final hidden = ref.watch(_hiddenDevicesProvider);
|
final hidden = ref.watch(_hiddenDevicesProvider);
|
||||||
|
Loading…
Reference in New Issue
Block a user