[mob][photos] Show errorText with border on invalid Pin
This commit is contained in:
@@ -134,29 +134,13 @@ class _LockScreenOptionState extends State<LockScreenOption> {
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 16),
|
||||
padding: EdgeInsets.only(top: 24),
|
||||
),
|
||||
appLock
|
||||
? Container()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 14,
|
||||
right: 12,
|
||||
),
|
||||
child: Text(
|
||||
'Choose between your device\'s default lock screen and a custom lock screen with a PIN or password.',
|
||||
style: textTheme.miniFaint,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
appLock
|
||||
? Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
MenuItemWidget(
|
||||
captionedTextWidget:
|
||||
const CaptionedTextWidget(
|
||||
@@ -211,7 +195,17 @@ class _LockScreenOptionState extends State<LockScreenOption> {
|
||||
),
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 14,
|
||||
right: 12,
|
||||
),
|
||||
child: Text(
|
||||
'Choose between your device\'s default lock screen and a custom lock screen with a PIN or password.',
|
||||
style: textTheme.miniFaint,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -18,6 +18,8 @@ class LockScreenOptionPassword extends StatefulWidget {
|
||||
this.isAuthenticating = false,
|
||||
this.authPass,
|
||||
});
|
||||
|
||||
/// If [isAuthenticating] is true then we are authenticating the user
|
||||
final bool isAuthenticating;
|
||||
final String? authPass;
|
||||
@override
|
||||
|
||||
@@ -19,6 +19,7 @@ class LockScreenOptionPin extends StatefulWidget {
|
||||
this.authPin,
|
||||
});
|
||||
|
||||
/// If [isAuthenticating] is true then we are authenticating the user
|
||||
final bool isAuthenticating;
|
||||
final String? authPin;
|
||||
@override
|
||||
@@ -29,7 +30,9 @@ class _LockScreenOptionPinState extends State<LockScreenOptionPin> {
|
||||
final _pinController = TextEditingController(text: null);
|
||||
|
||||
final LockscreenSetting _lockscreenSetting = LockscreenSetting.instance;
|
||||
late String hashedPin;
|
||||
late String enteredHashedPin;
|
||||
bool isPinValid = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
@@ -58,14 +61,20 @@ class _LockScreenOptionPinState extends State<LockScreenOptionPin> {
|
||||
"memLimit": Sodium.cryptoPwhashMemlimitInteractive,
|
||||
});
|
||||
|
||||
hashedPin = base64Encode(hash);
|
||||
if (widget.authPin == hashedPin) {
|
||||
enteredHashedPin = base64Encode(hash);
|
||||
if (widget.authPin == enteredHashedPin) {
|
||||
Navigator.of(context).pop(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
_pinController.clear();
|
||||
setState(() {
|
||||
isPinValid = true;
|
||||
});
|
||||
await HapticFeedback.vibrate();
|
||||
await Future.delayed(const Duration(milliseconds: 75));
|
||||
_pinController.clear();
|
||||
setState(() {
|
||||
isPinValid = false;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -207,23 +216,16 @@ class _LockScreenOptionPinState extends State<LockScreenOptionPin> {
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
border: Border.all(
|
||||
color: colorTheme.fillBase,
|
||||
color: colorTheme.warning400,
|
||||
),
|
||||
),
|
||||
textStyle:
|
||||
textTheme.h3Bold.copyWith(color: colorTheme.warning400),
|
||||
),
|
||||
// validator: widget.isAuthenticating
|
||||
// ? (value) {
|
||||
// if (widget.authPin == hashedPin) {
|
||||
// return null;
|
||||
// }
|
||||
// return 'Invalid PIN';
|
||||
// }
|
||||
// : null,
|
||||
errorText: '',
|
||||
forceErrorState: isPinValid,
|
||||
obscureText: true,
|
||||
obscuringCharacter: '*',
|
||||
errorText: '',
|
||||
onCompleted: (value) async {
|
||||
await Future.delayed(const Duration(milliseconds: 250));
|
||||
await _confirmPin(_pinController.text);
|
||||
|
||||
Reference in New Issue
Block a user