password dialog
This commit is contained in:
parent
7bf728bdad
commit
18339cf343
@ -655,7 +655,13 @@ class _ControlMenu extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate('OS Password')),
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.password_rounded, color: MyTheme.accent),
|
||||||
|
Text(translate('OS Password')).paddingOnly(left: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||||
PasswordWidget(controller: controller),
|
PasswordWidget(controller: controller),
|
||||||
CheckboxListTile(
|
CheckboxListTile(
|
||||||
@ -671,11 +677,22 @@ class _ControlMenu extends StatelessWidget {
|
|||||||
setState(() => autoLogin = v);
|
setState(() => autoLogin = v);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: Icon(Icons.close_rounded),
|
||||||
|
label: Text(translate("Cancel")),
|
||||||
|
onPressed: close,
|
||||||
|
),
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: Icon(Icons.done_rounded),
|
||||||
|
label: Text(translate("Ok")),
|
||||||
|
onPressed: submit,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).paddingOnly(top: 20)
|
||||||
]),
|
]),
|
||||||
actions: [
|
|
||||||
dialogButton('Cancel', onPressed: close, isOutline: true),
|
|
||||||
dialogButton('OK', onPressed: submit),
|
|
||||||
],
|
|
||||||
onSubmit: submit,
|
onSubmit: submit,
|
||||||
onCancel: close,
|
onCancel: close,
|
||||||
);
|
);
|
||||||
|
@ -75,64 +75,83 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate('Set your own password')),
|
title: Column(
|
||||||
content: Form(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
children: [
|
||||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
Icon(Icons.password_rounded, color: MyTheme.accent),
|
||||||
TextFormField(
|
Text(translate('Set your own password')).paddingOnly(left: 10),
|
||||||
autofocus: true,
|
],
|
||||||
obscureText: true,
|
),
|
||||||
keyboardType: TextInputType.visiblePassword,
|
content: Column(
|
||||||
decoration: InputDecoration(
|
children: [
|
||||||
labelText: translate('Password'),
|
Form(
|
||||||
),
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
controller: p0,
|
child: Column(
|
||||||
validator: (v) {
|
mainAxisSize: MainAxisSize.min,
|
||||||
if (v == null) return null;
|
children: [
|
||||||
final val = v.trim().length > 5;
|
TextFormField(
|
||||||
if (validateLength != val) {
|
autofocus: true,
|
||||||
// use delay to make setState success
|
obscureText: true,
|
||||||
Future.delayed(Duration(microseconds: 1),
|
keyboardType: TextInputType.visiblePassword,
|
||||||
() => setState(() => validateLength = val));
|
decoration: InputDecoration(
|
||||||
}
|
labelText: translate('Password'),
|
||||||
return val
|
),
|
||||||
? null
|
controller: p0,
|
||||||
: translate('Too short, at least 6 characters.');
|
validator: (v) {
|
||||||
},
|
if (v == null) return null;
|
||||||
|
final val = v.trim().length > 5;
|
||||||
|
if (validateLength != val) {
|
||||||
|
// use delay to make setState success
|
||||||
|
Future.delayed(Duration(microseconds: 1),
|
||||||
|
() => setState(() => validateLength = val));
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
? null
|
||||||
|
: translate('Too short, at least 6 characters.');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextFormField(
|
||||||
|
obscureText: true,
|
||||||
|
keyboardType: TextInputType.visiblePassword,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: translate('Confirmation'),
|
||||||
|
),
|
||||||
|
controller: p1,
|
||||||
|
validator: (v) {
|
||||||
|
if (v == null) return null;
|
||||||
|
final val = p0.text == v;
|
||||||
|
if (validateSame != val) {
|
||||||
|
Future.delayed(Duration(microseconds: 1),
|
||||||
|
() => setState(() => validateSame = val));
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
? null
|
||||||
|
: translate('The confirmation is not identical.');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: Icon(Icons.close_rounded),
|
||||||
|
label: Text(translate("Cancel")),
|
||||||
|
onPressed: close,
|
||||||
|
),
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: Icon(Icons.done_rounded),
|
||||||
|
label: Text(translate("Ok")),
|
||||||
|
onPressed:
|
||||||
|
(validateLength && validateSame) ? submit : null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).paddingOnly(top: 20)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
TextFormField(
|
),
|
||||||
obscureText: true,
|
],
|
||||||
keyboardType: TextInputType.visiblePassword,
|
),
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: translate('Confirmation'),
|
|
||||||
),
|
|
||||||
controller: p1,
|
|
||||||
validator: (v) {
|
|
||||||
if (v == null) return null;
|
|
||||||
final val = p0.text == v;
|
|
||||||
if (validateSame != val) {
|
|
||||||
Future.delayed(Duration(microseconds: 1),
|
|
||||||
() => setState(() => validateSame = val));
|
|
||||||
}
|
|
||||||
return val
|
|
||||||
? null
|
|
||||||
: translate('The confirmation is not identical.');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
])),
|
|
||||||
onCancel: close,
|
onCancel: close,
|
||||||
onSubmit: (validateLength && validateSame) ? submit : null,
|
onSubmit: (validateLength && validateSame) ? submit : null,
|
||||||
actions: [
|
|
||||||
dialogButton(
|
|
||||||
'Cancel',
|
|
||||||
onPressed: close,
|
|
||||||
isOutline: true,
|
|
||||||
),
|
|
||||||
dialogButton(
|
|
||||||
'OK',
|
|
||||||
onPressed: (validateLength && validateSame) ? submit : null,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -191,7 +210,13 @@ void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Text(translate('Password Required')),
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.password_rounded, color: MyTheme.accent),
|
||||||
|
Text(translate('Password Required')).paddingOnly(left: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||||
PasswordWidget(controller: controller),
|
PasswordWidget(controller: controller),
|
||||||
CheckboxListTile(
|
CheckboxListTile(
|
||||||
@ -208,11 +233,22 @@ void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: Icon(Icons.close_rounded),
|
||||||
|
label: Text(translate("Cancel")),
|
||||||
|
onPressed: close,
|
||||||
|
),
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: Icon(Icons.done_rounded),
|
||||||
|
label: Text(translate("Ok")),
|
||||||
|
onPressed: submit,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).paddingOnly(top: 20)
|
||||||
]),
|
]),
|
||||||
actions: [
|
|
||||||
dialogButton('Cancel', onPressed: cancel, isOutline: true),
|
|
||||||
dialogButton('OK', onPressed: submit),
|
|
||||||
],
|
|
||||||
onSubmit: submit,
|
onSubmit: submit,
|
||||||
onCancel: cancel,
|
onCancel: cancel,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user