Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Show errorText with border on invalid Pin

Aman Raj Singh Mouryabdbed2aa17f4
diff --git a/mobile/lib/ui/settings/lockscreen/lock_screen_option.dart b/mobile/lib/ui/settings/lockscreen/lock_screen_option.dart
index 59725f2fc6..d7d9c31f99 100644
--- a/mobile/lib/ui/settings/lockscreen/lock_screen_option.dart
+++ b/mobile/lib/ui/settings/lockscreen/lock_screen_option.dart
@@ -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,
+ ),
+ ),
],
),
),
diff --git a/mobile/lib/ui/settings/lockscreen/lock_screen_option_password.dart b/mobile/lib/ui/settings/lockscreen/lock_screen_option_password.dart
index 5831a65337..d9f03c9be0 100644
--- a/mobile/lib/ui/settings/lockscreen/lock_screen_option_password.dart
+++ b/mobile/lib/ui/settings/lockscreen/lock_screen_option_password.dart
@@ -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
diff --git a/mobile/lib/ui/settings/lockscreen/lock_screen_option_pin.dart b/mobile/lib/ui/settings/lockscreen/lock_screen_option_pin.dart
index 7f574dae1e..e64e52f284 100644
--- a/mobile/lib/ui/settings/lockscreen/lock_screen_option_pin.dart
+++ b/mobile/lib/ui/settings/lockscreen/lock_screen_option_pin.dart
@@ -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);