mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-23 18:58:29 +03:00
55 lines
1.5 KiB
Dart
Executable File
55 lines
1.5 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../app/models.dart';
|
|
import '../app/state.dart';
|
|
import 'state.dart';
|
|
import 'views/add_account_page.dart';
|
|
import 'views/password_dialog.dart';
|
|
import 'views/reset_dialog.dart';
|
|
|
|
List<MenuAction> buildOathMenuActions(AutoDisposeProviderRef ref) {
|
|
final device = ref.watch(currentDeviceProvider);
|
|
if (device != null) {
|
|
final state = ref.watch(oathStateProvider(device.path));
|
|
if (state != null) {
|
|
return [
|
|
if (!state.locked)
|
|
MenuAction(
|
|
text: 'Add credential',
|
|
icon: const Icon(Icons.add),
|
|
action: (context) {
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
builder: (context) => OathAddAccountPage(device: device),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
if (!state.locked)
|
|
MenuAction(
|
|
text: 'Manage password',
|
|
icon: const Icon(Icons.password),
|
|
action: (context) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => ManagePasswordDialog(device),
|
|
);
|
|
},
|
|
),
|
|
MenuAction(
|
|
text: 'Factory reset',
|
|
icon: const Icon(Icons.delete_forever),
|
|
action: (context) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => ResetDialog(device),
|
|
);
|
|
},
|
|
),
|
|
];
|
|
}
|
|
}
|
|
return [];
|
|
}
|