2021-12-02 13:44:17 +03:00
|
|
|
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';
|
2021-12-08 13:20:04 +03:00
|
|
|
import 'views/password_dialog.dart';
|
2022-01-21 13:30:14 +03:00
|
|
|
import 'views/reset_dialog.dart';
|
2021-12-02 13:44:17 +03:00
|
|
|
|
2022-02-08 17:40:26 +03:00
|
|
|
List<MenuAction> buildOathMenuActions(AutoDisposeProviderRef ref) {
|
2021-12-02 13:44:17 +03:00
|
|
|
final device = ref.watch(currentDeviceProvider);
|
|
|
|
if (device != null) {
|
|
|
|
final state = ref.watch(oathStateProvider(device.path));
|
2022-03-09 19:47:50 +03:00
|
|
|
return state.whenOrNull(
|
|
|
|
success: (oathState) => [
|
|
|
|
if (!oathState.locked) ...[
|
|
|
|
MenuAction(
|
|
|
|
text: 'Add credential',
|
|
|
|
icon: const Icon(Icons.add),
|
|
|
|
action: (context) {
|
2022-03-15 20:04:26 +03:00
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) =>
|
|
|
|
OathAddAccountPage(device: device),
|
2022-03-09 19:47:50 +03:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
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),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]) ??
|
|
|
|
[];
|
2021-12-02 13:44:17 +03:00
|
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|