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));
|
|
|
|
if (state != null) {
|
|
|
|
return [
|
|
|
|
if (!state.locked)
|
|
|
|
MenuAction(
|
|
|
|
text: 'Add credential',
|
|
|
|
icon: const Icon(Icons.add),
|
2022-02-08 17:40:26 +03:00
|
|
|
action: (context) {
|
2021-12-02 13:44:17 +03:00
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => OathAddAccountPage(device: device),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2021-12-08 13:20:04 +03:00
|
|
|
if (!state.locked)
|
|
|
|
MenuAction(
|
|
|
|
text: 'Manage password',
|
|
|
|
icon: const Icon(Icons.password),
|
2022-02-08 17:40:26 +03:00
|
|
|
action: (context) {
|
2021-12-08 13:20:04 +03:00
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => ManagePasswordDialog(device),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2021-12-02 13:44:17 +03:00
|
|
|
MenuAction(
|
|
|
|
text: 'Factory reset',
|
|
|
|
icon: const Icon(Icons.delete_forever),
|
2022-02-08 17:40:26 +03:00
|
|
|
action: (context) {
|
2022-01-21 13:30:14 +03:00
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => ResetDialog(device),
|
|
|
|
);
|
2021-12-02 13:44:17 +03:00
|
|
|
},
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|