Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] added the dynamicFAV and made seprate function for each type of lock

Aman Raj Singh Mouryad3c7ba687446
diff --git a/mobile/lib/ui/settings/TEMP/lock_screen_option.dart b/mobile/lib/ui/settings/TEMP/lock_screen_option.dart
index 6e9aec8e62..7cd7450b2f 100644
--- a/mobile/lib/ui/settings/TEMP/lock_screen_option.dart
+++ b/mobile/lib/ui/settings/TEMP/lock_screen_option.dart
@@ -33,6 +33,81 @@ class _LockScreenOptionState extends State<LockScreenOption> {
super.initState();
}
+ Future<void> _deviceLock() async {
+ await _configuration.removePinAndPassword();
+ setState(() {
+ isPasswordEnabled = _configuration.isPasswordSet();
+ isPinEnabled = _configuration.isPinSet();
+ });
+ }
+
+ Future<void> _pinLock() async {
+ final bool result = await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const LockScreenOptionPin();
+ },
+ ),
+ );
+ setState(() {
+ isPasswordEnabled = _configuration.isPasswordSet();
+ isPinEnabled = _configuration.isPinSet();
+ if (result == false) {
+ appLock = appLock;
+ } else {
+ appLock = isPinEnabled || isPasswordEnabled;
+ }
+ });
+ }
+
+ Future<void> _passwordLock() async {
+ final bool result = await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return const LockScreenOptionPassword();
+ },
+ ),
+ );
+ setState(() {
+ isPasswordEnabled = _configuration.isPasswordSet();
+ isPinEnabled = _configuration.isPinSet();
+ if (result == false) {
+ appLock = appLock;
+ } else {
+ appLock = isPinEnabled || isPasswordEnabled;
+ }
+ });
+ }
+
+ Future<void> _onToggleSwitch() async {
+ bool result;
+ if ((isPinEnabled || isPasswordEnabled) && appLock == true) {
+ result = await LocalAuthenticationService.instance
+ .requestEnteAuthForLockScreen(context);
+ await _configuration.removePinAndPassword();
+ isPasswordEnabled = _configuration.isPasswordSet();
+ isPinEnabled = _configuration.isPinSet();
+ } else {
+ result = await LocalAuthenticationService.instance
+ .requestLocalAuthForLockScreen(
+ context,
+ !_configuration.shouldShowLockScreen(),
+ S.of(context).authToChangeLockscreenSetting,
+ S.of(context).lockScreenEnablePreSteps,
+ );
+ await _configuration.removePinAndPassword();
+ isPasswordEnabled = _configuration.isPasswordSet();
+ isPinEnabled = _configuration.isPinSet();
+ }
+ setState(() {
+ if (result) {
+ appLock = !appLock!;
+ } else {
+ appLock = appLock;
+ }
+ });
+ }
+
@override
Widget build(BuildContext context) {
final colorTheme = getEnteColorScheme(context);
@@ -68,41 +143,7 @@ class _LockScreenOptionState extends State<LockScreenOption> {
menuItemColor: colorTheme.fillFaint,
trailingWidget: ToggleSwitchWidget(
value: () => appLock!,
- onChanged: () async {
- bool result;
- if ((isPinEnabled || isPasswordEnabled) &&
- appLock == true) {
- result = await LocalAuthenticationService
- .instance
- .requestEnteAuthForLockScreen(context);
- await _configuration.removePinAndPassword();
- isPasswordEnabled =
- _configuration.isPasswordSet();
- isPinEnabled = _configuration.isPinSet();
- } else {
- result = await LocalAuthenticationService
- .instance
- .requestLocalAuthForLockScreen(
- context,
- !_configuration.shouldShowLockScreen(),
- S
- .of(context)
- .authToChangeLockscreenSetting,
- S.of(context).lockScreenEnablePreSteps,
- );
- await _configuration.removePinAndPassword();
- isPasswordEnabled =
- _configuration.isPasswordSet();
- isPinEnabled = _configuration.isPinSet();
- }
- setState(() {
- if (result) {
- appLock = !appLock!;
- } else {
- appLock = appLock;
- }
- });
- },
+ onChanged: () => _onToggleSwitch(),
),
),
const Padding(
@@ -137,15 +178,7 @@ class _LockScreenOptionState extends State<LockScreenOption> {
? Icons.check
: null,
trailingIconColor: colorTheme.tabIcon,
- onTap: () async {
- setState(() {
- _configuration.removePinAndPassword();
- isPasswordEnabled =
- _configuration.isPasswordSet();
- isPinEnabled =
- _configuration.isPinSet();
- });
- },
+ onTap: () => _deviceLock(),
),
DividerWidget(
dividerType: DividerType.menuNoIcon,
@@ -163,28 +196,7 @@ class _LockScreenOptionState extends State<LockScreenOption> {
trailingIcon:
isPinEnabled ? Icons.check : null,
trailingIconColor: colorTheme.tabIcon,
- onTap: () async {
- final bool result =
- await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return const LockScreenOptionPin();
- },
- ),
- );
- setState(() {
- isPasswordEnabled =
- _configuration.isPasswordSet();
- isPinEnabled =
- _configuration.isPinSet();
- if (result == false) {
- appLock = appLock;
- } else {
- appLock =
- isPinEnabled || isPasswordEnabled;
- }
- });
- },
+ onTap: () => _pinLock(),
),
DividerWidget(
dividerType: DividerType.menuNoIcon,
@@ -202,28 +214,7 @@ class _LockScreenOptionState extends State<LockScreenOption> {
trailingIcon:
isPasswordEnabled ? Icons.check : null,
trailingIconColor: colorTheme.tabIcon,
- onTap: () async {
- final bool result =
- await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return const LockScreenOptionPassword();
- },
- ),
- );
- setState(() {
- isPasswordEnabled =
- _configuration.isPasswordSet();
- isPinEnabled =
- _configuration.isPinSet();
- if (result == false) {
- appLock = appLock;
- } else {
- appLock =
- isPinEnabled || isPasswordEnabled;
- }
- });
- },
+ onTap: () => _passwordLock(),
),
],
)
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 ce6b7696e7..564b453144 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
@@ -2,6 +2,7 @@ import "package:flutter/material.dart";
import "package:photos/core/configuration.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/dynamic_fab.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/components/dialog_widget.dart";
@@ -85,7 +86,18 @@ class _LockScreenOptionConfirmPasswordState
Widget build(BuildContext context) {
final colorTheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
appBar: AppBar(
elevation: 0,
leading: IconButton(
@@ -98,6 +110,17 @@ class _LockScreenOptionConfirmPasswordState
),
),
),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ buttonText: S.of(context).confirm,
+ isFormValid: _confirmPasswordController.text.isNotEmpty,
+ onPressedFunction: () async {
+ await _confirmPasswordMatch();
+ FocusScope.of(context).unfocus();
+ },
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
@@ -152,17 +175,6 @@ class _LockScreenOptionConfirmPasswordState
isPasswordInput: true,
),
),
- const Spacer(),
- Padding(
- padding: const EdgeInsets.all(18.0),
- child: ButtonWidget(
- labelText: S.of(context).confirm,
- buttonType: ButtonType.secondary,
- buttonSize: ButtonSize.large,
- onTap: () => _confirmPasswordMatch(),
- ),
- ),
- const Padding(padding: EdgeInsets.only(bottom: 24)),
],
),
),
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 d348468ea0..fe7f965932 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
@@ -2,6 +2,7 @@ import "package:flutter/material.dart";
import "package:photos/core/configuration.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/common/dynamic_fab.dart";
import "package:photos/ui/components/buttons/button_widget.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
import "package:photos/ui/components/dialog_widget.dart";
@@ -87,8 +88,18 @@ class _LockScreenOptionConfirmPinState
Widget build(BuildContext context) {
final colorTheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
return Scaffold(
- resizeToAvoidBottomInset: false,
+ resizeToAvoidBottomInset: isKeypadOpen,
appBar: AppBar(
elevation: 0,
leading: IconButton(
@@ -101,6 +112,17 @@ class _LockScreenOptionConfirmPinState
),
),
),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ buttonText: S.of(context).confirm,
+ isFormValid: _confirmPinController.text.isNotEmpty,
+ onPressedFunction: () async {
+ await _confirmPinMatch();
+ FocusScope.of(context).unfocus();
+ },
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
body: Center(
child: Column(
children: [
@@ -175,19 +197,6 @@ class _LockScreenOptionConfirmPinState
},
),
),
- const Spacer(),
- Padding(
- padding: const EdgeInsets.all(18.0),
- child: ButtonWidget(
- labelText: S.of(context).confirm,
- buttonType: _confirmPinController.text.length == 4
- ? ButtonType.primary
- : ButtonType.secondary,
- buttonSize: ButtonSize.large,
- onTap: () => _confirmPinMatch(),
- ),
- ),
- const Padding(padding: EdgeInsets.only(bottom: 24)),
],
),
),
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 7f5b6be781..cd3408476c 100644
--- a/mobile/lib/ui/settings/TEMP/lock_screen_option_password.dart
+++ b/mobile/lib/ui/settings/TEMP/lock_screen_option_password.dart
@@ -1,9 +1,8 @@
import "package:flutter/material.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/buttons/button_widget.dart";
+import "package:photos/ui/common/dynamic_fab.dart";
import "package:photos/ui/components/buttons/icon_button_widget.dart";
-import "package:photos/ui/components/models/button_type.dart";
import "package:photos/ui/components/text_input_widget.dart";
import "package:photos/ui/settings/TEMP/lock_screen_option_confirm_password.dart";
@@ -68,7 +67,18 @@ class _LockScreenOptionPasswordState extends State<LockScreenOptionPassword> {
Widget build(BuildContext context) {
final colorTheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
appBar: AppBar(
elevation: 0,
leading: IconButton(
@@ -81,6 +91,17 @@ class _LockScreenOptionPasswordState extends State<LockScreenOptionPassword> {
),
),
),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ buttonText: S.of(context).ok,
+ isFormValid: _passwordController.text.isNotEmpty,
+ onPressedFunction: () async {
+ await _confirmPassword();
+ FocusScope.of(context).unfocus();
+ },
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
@@ -136,17 +157,6 @@ class _LockScreenOptionPasswordState extends State<LockScreenOptionPassword> {
isPasswordInput: true,
),
),
- const Spacer(),
- Padding(
- padding: const EdgeInsets.all(18.0),
- child: ButtonWidget(
- labelText: 'Next',
- buttonType: ButtonType.secondary,
- buttonSize: ButtonSize.large,
- onTap: () => _confirmPassword(),
- ),
- ),
- const Padding(padding: EdgeInsets.only(bottom: 24)),
],
),
),
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 14a7d87740..b806b5dff7 100644
--- a/mobile/lib/ui/settings/TEMP/lock_screen_option_pin.dart
+++ b/mobile/lib/ui/settings/TEMP/lock_screen_option_pin.dart
@@ -83,7 +83,6 @@ class _LockScreenOptionPinState extends State<LockScreenOptionPin> {
),
),
),
- // resizeToAvoidBottomInset: false,
body: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,