diff --git a/lib/about_page.dart b/lib/about_page.dart index 8b2b47b6..d80d368c 100755 --- a/lib/about_page.dart +++ b/lib/about_page.dart @@ -77,10 +77,12 @@ class AboutPage extends ConsumerWidget { style: TextStyle(decoration: TextDecoration.underline), ), onPressed: () { - showLicensePage( - context: context, - applicationVersion: version, - ); + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) => const LicensePage( + applicationVersion: version, + ), + settings: const RouteSettings(name: 'licenses'), + )); }, ), const Padding( diff --git a/lib/app/views/device_button.dart b/lib/app/views/device_button.dart index ad74e2a2..50dbbb40 100755 --- a/lib/app/views/device_button.dart +++ b/lib/app/views/device_button.dart @@ -48,6 +48,7 @@ class DeviceButton extends ConsumerWidget { showDialog( context: context, builder: (context) => const DevicePickerDialog(), + routeSettings: const RouteSettings(name: 'device_picker'), ); }, ), diff --git a/lib/app/views/main_drawer.dart b/lib/app/views/main_drawer.dart index c3d9f5ef..d16c12a4 100755 --- a/lib/app/views/main_drawer.dart +++ b/lib/app/views/main_drawer.dart @@ -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'), + ); }, ), ], diff --git a/lib/app/views/main_page.dart b/lib/app/views/main_page.dart index dcf9f837..36f87eea 100755 --- a/lib/app/views/main_page.dart +++ b/lib/app/views/main_page.dart @@ -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(currentDeviceDataProvider, (_, __) { + 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); diff --git a/lib/fido/views/add_fingerprint_dialog.dart b/lib/fido/views/add_fingerprint_dialog.dart index 70e6f418..4d7a8288 100755 --- a/lib/fido/views/add_fingerprint_dialog.dart +++ b/lib/fido/views/add_fingerprint_dialog.dart @@ -12,7 +12,6 @@ import '../../widgets/responsive_dialog.dart'; import '../state.dart'; import '../../fido/models.dart'; import '../../app/models.dart'; -import '../../app/state.dart'; final _log = Logger('fido.views.add_fingerprint_dialog'); @@ -119,12 +118,6 @@ class _AddFingerprintDialogState extends ConsumerState @override Widget build(BuildContext context) { - // If current device changes, we need to pop back to the main Page. - ref.listen(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( diff --git a/lib/fido/views/delete_credential_dialog.dart b/lib/fido/views/delete_credential_dialog.dart index 873b8c39..53835a90 100755 --- a/lib/fido/views/delete_credential_dialog.dart +++ b/lib/fido/views/delete_credential_dialog.dart @@ -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(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(false); - }); - final label = credential.userName; return ResponsiveDialog( diff --git a/lib/fido/views/delete_fingerprint_dialog.dart b/lib/fido/views/delete_fingerprint_dialog.dart index 624538af..f0a04232 100755 --- a/lib/fido/views/delete_fingerprint_dialog.dart +++ b/lib/fido/views/delete_fingerprint_dialog.dart @@ -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(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(false); - }); - final label = fingerprint.label; return ResponsiveDialog( diff --git a/lib/fido/views/pin_dialog.dart b/lib/fido/views/pin_dialog.dart index 08d11a02..96cc2b43 100755 --- a/lib/fido/views/pin_dialog.dart +++ b/lib/fido/views/pin_dialog.dart @@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../app/message.dart'; import '../../app/models.dart'; -import '../../app/state.dart'; import '../../widgets/responsive_dialog.dart'; import '../models.dart'; import '../state.dart'; @@ -28,11 +27,6 @@ class _FidoPinDialogState extends ConsumerState { @override Widget build(BuildContext context) { - // If current device changes, we need to pop back to the main Page. - ref.listen(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(); - }); - final hasPin = widget.state.hasPin; final isValid = _newPin.isNotEmpty && _newPin == _confirmPin && diff --git a/lib/fido/views/rename_fingerprint_dialog.dart b/lib/fido/views/rename_fingerprint_dialog.dart index e5c43ac7..81e9a098 100755 --- a/lib/fido/views/rename_fingerprint_dialog.dart +++ b/lib/fido/views/rename_fingerprint_dialog.dart @@ -6,7 +6,6 @@ import '../../widgets/responsive_dialog.dart'; import '../models.dart'; import '../state.dart'; import '../../app/models.dart'; -import '../../app/state.dart'; class RenameFingerprintDialog extends ConsumerStatefulWidget { final DevicePath devicePath; @@ -39,11 +38,6 @@ class _RenameAccountDialogState extends ConsumerState { @override Widget build(BuildContext context) { - // If current device changes, we need to pop back to the main Page. - ref.listen(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(); - }); - return ResponsiveDialog( title: const Text('Rename fingerprint'), actions: [ diff --git a/lib/fido/views/reset_dialog.dart b/lib/fido/views/reset_dialog.dart index f86b207d..bb5942d9 100755 --- a/lib/fido/views/reset_dialog.dart +++ b/lib/fido/views/reset_dialog.dart @@ -11,7 +11,6 @@ import '../../widgets/responsive_dialog.dart'; import '../state.dart'; import '../../fido/models.dart'; import '../../app/models.dart'; -import '../../app/state.dart'; final _log = Logger('fido.views.reset_dialog'); @@ -47,12 +46,6 @@ class _ResetDialogState extends ConsumerState { @override Widget build(BuildContext context) { - // If current device changes, we need to pop back to the main Page. - ref.listen(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: () { diff --git a/lib/management/views/management_screen.dart b/lib/management/views/management_screen.dart index 126bd516..f8f80349 100755 --- a/lib/management/views/management_screen.dart +++ b/lib/management/views/management_screen.dart @@ -4,7 +4,6 @@ import 'package:collection/collection.dart'; import '../../app/message.dart'; import '../../app/models.dart'; -import '../../app/state.dart'; import '../../app/views/app_loading_screen.dart'; import '../../core/models.dart'; import '../../widgets/custom_icons.dart'; @@ -232,11 +231,6 @@ class _ManagementScreenState extends ConsumerState { @override Widget build(BuildContext context) { - ref.listen(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( diff --git a/lib/oath/views/account_dialog.dart b/lib/oath/views/account_dialog.dart index bc000e3e..ce4974c2 100755 --- a/lib/oath/views/account_dialog.dart +++ b/lib/oath/views/account_dialog.dart @@ -93,6 +93,13 @@ class AccountDialog extends ConsumerWidget with AccountMixin { @override Widget build(BuildContext context, WidgetRef ref) { + // TODO: Solve this in a cleaner way + if (ref.watch(currentDeviceDataProvider) == null) { + // The rest of this method assumes there is a device, and will throw an exception if not. + // This will never be shown, as the dialog will be immediately closed + return const SizedBox(); + } + final code = getCode(ref); if (code == null) { if (isDesktop) { diff --git a/lib/oath/views/add_account_page.dart b/lib/oath/views/add_account_page.dart index 756ba4c1..ac870745 100755 --- a/lib/oath/views/add_account_page.dart +++ b/lib/oath/views/add_account_page.dart @@ -97,12 +97,6 @@ class _OathAddAccountPageState extends ConsumerState { @override Widget build(BuildContext context) { - // If current device changes, we need to pop back to the main Page. - ref.listen(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, @@ -206,7 +200,7 @@ class _OathAddAccountPageState extends ConsumerState { border: OutlineInputBorder(), labelText: 'Account name', helperText: '', // Prevents dialog resizing when enabled = false - prefixIcon: Icon(Icons.people_alt_outlined), + prefixIcon: Icon(Icons.person_outline), ), onChanged: (value) { setState(() { diff --git a/lib/oath/views/delete_account_dialog.dart b/lib/oath/views/delete_account_dialog.dart index c559ad49..93f392ef 100755 --- a/lib/oath/views/delete_account_dialog.dart +++ b/lib/oath/views/delete_account_dialog.dart @@ -16,11 +16,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(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(false); - }); - final label = credential.issuer != null ? '${credential.issuer} (${credential.name})' : credential.name; diff --git a/lib/oath/views/manage_password_dialog.dart b/lib/oath/views/manage_password_dialog.dart index 9074917a..ce25ffb3 100755 --- a/lib/oath/views/manage_password_dialog.dart +++ b/lib/oath/views/manage_password_dialog.dart @@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../app/message.dart'; import '../../app/models.dart'; -import '../../app/state.dart'; import '../../widgets/responsive_dialog.dart'; import '../models.dart'; import '../state.dart'; @@ -41,11 +40,6 @@ class _ManagePasswordDialogState extends ConsumerState { @override Widget build(BuildContext context) { - // If current device changes, we need to pop back to the main Page. - ref.listen(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(); - }); - final isValid = _newPassword.isNotEmpty && _newPassword == _confirmPassword && (!widget.state.hasKey || _currentPassword.isNotEmpty); diff --git a/lib/oath/views/oath_screen.dart b/lib/oath/views/oath_screen.dart index 43a3b525..0be28141 100755 --- a/lib/oath/views/oath_screen.dart +++ b/lib/oath/views/oath_screen.dart @@ -257,7 +257,6 @@ class _UnlockFormState extends ConsumerState<_UnlockForm> { void _submit() async { setState(() { _passwordIsWrong = false; - _isObscure = false; }); final result = await ref .read(oathStateProvider(widget._devicePath).notifier) diff --git a/lib/oath/views/rename_account_dialog.dart b/lib/oath/views/rename_account_dialog.dart index 90b0d80b..5f2517cc 100755 --- a/lib/oath/views/rename_account_dialog.dart +++ b/lib/oath/views/rename_account_dialog.dart @@ -33,11 +33,6 @@ class _RenameAccountDialogState extends ConsumerState { @override Widget build(BuildContext context) { - // If current device changes, we need to pop back to the main Page. - ref.listen(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(); - }); - final credential = widget.credential; final label = credential.issuer != null diff --git a/lib/oath/views/reset_dialog.dart b/lib/oath/views/reset_dialog.dart index 8b5030ed..874d58e4 100755 --- a/lib/oath/views/reset_dialog.dart +++ b/lib/oath/views/reset_dialog.dart @@ -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(currentDeviceProvider, (previous, next) { - Navigator.of(context).pop(); - }); - return ResponsiveDialog( title: const Text('Factory reset'), actions: [