fix: tag changed without saving
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -30,8 +29,7 @@ class PrivateKeyEditPage extends StatefulWidget {
|
||||
_PrivateKeyEditPageState createState() => _PrivateKeyEditPageState();
|
||||
}
|
||||
|
||||
class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
with AfterLayoutMixin {
|
||||
class _PrivateKeyEditPageState extends State<PrivateKeyEditPage> {
|
||||
final _nameController = TextEditingController();
|
||||
final _keyController = TextEditingController();
|
||||
final _pwdController = TextEditingController();
|
||||
@@ -40,7 +38,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
final _pwdNode = FocusNode();
|
||||
|
||||
late FocusScopeNode _focusScope;
|
||||
late PrivateKeyProvider _provider;
|
||||
final _provider = locator<PrivateKeyProvider>();
|
||||
late S _s;
|
||||
|
||||
Widget? _loading;
|
||||
@@ -48,7 +46,18 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_provider = locator<PrivateKeyProvider>();
|
||||
if (widget.pki != null) {
|
||||
_nameController.text = widget.pki!.id;
|
||||
_keyController.text = widget.pki!.key;
|
||||
} else {
|
||||
Clipboard.getData(_format).then((value) {
|
||||
if (value == null) return;
|
||||
final clipdata = value.text?.trim() ?? '';
|
||||
if (clipdata.startsWith('-----BEGIN') && clipdata.endsWith('-----')) {
|
||||
_keyController.text = clipdata;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -216,17 +225,4 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
if (widget.pki != null) {
|
||||
_nameController.text = widget.pki!.id;
|
||||
_keyController.text = widget.pki!.key;
|
||||
} else {
|
||||
final clipdata = ((await Clipboard.getData(_format))?.text ?? '').trim();
|
||||
if (clipdata.startsWith('-----BEGIN') && clipdata.endsWith('-----')) {
|
||||
_keyController.text = clipdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,14 +60,20 @@ class _PrivateKeyListState extends State<PrivateKeysListPage>
|
||||
padding: const EdgeInsets.all(13),
|
||||
itemCount: key.pkis.length,
|
||||
itemBuilder: (context, idx) {
|
||||
final item = key.pkis[idx];
|
||||
return RoundRectCard(
|
||||
ListTile(
|
||||
title: Text(key.pkis[idx].id),
|
||||
trailing: TextButton(
|
||||
onPressed: () =>
|
||||
AppRoute.keyEdit(pki: key.pkis[idx]).go(context),
|
||||
child: Text(_s.edit),
|
||||
leading: Text(
|
||||
'#$idx',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
title: Text(item.id),
|
||||
subtitle: Text(item.type ?? _s.unknown, style: grey),
|
||||
onTap: () => AppRoute.keyEdit(pki: item).go(context),
|
||||
trailing: const Icon(Icons.edit),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user