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';
|
2021-12-02 13:44:17 +03:00
|
|
|
|
|
|
|
List<MenuAction> buildOathMenuActions(
|
|
|
|
BuildContext context, 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: () {
|
|
|
|
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),
|
|
|
|
action: () {
|
|
|
|
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),
|
|
|
|
action: () {
|
|
|
|
ScaffoldMessenger.of(context)
|
|
|
|
..clearSnackBars()
|
|
|
|
..showSnackBar(
|
|
|
|
const SnackBar(
|
|
|
|
content: Text('Not implemented'),
|
|
|
|
duration: Duration(seconds: 2),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|