Make KeepOrDeleteKey Widget stateless
This commit is contained in:
parent
b099cab718
commit
b104cd584e
@ -464,23 +464,14 @@ class SSHKeyList extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
class KeepOrDeleteKey extends StatefulWidget {
|
||||
class KeepOrDeleteKey extends StatelessWidget {
|
||||
final String sshKey;
|
||||
|
||||
const KeepOrDeleteKey({super.key, required this.sshKey});
|
||||
|
||||
@override
|
||||
State<KeepOrDeleteKey> createState() => _KeepOrDeleteKeyState();
|
||||
}
|
||||
|
||||
class _KeepOrDeleteKeyState extends State<KeepOrDeleteKey> {
|
||||
bool _selectedForDeletion = false;
|
||||
|
||||
bool get selectedForDeletion => _selectedForDeletion;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final key = widget.sshKey;
|
||||
final key = sshKey;
|
||||
final isKeySelectedToKeep = context.select<SSHKeyList, bool>(
|
||||
(keylist) => keylist.isKeySelectedToKeep(key),
|
||||
);
|
||||
@ -504,7 +495,7 @@ class _KeepOrDeleteKeyState extends State<KeepOrDeleteKey> {
|
||||
}
|
||||
|
||||
var title = "Unnamed Key";
|
||||
final sshKeySplit = widget.sshKey.split(' ');
|
||||
final sshKeySplit = sshKey.split(' ');
|
||||
if (sshKeySplit.length >= 3) {
|
||||
final potentialTitle = sshKeySplit.sublist(2).join(' ');
|
||||
if (potentialTitle != "") {
|
||||
@ -522,7 +513,7 @@ class _KeepOrDeleteKeyState extends State<KeepOrDeleteKey> {
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 0, 20, 20),
|
||||
child: Text(widget.sshKey, style: TextStyle(fontSize: 15)),
|
||||
child: Text(sshKey, style: TextStyle(fontSize: 15)),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 0, 20, 20),
|
||||
@ -531,26 +522,20 @@ class _KeepOrDeleteKeyState extends State<KeepOrDeleteKey> {
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedForDeletion = true;
|
||||
Provider.of<SSHKeyList>(
|
||||
context,
|
||||
listen: false,
|
||||
).selectKeyForDeletion(widget.sshKey);
|
||||
});
|
||||
Provider.of<SSHKeyList>(
|
||||
context,
|
||||
listen: false,
|
||||
).selectKeyForDeletion(sshKey);
|
||||
},
|
||||
style: buttonStyleDelete,
|
||||
child: Text('Select for Deletion'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedForDeletion = false;
|
||||
Provider.of<SSHKeyList>(
|
||||
context,
|
||||
listen: false,
|
||||
).keepKey(widget.sshKey);
|
||||
});
|
||||
Provider.of<SSHKeyList>(
|
||||
context,
|
||||
listen: false,
|
||||
).keepKey(sshKey);
|
||||
},
|
||||
style: buttonStyleKeep,
|
||||
child: Text('Keep Key'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user