mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 08:22:16 +03:00
Merge PR #51.
This commit is contained in:
commit
e721d8fe74
@ -4,7 +4,7 @@ import '../../management/models.dart';
|
||||
|
||||
part 'models.freezed.dart';
|
||||
|
||||
enum SubPage { authenticator, yubikey }
|
||||
enum SubPage { oath, fido, otp, piv, management }
|
||||
|
||||
@freezed
|
||||
class YubiKeyData with _$YubiKeyData {
|
||||
|
@ -107,7 +107,7 @@ class CurrentDeviceNotifier extends StateNotifier<DeviceNode?> {
|
||||
}
|
||||
|
||||
final subPageProvider = StateNotifierProvider<SubPageNotifier, SubPage>(
|
||||
(ref) => SubPageNotifier(SubPage.authenticator));
|
||||
(ref) => SubPageNotifier(SubPage.oath));
|
||||
|
||||
class SubPageNotifier extends StateNotifier<SubPage> {
|
||||
SubPageNotifier(SubPage state) : super(state);
|
||||
@ -119,13 +119,12 @@ class SubPageNotifier extends StateNotifier<SubPage> {
|
||||
|
||||
final menuActionsProvider = Provider.autoDispose<List<MenuAction>>((ref) {
|
||||
switch (ref.watch(subPageProvider)) {
|
||||
case SubPage.authenticator:
|
||||
case SubPage.oath:
|
||||
return buildOathMenuActions(ref);
|
||||
case SubPage.yubikey:
|
||||
// TODO: Handle this case.
|
||||
break;
|
||||
// TODO: Handle other cases.
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
abstract class QrScanner {
|
||||
|
@ -11,10 +11,8 @@ class DeviceInfoScreen extends StatelessWidget {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text('YubiKey: ${device.name}'),
|
||||
Text('Serial: ${device.info.serial}'),
|
||||
Text('Version: ${device.info.version}'),
|
||||
children: const [
|
||||
Text('This page intentionally left blank (for now)'),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -9,10 +9,16 @@ import '../state.dart';
|
||||
extension on SubPage {
|
||||
String get displayName {
|
||||
switch (this) {
|
||||
case SubPage.authenticator:
|
||||
case SubPage.oath:
|
||||
return 'Authenticator';
|
||||
case SubPage.yubikey:
|
||||
return 'YubiKey';
|
||||
case SubPage.fido:
|
||||
return 'WebAuthn';
|
||||
case SubPage.otp:
|
||||
return 'One-Time Passwords';
|
||||
case SubPage.piv:
|
||||
return 'Certificates';
|
||||
case SubPage.management:
|
||||
return 'Toggle applications';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -22,10 +28,16 @@ class MainPageDrawer extends ConsumerWidget {
|
||||
|
||||
IconData _iconFor(SubPage page) {
|
||||
switch (page) {
|
||||
case SubPage.authenticator:
|
||||
case SubPage.oath:
|
||||
return Icons.supervisor_account;
|
||||
default:
|
||||
return Icons.miscellaneous_services;
|
||||
case SubPage.fido:
|
||||
return Icons.security;
|
||||
case SubPage.otp:
|
||||
return Icons.password;
|
||||
case SubPage.piv:
|
||||
return Icons.approval;
|
||||
case SubPage.management:
|
||||
return Icons.construction;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +45,8 @@ class MainPageDrawer extends ConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final currentSubPage = ref.watch(subPageProvider);
|
||||
|
||||
final mainPages = [SubPage.oath, SubPage.fido, SubPage.otp, SubPage.piv];
|
||||
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
primary: false, //Prevents conflict with the MainPage scroll view.
|
||||
@ -44,7 +58,7 @@ class MainPageDrawer extends ConsumerWidget {
|
||||
style: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
),
|
||||
...[SubPage.authenticator].map((page) => DrawerItem(
|
||||
...mainPages.map((page) => DrawerItem(
|
||||
titleText: page.displayName,
|
||||
icon: Icon(_iconFor(page)),
|
||||
selected: page == currentSubPage,
|
||||
@ -55,28 +69,6 @@ class MainPageDrawer extends ConsumerWidget {
|
||||
}
|
||||
: null,
|
||||
)),
|
||||
// PLACEHOLDERS
|
||||
DrawerItem(
|
||||
titleText: 'WebAuthn',
|
||||
icon: const Icon(Icons.security),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
DrawerItem(
|
||||
titleText: 'One-Time Passwords',
|
||||
icon: const Icon(Icons.password),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
DrawerItem(
|
||||
titleText: 'Certificates',
|
||||
icon: const Icon(Icons.approval),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
const Divider(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@ -85,10 +77,13 @@ class MainPageDrawer extends ConsumerWidget {
|
||||
style: Theme.of(context).textTheme.bodyText2,
|
||||
),
|
||||
),
|
||||
// PLACEHOLDER
|
||||
DrawerItem(
|
||||
titleText: 'Toggle applications',
|
||||
icon: const Icon(Icons.construction),
|
||||
icon: Icon(_iconFor(SubPage.management)),
|
||||
selected: SubPage.management == currentSubPage,
|
||||
onTap: () {
|
||||
ref.read(subPageProvider.notifier).setSubPage(SubPage.management);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
|
@ -20,9 +20,9 @@ class MainPage extends ConsumerWidget {
|
||||
}
|
||||
// TODO: If page not supported by device, do something?
|
||||
switch (subPage) {
|
||||
case SubPage.authenticator:
|
||||
case SubPage.oath:
|
||||
return OathScreen(device);
|
||||
case SubPage.yubikey:
|
||||
default:
|
||||
return DeviceInfoScreen(device);
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,13 @@ class AccountView extends ConsumerWidget {
|
||||
?.copyWith(color: Colors.grey)
|
||||
: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
subtitle: Text(label, style: Theme.of(context).textTheme.caption),
|
||||
subtitle: Text(
|
||||
label,
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
overflow: TextOverflow.fade,
|
||||
maxLines: 1,
|
||||
softWrap: false,
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
Loading…
Reference in New Issue
Block a user