yubioath-flutter/lib/app/views/main_page.dart

45 lines
1.3 KiB
Dart
Raw Normal View History

2021-11-24 10:44:28 +03:00
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'message_page.dart';
2021-11-24 10:44:28 +03:00
import 'no_device_screen.dart';
import '../models.dart';
import '../state.dart';
2022-03-15 19:16:14 +03:00
import '../../fido/views/fido_screen.dart';
2021-11-24 10:44:28 +03:00
import '../../oath/views/oath_screen.dart';
2022-03-04 15:42:10 +03:00
import '../../management/views/management_screen.dart';
2021-11-24 10:44:28 +03:00
class MainPage extends ConsumerWidget {
const MainPage({Key? key}) : super(key: key);
2021-11-24 10:44:28 +03:00
@override
Widget build(BuildContext context, WidgetRef ref) {
final deviceData = ref.watch(currentDeviceDataProvider);
if (deviceData == null) {
final node = ref.watch(currentDeviceProvider);
return NoDeviceScreen(node);
}
final app = ref.watch(currentAppProvider);
if (app.getAvailability(deviceData) != Availability.enabled) {
return const MessagePage(
header: 'Application disabled',
message: 'Enable the application on your YubiKey to access',
2022-03-07 11:57:29 +03:00
);
}
switch (app) {
case Application.oath:
return OathScreen(deviceData.node.path);
case Application.management:
return ManagementScreen(deviceData);
2022-03-15 19:16:14 +03:00
case Application.fido:
return FidoScreen(deviceData);
default:
2022-04-05 13:41:35 +03:00
return const MessagePage(
header: 'Not implemented',
message: 'This section has not yet been implemented',
);
2021-11-24 10:44:28 +03:00
}
}
}