Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Added Haptic feedback to pin/password input

Aman Raj Singh Mouryaa135f467751e
diff --git a/mobile/lib/ui/settings/TEMP/lock_screen_option.dart b/mobile/lib/ui/settings/TEMP/lock_screen_option.dart
index 8388ce17d3..154194b36c 100644
--- a/mobile/lib/ui/settings/TEMP/lock_screen_option.dart
+++ b/mobile/lib/ui/settings/TEMP/lock_screen_option.dart
@@ -90,8 +90,8 @@ class _LockScreenOptionState extends State<LockScreenOption> {
AppLock.of(context)!.setEnabled(!appLock!);
await Configuration.instance.setShouldShowLockScreen(!appLock!);
}
+ await _configuration.removePinAndPassword();
setState(() {
- _configuration.removePinAndPassword();
isPasswordEnabled = _configuration.isPasswordSet();
isPinEnabled = _configuration.isPinSet();
appLock = !appLock!;
diff --git a/mobile/lib/ui/settings/TEMP/lock_screen_option_confirm_password.dart b/mobile/lib/ui/settings/TEMP/lock_screen_option_confirm_password.dart
index 819c369982..476eba19d2 100644
--- a/mobile/lib/ui/settings/TEMP/lock_screen_option_confirm_password.dart
+++ b/mobile/lib/ui/settings/TEMP/lock_screen_option_confirm_password.dart
@@ -1,4 +1,5 @@
import "package:flutter/material.dart";
+import "package:flutter/services.dart";
import "package:photos/core/configuration.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/ente_theme.dart";
@@ -25,6 +26,7 @@ class _LockScreenOptionConfirmPasswordState
final _focusNode = FocusNode();
final _isFormValid = ValueNotifier<bool>(false);
+ final _submitNotifier = ValueNotifier(false);
@override
void initState() {
super.initState();
@@ -36,8 +38,9 @@ class _LockScreenOptionConfirmPasswordState
@override
void dispose() {
- super.dispose();
+ _submitNotifier.dispose();
_focusNode.dispose();
+ super.dispose();
}
Future<void> _confirmPasswordMatch() async {
@@ -46,7 +49,9 @@ class _LockScreenOptionConfirmPasswordState
Navigator.of(context).pop(true);
Navigator.of(context).pop(true);
+ return;
}
+ await HapticFeedback.vibrate();
_confirmPasswordController.clear();
}
@@ -140,16 +145,14 @@ class _LockScreenOptionConfirmPasswordState
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TextInputWidget(
hintText: S.of(context).confirmPassword,
- borderRadius: 2,
focusNode: _focusNode,
- isClearable: true,
textCapitalization: TextCapitalization.words,
textEditingController: _confirmPasswordController,
- prefixIcon: Icons.lock_outline,
isPasswordInput: true,
onChange: (p0) {
_isFormValid.value =
_confirmPasswordController.text.isNotEmpty;
+ _submitNotifier.value = !_submitNotifier.value;
},
),
),
diff --git a/mobile/lib/ui/settings/TEMP/lock_screen_option_confirm_pin.dart b/mobile/lib/ui/settings/TEMP/lock_screen_option_confirm_pin.dart
index 3f8b015f10..66fa8059a7 100644
--- a/mobile/lib/ui/settings/TEMP/lock_screen_option_confirm_pin.dart
+++ b/mobile/lib/ui/settings/TEMP/lock_screen_option_confirm_pin.dart
@@ -1,4 +1,5 @@
import "package:flutter/material.dart";
+import "package:flutter/services.dart";
import "package:photos/core/configuration.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/ente_theme.dart";
@@ -50,9 +51,9 @@ class _LockScreenOptionConfirmPinState
Navigator.of(context).pop(true);
Navigator.of(context).pop(true);
return;
- } else {
- _confirmPinController.clear();
}
+ await HapticFeedback.vibrate();
+ _confirmPinController.clear();
}
@override
@@ -149,28 +150,36 @@ class _LockScreenOptionConfirmPinState
crossAxisAlignment: CrossAxisAlignment.center,
controller: _confirmPinController,
focusNode: _focusNode,
+ defaultPinTheme: _pinPutDecoration,
submittedPinTheme: _pinPutDecoration.copyWith(
+ textStyle: textTheme.h3Bold,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
- color: const Color.fromRGBO(45, 194, 98, 0.5),
+ color: colorTheme.fillBase,
),
),
),
- defaultPinTheme: _pinPutDecoration,
followingPinTheme: _pinPutDecoration.copyWith(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
- color: const Color.fromRGBO(45, 194, 98, 0.5),
+ color: colorTheme.fillMuted,
),
),
),
+ focusedPinTheme: _pinPutDecoration,
errorPinTheme: _pinPutDecoration.copyWith(
- textStyle: TextStyle(color: colorTheme.warning400),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(5.0),
+ border: Border.all(
+ color: colorTheme.fillBase,
+ ),
+ ),
+ textStyle:
+ textTheme.h3Bold.copyWith(color: colorTheme.warning400),
),
errorText: '',
- focusedPinTheme: _pinPutDecoration,
obscureText: true,
obscuringCharacter: '*',
validator: (value) {
diff --git a/mobile/lib/ui/settings/TEMP/lock_screen_option_password.dart b/mobile/lib/ui/settings/TEMP/lock_screen_option_password.dart
index abf3afbdbf..75811312b4 100644
--- a/mobile/lib/ui/settings/TEMP/lock_screen_option_password.dart
+++ b/mobile/lib/ui/settings/TEMP/lock_screen_option_password.dart
@@ -1,4 +1,5 @@
import "package:flutter/material.dart";
+import "package:flutter/services.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/common/dynamic_fab.dart";
@@ -45,6 +46,8 @@ class _LockScreenOptionPasswordState extends State<LockScreenOptionPassword> {
Navigator.of(context).pop(true);
return true;
}
+ await HapticFeedback.vibrate();
+
Navigator.of(context).pop(false);
return false;
}
@@ -156,12 +159,9 @@ class _LockScreenOptionPasswordState extends State<LockScreenOptionPassword> {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TextInputWidget(
hintText: S.of(context).password,
- borderRadius: 2,
- isClearable: true,
focusNode: _focusNode,
textCapitalization: TextCapitalization.words,
textEditingController: _passwordController,
- prefixIcon: Icons.lock_outline,
isPasswordInput: true,
onChange: (p0) {
_isFormValid.value = _passwordController.text.isNotEmpty;
diff --git a/mobile/lib/ui/settings/TEMP/lock_screen_option_pin.dart b/mobile/lib/ui/settings/TEMP/lock_screen_option_pin.dart
index a327b77ba2..950474d4fe 100644
--- a/mobile/lib/ui/settings/TEMP/lock_screen_option_pin.dart
+++ b/mobile/lib/ui/settings/TEMP/lock_screen_option_pin.dart
@@ -1,4 +1,5 @@
import "package:flutter/material.dart";
+import "package:flutter/services.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/settings/TEMP/lock_screen_option_confirm_pin.dart";
@@ -42,7 +43,7 @@ class _LockScreenOptionPinState extends State<LockScreenOptionPin> {
Navigator.of(context).pop(true);
return true;
}
- Navigator.of(context).pop(false);
+ await HapticFeedback.vibrate();
return false;
}
@@ -62,8 +63,8 @@ class _LockScreenOptionPinState extends State<LockScreenOptionPin> {
}
final _pinPutDecoration = PinTheme(
- height: 50,
- width: 50,
+ height: 48,
+ width: 48,
decoration: BoxDecoration(
border: Border.all(color: const Color.fromRGBO(45, 194, 98, 1.0)),
borderRadius: BorderRadius.circular(15.0),
@@ -146,10 +147,11 @@ class _LockScreenOptionPinState extends State<LockScreenOptionPin> {
controller: _pinController,
defaultPinTheme: _pinPutDecoration,
submittedPinTheme: _pinPutDecoration.copyWith(
+ textStyle: textTheme.h3Bold,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
- color: const Color.fromRGBO(45, 194, 98, 0.5),
+ color: colorTheme.fillBase,
),
),
),
@@ -157,20 +159,31 @@ class _LockScreenOptionPinState extends State<LockScreenOptionPin> {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(
- color: const Color.fromRGBO(45, 194, 98, 0.5),
+ color: colorTheme.fillMuted,
),
),
),
focusedPinTheme: _pinPutDecoration,
errorPinTheme: _pinPutDecoration.copyWith(
decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(5.0),
border: Border.all(
- color: colorTheme.warning400,
+ color: colorTheme.fillBase,
),
),
+ textStyle: textTheme.h3Bold
+ .copyWith(color: colorTheme.warning400),
),
+ validator: widget.isAuthenticating
+ ? (value) {
+ if (widget.authPin == value) {
+ return null;
+ }
+ return 'Invalid PIN';
+ }
+ : null,
autofocus: true,
- errorText: '*',
+ errorText: '',
obscureText: true,
obscuringCharacter: '*',
onCompleted: (value) {
diff --git a/mobile/lib/ui/settings/TEMP/password_input_widget.dart b/mobile/lib/ui/settings/TEMP/password_input_widget.dart
deleted file mode 100644
index dc9e7a0f5e..0000000000
--- a/mobile/lib/ui/settings/TEMP/password_input_widget.dart
+++ /dev/null
@@ -1,92 +0,0 @@
-import "package:flutter/material.dart";
-import "package:flutter/services.dart";
-import "package:photos/models/execution_states.dart";
-import "package:photos/models/typedefs.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/utils/debouncer.dart";
-
-class PasswordInputWidget extends StatefulWidget {
- final String? label;
- final String? message;
- final String? hintText;
- final IconData? prefixIcon;
- final String? initialValue;
- final Alignment? alignMessage;
- final bool? autoFocus;
- final int? maxLength;
- final double borderRadius;
-
- final ValueNotifier? submitNotifier;
-
- final FutureVoidCallbackParamStr? onSubmit;
- final VoidCallbackParamStr? onChange;
- final bool isPasswordInput;
-
- final FocusNode? focusNode;
- final TextEditingController? textEditingController;
- final TextInputType? textInputType;
- final List<TextInputFormatter>? textInputFormatter;
- const PasswordInputWidget({
- Key? key,
- this.label,
- this.message,
- this.hintText,
- this.prefixIcon,
- this.initialValue,
- this.alignMessage,
- this.autoFocus,
- this.maxLength,
- this.borderRadius = 10.0,
- this.submitNotifier,
- this.onSubmit,
- this.onChange,
- required this.isPasswordInput,
- this.focusNode,
- this.textEditingController,
- this.textInputType,
- this.textInputFormatter,
- }) : super(key: key);
-
- @override
- State<PasswordInputWidget> createState() => _PasswordInputWidgetState();
-}
-
-class _PasswordInputWidgetState extends State<PasswordInputWidget> {
- ExecutionState executionState = ExecutionState.idle;
- late final TextEditingController _textController;
- final _debouncer = Debouncer(const Duration(milliseconds: 300));
- late final ValueNotifier<bool> _obscureTextNotifier;
-
- @override
- void initState() {
- super.initState();
- // widget.submitNotifier?.addListener(_onSubmit);
- // widget.cancelNotifier?.addListener(_onCancel);
- _textController = widget.textEditingController ?? TextEditingController();
-
- // _setInitialValue();
-
- if (widget.onChange != null) {
- _textController.addListener(() {
- widget.onChange!.call(_textController.text);
- });
- }
- _obscureTextNotifier = ValueNotifier(widget.isPasswordInput);
- // _obscureTextNotifier.addListener(_safeRefresh);
-
- // if (widget.isEmptyNotifier != null) {
- // _textController.addListener(() {
- // widget.isEmptyNotifier!.value = _textController.text.isEmpty;
- // });
- // }
- }
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- var textInputChildren = <Widget>[];
-
- return const Placeholder();
- }
-}
diff --git a/mobile/lib/ui/settings/security_section_widget.dart b/mobile/lib/ui/settings/security_section_widget.dart
index 3ddea3e47d..bce32312cd 100644
--- a/mobile/lib/ui/settings/security_section_widget.dart
+++ b/mobile/lib/ui/settings/security_section_widget.dart
@@ -150,7 +150,6 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
context,
S.of(context).authToChangeLockscreenSetting,
);
-
if (result) {
await Navigator.of(context).push(
MaterialPageRoute(
@@ -162,25 +161,6 @@ class _SecuritySectionWidgetState extends State<SecuritySectionWidget> {
}
},
),
- // MenuItemWidget(
- // captionedTextWidget: const CaptionedTextWidget(
- // title: 'App lock',
- // ),
- // trailingWidget: ToggleSwitchWidget(
- // value: () => _config.shouldShowLockScreen(),
- // onChanged: () async {
- // await LocalAuthenticationService.instance
- // .requestLocalAuthForLockScreen(
- // context,
- // !_config.shouldShowLockScreen(),
- // S.of(context).authToChangeLockscreenSetting,
- // S.of(context).lockScreenEnablePreSteps,
- // );
-
- // ///try here also once about the material page route
- // },
- // ),
- // ),
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(