Add a "this device" hint
This commit is contained in:
parent
861ea5ab50
commit
fbaab3744e
@ -311,8 +311,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
case AuthentikUserSettingsChangeDialogStatus.userSettingsObtained:
|
||||
title = Text("User Settings Obtained");
|
||||
children = [Text("You can now edit your user settings.")];
|
||||
for (var key in authentikApiState.allKeys) {
|
||||
children.add(KeepOrDeleteKey(sshKey: key));
|
||||
for (var k in authentikApiState.allKeys) {
|
||||
children.add(KeepOrDeleteKey(sshKey: k, isOurKey: k == key));
|
||||
}
|
||||
|
||||
if (!authentikApiState.allKeys.contains(key)) {
|
||||
// If the key is not already in the list, add it
|
||||
children.add(KeepOrDeleteKey(sshKey: key, isOurKey: true));
|
||||
}
|
||||
|
||||
actions.add(
|
||||
@ -584,12 +589,21 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
|
||||
|
||||
class KeepOrDeleteKey extends StatelessWidget {
|
||||
final String sshKey;
|
||||
final bool isOurKey;
|
||||
|
||||
const KeepOrDeleteKey({super.key, required this.sshKey});
|
||||
const KeepOrDeleteKey({
|
||||
super.key,
|
||||
required this.sshKey,
|
||||
this.isOurKey = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final key = sshKey;
|
||||
final isKeyPreviouslyExisting = context
|
||||
.select<AuthentikUserSettingsChangeDialogState, bool>(
|
||||
(keylist) => keylist.allKeys.contains(key),
|
||||
);
|
||||
final isKeySelectedToKeep = context
|
||||
.select<AuthentikUserSettingsChangeDialogState, bool>(
|
||||
(keylist) => keylist.isKeySelectedToKeep(key),
|
||||
@ -622,14 +636,41 @@ class KeepOrDeleteKey extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
var textPush = "Keep Key";
|
||||
var textDoNotPush = "Select for Deletion";
|
||||
|
||||
if (!isKeyPreviouslyExisting) {
|
||||
textPush = "Push Key";
|
||||
textDoNotPush = "Do Not Push Key";
|
||||
}
|
||||
|
||||
Widget titleWidget = Text(title, style: TextStyle(fontSize: 25));
|
||||
|
||||
if (isOurKey) {
|
||||
titleWidget = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
titleWidget,
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Text(
|
||||
"This Device",
|
||||
style: TextStyle(fontSize: 15, color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Card(
|
||||
margin: EdgeInsets.fromLTRB(20, 20, 20, 0),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Text(title, style: TextStyle(fontSize: 25)),
|
||||
),
|
||||
Padding(padding: EdgeInsets.all(20), child: titleWidget),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(20, 0, 20, 20),
|
||||
child: Text(sshKey, style: TextStyle(fontSize: 15)),
|
||||
@ -644,20 +685,20 @@ class KeepOrDeleteKey extends StatelessWidget {
|
||||
Provider.of<AuthentikUserSettingsChangeDialogState>(
|
||||
context,
|
||||
listen: false,
|
||||
).selectKeyForDeletion(sshKey);
|
||||
).keepKey(sshKey);
|
||||
},
|
||||
style: buttonStyleDelete,
|
||||
child: Text('Select for Deletion'),
|
||||
style: buttonStyleKeep,
|
||||
child: Text(textPush),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Provider.of<AuthentikUserSettingsChangeDialogState>(
|
||||
context,
|
||||
listen: false,
|
||||
).keepKey(sshKey);
|
||||
).selectKeyForDeletion(sshKey);
|
||||
},
|
||||
style: buttonStyleKeep,
|
||||
child: Text('Keep Key'),
|
||||
style: buttonStyleDelete,
|
||||
child: Text(textDoNotPush),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user