added show/hide password buttons
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-03-21 17:56:31 -05:00
parent f5b912b16f
commit 1cc3e6baf0
2 changed files with 96 additions and 52 deletions

View File

@ -347,7 +347,7 @@ Future<String?> promptPassword() async {
obscuringCharacter: '*', obscuringCharacter: '*',
onChanged: (value) => password = value, onChanged: (value) => password = value,
), ),
title: const Text('Enter Authentication Password'), title: const Text('Enter Repertory Portal Password'),
); );
}, },
); );

View File

@ -161,63 +161,107 @@ void createPasswordSetting(
onPressed: (_) { onPressed: (_) {
String updatedValue1 = value; String updatedValue1 = value;
String updatedValue2 = value; String updatedValue2 = value;
bool hidePassword1 = true;
bool hidePassword2 = true;
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return AlertDialog( return StatefulBuilder(
actions: [ builder: (context, setDialogState) {
TextButton( return AlertDialog(
child: const Text('Cancel'), actions: [
onPressed: () => Navigator.of(context).pop(), TextButton(
), child: const Text('Cancel'),
TextButton( onPressed: () => Navigator.of(context).pop(),
child: const Text('OK'), ),
onPressed: () { TextButton(
if (updatedValue1 != updatedValue2) { child: const Text('OK'),
return displayErrorMessage( onPressed: () {
context, if (updatedValue1 != updatedValue2) {
"Setting '$key' does not match", return displayErrorMessage(
); context,
} "Setting '$key' does not match",
);
}
final result = validators.firstWhereOrNull( final result = validators.firstWhereOrNull(
(validator) => !validator(updatedValue1), (validator) => !validator(updatedValue1),
); );
if (result != null) { if (result != null) {
return displayErrorMessage( return displayErrorMessage(
context, context,
"Setting '$key' is not valid", "Setting '$key' is not valid",
); );
} }
setState(() => settings[key] = updatedValue1); setState(() => settings[key] = updatedValue1);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),
], ],
content: Column( content: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
TextField( Row(
autofocus: true, children: [
controller: TextEditingController(text: updatedValue1), Expanded(
obscureText: true, child: TextField(
obscuringCharacter: '*', autofocus: true,
onChanged: (value) => updatedValue1 = value, controller: TextEditingController(
text: updatedValue1,
),
obscureText: hidePassword1,
obscuringCharacter: '*',
onChanged: (value) => updatedValue1 = value,
),
),
IconButton(
onPressed:
() => setDialogState(
() => hidePassword1 = !hidePassword1,
),
icon: Icon(
hidePassword1
? Icons.visibility
: Icons.visibility_off,
),
),
],
),
const SizedBox(height: constants.padding),
Row(
children: [
Expanded(
child: TextField(
autofocus: false,
controller: TextEditingController(
text: updatedValue2,
),
obscureText: hidePassword2,
obscuringCharacter: '*',
onChanged: (value) => updatedValue2 = value,
),
),
IconButton(
onPressed:
() => setDialogState(
() => hidePassword2 = !hidePassword2,
),
icon: Icon(
hidePassword2
? Icons.visibility
: Icons.visibility_off,
),
),
],
),
],
), ),
const SizedBox(height: constants.padding), title: createSettingTitle(context, key, description),
TextField( );
autofocus: false, },
controller: TextEditingController(text: updatedValue2),
obscureText: true,
obscuringCharacter: '*',
onChanged: (value) => updatedValue2 = value,
),
],
),
title: createSettingTitle(context, key, description),
); );
}, },
); );