mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 08:22:16 +03:00
Pop dialogs by default when device changes.
This commit is contained in:
parent
3a485b9cf6
commit
141fa419e4
@ -77,10 +77,12 @@ class AboutPage extends ConsumerWidget {
|
||||
style: TextStyle(decoration: TextDecoration.underline),
|
||||
),
|
||||
onPressed: () {
|
||||
showLicensePage(
|
||||
context: context,
|
||||
applicationVersion: version,
|
||||
);
|
||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const LicensePage(
|
||||
applicationVersion: version,
|
||||
),
|
||||
settings: const RouteSettings(name: 'licenses'),
|
||||
));
|
||||
},
|
||||
),
|
||||
const Padding(
|
||||
|
@ -48,6 +48,7 @@ class DeviceButton extends ConsumerWidget {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => const DevicePickerDialog(),
|
||||
routeSettings: const RouteSettings(name: 'device_picker'),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -93,7 +93,10 @@ class MainPageDrawer extends ConsumerWidget {
|
||||
final nav = Navigator.of(context);
|
||||
if (shouldPop) nav.pop();
|
||||
showDialog(
|
||||
context: context, builder: (context) => const SettingsPage());
|
||||
context: context,
|
||||
builder: (context) => const SettingsPage(),
|
||||
routeSettings: const RouteSettings(name: 'settings'),
|
||||
);
|
||||
},
|
||||
),
|
||||
DrawerItem(
|
||||
@ -103,7 +106,10 @@ class MainPageDrawer extends ConsumerWidget {
|
||||
final nav = Navigator.of(context);
|
||||
if (shouldPop) nav.pop();
|
||||
showDialog(
|
||||
context: context, builder: (context) => const AboutPage());
|
||||
context: context,
|
||||
builder: (context) => const AboutPage(),
|
||||
routeSettings: const RouteSettings(name: 'about'),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -20,6 +20,18 @@ class MainPage extends ConsumerWidget {
|
||||
next?.call(context);
|
||||
},
|
||||
);
|
||||
// If the current device changes, we need to pop any open dialogs.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (_, __) {
|
||||
Navigator.of(context).popUntil((route) {
|
||||
return route.isFirst ||
|
||||
[
|
||||
'device_picker',
|
||||
'settings',
|
||||
'about',
|
||||
'licenses',
|
||||
].contains(route.settings.name);
|
||||
});
|
||||
});
|
||||
final deviceData = ref.watch(currentDeviceDataProvider);
|
||||
if (deviceData == null) {
|
||||
final node = ref.watch(currentDeviceProvider);
|
||||
|
@ -119,12 +119,6 @@ class _AddFingerprintDialogState extends ConsumerState<AddFingerprintDialog>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
// Prevent over-popping if reset causes currentDevice to change.
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
});
|
||||
|
||||
final progress = _samples == 0 ? 0.0 : _samples / (_samples + _remaining);
|
||||
|
||||
return ResponsiveDialog(
|
||||
|
@ -17,11 +17,6 @@ class DeleteCredentialDialog extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
Navigator.of(context).pop(false);
|
||||
});
|
||||
|
||||
final label = credential.userName;
|
||||
|
||||
return ResponsiveDialog(
|
||||
|
@ -15,11 +15,6 @@ class DeleteFingerprintDialog extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
Navigator.of(context).pop(false);
|
||||
});
|
||||
|
||||
final label = fingerprint.label;
|
||||
|
||||
return ResponsiveDialog(
|
||||
|
@ -28,11 +28,6 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
|
||||
final hasPin = widget.state.hasPin;
|
||||
final isValid = _newPin.isNotEmpty &&
|
||||
_newPin == _confirmPin &&
|
||||
|
@ -39,11 +39,6 @@ class _RenameAccountDialogState extends ConsumerState<RenameFingerprintDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
|
||||
return ResponsiveDialog(
|
||||
title: const Text('Rename fingerprint'),
|
||||
actions: [
|
||||
|
@ -47,12 +47,6 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
// Prevent over-popping if reset causes currentDevice to change.
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
});
|
||||
|
||||
return ResponsiveDialog(
|
||||
title: const Text('Factory reset'),
|
||||
onCancel: () {
|
||||
|
@ -232,11 +232,6 @@ class _ManagementScreenState extends ConsumerState<ManagementScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (_, __) {
|
||||
//TODO: This can probably be checked better to make sure it's the main page.
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
});
|
||||
|
||||
var canSave = false;
|
||||
final child =
|
||||
ref.watch(managementStateProvider(widget.deviceData.node.path)).when(
|
||||
|
@ -96,12 +96,6 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
//TODO: This can probably be checked better to make sure it's the main page.
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
});
|
||||
|
||||
final period = int.tryParse(_periodController.text) ?? -1;
|
||||
final remaining = getRemainingKeySpace(
|
||||
oathType: _oathType,
|
||||
|
@ -15,11 +15,6 @@ class DeleteAccountDialog extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
Navigator.of(context).pop(false);
|
||||
});
|
||||
|
||||
final label = credential.issuer != null
|
||||
? '${credential.issuer} (${credential.name})'
|
||||
: credential.name;
|
||||
|
@ -41,11 +41,6 @@ class _ManagePasswordDialogState extends ConsumerState<ManagePasswordDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
|
||||
final isValid = _newPassword.isNotEmpty &&
|
||||
_newPassword == _confirmPassword &&
|
||||
(!widget.state.hasKey || _currentPassword.isNotEmpty);
|
||||
|
@ -32,11 +32,6 @@ class _RenameAccountDialogState extends ConsumerState<RenameAccountDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
|
||||
final credential = widget.credential;
|
||||
|
||||
final label = credential.issuer != null
|
||||
|
@ -13,11 +13,6 @@ class ResetDialog extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// If current device changes, we need to pop back to the main Page.
|
||||
ref.listen<DeviceNode?>(currentDeviceProvider, (previous, next) {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
|
||||
return ResponsiveDialog(
|
||||
title: const Text('Factory reset'),
|
||||
actions: [
|
||||
|
Loading…
Reference in New Issue
Block a user