Merge branch 'main' into fix/android-nfc

This commit is contained in:
Adam Velebil 2022-06-13 10:32:20 +02:00
commit c357522e6a
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084
18 changed files with 35 additions and 77 deletions

View File

@ -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(

View File

@ -48,6 +48,7 @@ class DeviceButton extends ConsumerWidget {
showDialog(
context: context,
builder: (context) => const DevicePickerDialog(),
routeSettings: const RouteSettings(name: 'device_picker'),
);
},
),

View File

@ -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'),
);
},
),
],

View File

@ -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<YubiKeyData?>(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);

View File

@ -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<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(

View File

@ -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(

View File

@ -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(

View File

@ -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<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 &&

View File

@ -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<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: [

View File

@ -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<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: () {

View File

@ -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<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(

View File

@ -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) {

View File

@ -97,12 +97,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,
@ -206,7 +200,7 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
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(() {

View File

@ -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<DeviceNode?>(currentDeviceProvider, (previous, next) {
Navigator.of(context).pop(false);
});
final label = credential.issuer != null
? '${credential.issuer} (${credential.name})'
: credential.name;

View File

@ -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<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);

View File

@ -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)

View File

@ -33,11 +33,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

View File

@ -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: [