import 'package:proxmox_dart_api_client/proxmox_dart_api_client.dart'
as proxclient;
import 'package:proxmox_login_manager/extension.dart';
+import 'package:proxmox_login_manager/proxmox_password_store.dart';
typedef OnLoginCallback = Function(proxclient.ProxmoxApiClient client);
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
+ backgroundColor: Theme.of(context).colorScheme.background,
appBar: AppBar(
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
),
),
),
- ...logins.where((b) => !b.activeSession).map((l) => ListTile(
- title: Text(l.fullHostname),
- subtitle: Text(l.fullUsername),
+ ...logins.where((b) => !b.activeSession).map((login) =>
+ ListTile(
+ title: Text(login.fullHostname),
+ subtitle: Text(login.fullUsername),
trailing: Icon(Icons.navigate_next),
leading: PopupMenuButton(
itemBuilder: (context) => [
+ if (login.passwordSaved ?? false)
+ PopupMenuItem(
+ child: ListTile(
+ dense: true,
+ leading: Icon(Icons.key_off),
+ title: Text('Delete Password'),
+ onTap: () async {
+ await deletePassword(login.identifier!);
+
+ await snapshot.data!
+ .rebuild((b) => b
+ ..logins.rebuildWhere(
+ (m) => m == login,
+ (b) =>
+ b..passwordSaved = false))
+ .saveToDisk();
+ refreshFromStorage();
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
PopupMenuItem(
child: ListTile(
dense: true,
leading: Icon(Icons.delete),
title: Text('Delete'),
onTap: () async {
+ await deletePassword(login.identifier!);
await snapshot.data!
- .rebuild((b) => b.logins.remove(l))
+ .rebuild(
+ (b) => b.logins.remove(login))
.saveToDisk();
refreshFromStorage();
Navigator.of(context).pop();
),
),
]),
- onTap: () => _login(user: l),
+ onTap: () => _login(user: login),
))
]);
return ListView(
}
Future<void> _login({ProxmoxLoginModel? user, bool isCreate = false}) async {
+ String? password;
+ String ticket = user?.ticket ?? '';
+ bool passwordSaved = user != null && (user.passwordSaved ?? false);
+
+ if (ticket == '' && passwordSaved) {
+ password = await getPassword(user.identifier!);
+ }
+
final client = await Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ProxmoxLoginPage(
userModel: user,
isCreate: isCreate,
ticket: user?.ticket,
+ password: password,
)));
refreshFromStorage();
if (client != null) {