π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refactor lock screen UI to use LockScreenSubmitFab and simplify component structure
aman-pilot2f1cf1a8a149
diff --git a/mobile/packages/lock_screen/lib/ui/lock_screen_confirm_password.dart b/mobile/packages/lock_screen/lib/ui/lock_screen_confirm_password.dartindex b339db8c38..d6f4d6a30e 100644--- a/mobile/packages/lock_screen/lib/ui/lock_screen_confirm_password.dart+++ b/mobile/packages/lock_screen/lib/ui/lock_screen_confirm_password.dart@@ -1,9 +1,8 @@+import "package:ente_components/ente_components.dart";import "package:ente_lock_screen/lock_screen_settings.dart";+import "package:ente_lock_screen/ui/lock_screen_submit_fab.dart";import "package:ente_strings/ente_strings.dart";import "package:ente_ui/components/android_text_input_autofocus.dart";-import "package:ente_ui/components/buttons/dynamic_fab.dart";-import "package:ente_ui/components/text_input_widget.dart";-import "package:ente_ui/theme/ente_theme.dart";import "package:flutter/material.dart";import "package:flutter/services.dart";import "package:flutter_svg/flutter_svg.dart";@@ -47,21 +46,10 @@ class _LockScreenConfirmPasswordState extends State<LockScreenConfirmPassword> {@overrideWidget build(BuildContext context) {- final colorTheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final isKeypadOpen = MediaQuery.viewInsetsOf(context).bottom > 100;-- FloatingActionButtonLocation? fabLocation() {- if (isKeypadOpen) {- return null;- } else {- return FloatingActionButtonLocation.centerFloat;- }- }+ final colorTheme = context.componentColors;return Scaffold(backgroundColor: colorTheme.backgroundBase,- resizeToAvoidBottomInset: isKeypadOpen,appBar: AppBar(backgroundColor: colorTheme.backgroundBase,elevation: 0,@@ -77,24 +65,15 @@ class _LockScreenConfirmPasswordState extends State<LockScreenConfirmPassword> {title: SvgPicture.asset(LockScreenSettings.instance.appLogoAsset,height: LockScreenSettings.instance.appLogoHeight,- colorFilter: ColorFilter.mode(colorTheme.primary700, BlendMode.srcIn),+ colorFilter: ColorFilter.mode(colorTheme.primary, BlendMode.srcIn),),),- floatingActionButton: ValueListenableBuilder<bool>(- valueListenable: _isFormValid,- builder: (context, isFormValid, child) {- return DynamicFAB(- isKeypadOpen: isKeypadOpen,- buttonText: context.strings.confirm,- isFormValid: isFormValid,- onPressedFunction: () async {- _submitNotifier.value = !_submitNotifier.value;- },- );- },+ floatingActionButton: LockScreenSubmitFab(+ label: context.strings.confirm,+ isFormValid: _isFormValid,+ onSubmit: () => _submitNotifier.value = !_submitNotifier.value,),- floatingActionButtonLocation: fabLocation(),- floatingActionButtonAnimator: NoScalingAnimation(),+ floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,body: SingleChildScrollView(child: Center(child: Padding(@@ -112,21 +91,21 @@ class _LockScreenConfirmPasswordState extends State<LockScreenConfirmPassword> {Text(context.strings.reEnterPassword,textAlign: TextAlign.center,- style: textTheme.bodyBold,+ style: TextStyles.bodyBold,),const Padding(padding: EdgeInsets.all(12)),Padding(padding: const EdgeInsets.symmetric(horizontal: 16),child: AndroidTextInputAutofocus(focusNode: _focusNode,- child: TextInputWidget(+ child: TextInputComponent(hintText: context.strings.password,- autoFocus: true,+ autofocus: true,focusNode: _focusNode,textCapitalization: TextCapitalization.none,+ textInputAction: TextInputAction.done,isPasswordInput: true,- shouldSurfaceExecutionStates: false,- onChange: (p0) {+ onChanged: (p0) {_confirmPasswordController.text = p0;_isFormValid.value =_confirmPasswordController.text.isNotEmpty;diff --git a/mobile/packages/lock_screen/lib/ui/lock_screen_options.dart b/mobile/packages/lock_screen/lib/ui/lock_screen_options.dartindex 6463593a91..485868a519 100644--- a/mobile/packages/lock_screen/lib/ui/lock_screen_options.dart+++ b/mobile/packages/lock_screen/lib/ui/lock_screen_options.dart@@ -1,6 +1,7 @@import "dart:async";import "dart:io";+import "package:ente_components/ente_components.dart";import "package:ente_lock_screen/local_authentication_service.dart";import "package:ente_lock_screen/lock_screen_settings.dart";import "package:ente_lock_screen/ui/app_lock.dart";@@ -10,17 +11,6 @@ import "package:ente_lock_screen/ui/lock_screen_password.dart";import "package:ente_lock_screen/ui/lock_screen_pin.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import "package:ente_strings/ente_strings.dart";-import "package:ente_ui/components/buttons/button_widget.dart";-import "package:ente_ui/components/buttons/models/button_type.dart";-import "package:ente_ui/components/captioned_text_widget.dart";-import "package:ente_ui/components/constrained_custom_scroll_view.dart";-import "package:ente_ui/components/dialog_widget.dart";-import "package:ente_ui/components/divider_widget.dart";-import "package:ente_ui/components/menu_item_widget.dart";-import "package:ente_ui/components/title_bar_title_widget.dart";-import "package:ente_ui/components/title_bar_widget.dart";-import "package:ente_ui/components/toggle_switch_widget.dart";-import "package:ente_ui/theme/ente_theme.dart";import "package:flutter/material.dart";class LockScreenOptions extends StatefulWidget {@@ -76,18 +66,12 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {await _initializeSettings();return;}- await showDialogWidget(+ await showBottomSheetComponent(context: context,- title: context.strings.noSystemLockFound,- body: context.strings.deviceLockEnablePreSteps,- isDismissible: true,- buttons: [- ButtonWidget(- buttonType: ButtonType.secondary,- labelText: context.strings.ok,- isInAlert: true,- ),- ],+ builder: (_) => BottomSheetComponent(+ title: context.strings.noSystemLockFound,+ message: context.strings.deviceLockEnablePreSteps,+ ),);}await _initializeSettings();@@ -176,209 +160,179 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {@overrideWidget build(BuildContext context) {- final colorTheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);+ final colors = context.componentColors;+ final descriptionStyle = TextStyles.mini.copyWith(+ color: colors.textLighter,+ );return Scaffold(- body: ConstrainedCustomScrollView(- slivers: <Widget>[- TitleBarWidget(- flexibleSpaceTitle: TitleBarTitleWidget(- title: context.strings.appLock,- ),- ),- SliverList(- delegate: SliverChildBuilderDelegate((context, index) {- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 16),- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 20),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Column(- crossAxisAlignment: CrossAxisAlignment.start,+ backgroundColor: colors.backgroundBase,+ body: Align(+ alignment: Alignment.topCenter,+ child: ConstrainedBox(+ constraints: const BoxConstraints(maxWidth: 700),+ child: AppBarComponent(+ title: context.strings.appLock,+ slivers: <Widget>[+ SliverList(+ delegate: SliverChildBuilderDelegate((context, index) {+ return Padding(+ padding: const EdgeInsets.symmetric(horizontal: 16),+ child: Padding(+ padding: const EdgeInsets.only(top: 8, bottom: 20),+ child: Column(+ mainAxisSize: MainAxisSize.min,children: [- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.strings.appLock,- ),- alignCaptionedTextToLeft: true,- singleBorderRadius: 8,- menuItemColor: colorTheme.fillFaint,- trailingWidget: ToggleSwitchWidget(- value: () => appLock,- onChanged: () => _onToggleSwitch(),- ),+ Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ MenuComponent(+ title: context.strings.appLock,+ trailing: ToggleSwitchComponent.async(+ value: () => appLock,+ onChanged: () => _onToggleSwitch(),+ ),+ ),+ AnimatedSwitcher(+ duration: const Duration(milliseconds: 210),+ switchInCurve: Curves.easeOut,+ switchOutCurve: Curves.easeIn,+ child: !appLock+ ? Padding(+ padding: const EdgeInsets.only(+ top: 14,+ left: 14,+ right: 12,+ ),+ child: Text(+ context.strings.appLockDescription,+ style: descriptionStyle,+ textAlign: TextAlign.left,+ ),+ )+ : const SizedBox(),+ ),+ const Padding(padding: EdgeInsets.only(top: 24)),+ ],),AnimatedSwitcher(duration: const Duration(milliseconds: 210),switchInCurve: Curves.easeOut,switchOutCurve: Curves.easeIn,- child: !appLock- ? Padding(- padding: const EdgeInsets.only(- top: 14,- left: 14,- right: 12,- ),- child: Text(- context.strings.appLockDescription,- style: textTheme.miniFaint,- textAlign: TextAlign.left,- ),+ child: appLock+ ? Column(+ crossAxisAlignment:+ CrossAxisAlignment.start,+ children: [+ MenuGroupComponent(+ showDividers: true,+ items: [+ MenuComponent(+ title: context.strings.deviceLock,+ trailing: isSystemLockEnabled+ ? Icon(+ Icons.check,+ color: colors.textBase,+ )+ : null,+ onTap: () => _deviceLock(),+ ),+ MenuComponent(+ title: context.strings.pinLock,+ trailing: isPinEnabled+ ? Icon(+ Icons.check,+ color: colors.textBase,+ )+ : null,+ onTap: () => _pinLock(),+ ),+ MenuComponent(+ title: context.strings.password,+ trailing: isPasswordEnabled+ ? Icon(+ Icons.check,+ color: colors.textBase,+ )+ : null,+ onTap: () => _passwordLock(),+ ),+ ],+ ),+ const SizedBox(height: 24),+ PlatformDetector.isMobile()+ ? MenuComponent(+ title: context.strings.autoLock,+ subtitle: _formatTime(+ Duration(+ milliseconds:+ autoLockTimeInMilliseconds,+ ),+ ),+ onTap: () => _onAutoLock(),+ )+ : const SizedBox.shrink(),+ PlatformDetector.isMobile()+ ? Padding(+ padding: const EdgeInsets.only(+ top: 14,+ left: 14,+ right: 12,+ ),+ child: Text(+ context+ .strings+ .autoLockFeatureDescription,+ style: descriptionStyle,+ textAlign: TextAlign.left,+ ),+ )+ : const SizedBox.shrink(),+ ],)- : const SizedBox(),+ : const SizedBox.shrink(),),- const Padding(padding: EdgeInsets.only(top: 24)),- ],- ),- AnimatedSwitcher(- duration: const Duration(milliseconds: 210),- switchInCurve: Curves.easeOut,- switchOutCurve: Curves.easeIn,- child: appLock- ? Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.strings.deviceLock,+ PlatformDetector.isMobile()+ ? Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ SizedBox(height: appLock ? 24 : 8),+ MenuComponent(+ title: context.strings.hideContent,+ trailing: ToggleSwitchComponent.async(+ value: () => hideAppContent,+ onChanged: () => _onHideContent(),+ ),),- surfaceExecutionStates: false,- alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: false,- isBottomBorderRadiusRemoved: true,- menuItemColor: colorTheme.fillFaint,- trailingIcon: isSystemLockEnabled- ? Icons.check- : null,- trailingIconColor: colorTheme.textBase,- onTap: () => _deviceLock(),- ),- DividerWidget(- dividerType: DividerType.menuNoIcon,- bgColor: colorTheme.fillFaint,- ),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.strings.pinLock,+ Padding(+ padding: const EdgeInsets.only(+ top: 14,+ left: 14,+ right: 12,+ ),+ child: Text(+ Platform.isAndroid+ ? context+ .strings+ .hideContentDescriptionAndroid+ : context+ .strings+ .hideContentDescriptioniOS,+ style: descriptionStyle,+ textAlign: TextAlign.left,+ ),),- surfaceExecutionStates: false,- alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: true,- isBottomBorderRadiusRemoved: true,- menuItemColor: colorTheme.fillFaint,- trailingIcon: isPinEnabled- ? Icons.check- : null,- trailingIconColor: colorTheme.textBase,- onTap: () => _pinLock(),- ),- DividerWidget(- dividerType: DividerType.menuNoIcon,- bgColor: colorTheme.fillFaint,- ),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.strings.password,- ),- surfaceExecutionStates: false,- alignCaptionedTextToLeft: true,- isTopBorderRadiusRemoved: true,- isBottomBorderRadiusRemoved: false,- menuItemColor: colorTheme.fillFaint,- trailingIcon: isPasswordEnabled- ? Icons.check- : null,- trailingIconColor: colorTheme.textBase,- onTap: () => _passwordLock(),- ),- const SizedBox(height: 24),- PlatformDetector.isMobile()- ? MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.strings.autoLock,- subTitle: _formatTime(- Duration(- milliseconds:- autoLockTimeInMilliseconds,- ),- ),- ),- surfaceExecutionStates: false,- alignCaptionedTextToLeft: true,- singleBorderRadius: 8,- menuItemColor: colorTheme.fillFaint,- trailingIconColor:- colorTheme.textBase,- onTap: () => _onAutoLock(),- )- : const SizedBox.shrink(),- PlatformDetector.isMobile()- ? Padding(- padding: const EdgeInsets.only(- top: 14,- left: 14,- right: 12,- ),- child: Text(- context- .strings- .autoLockFeatureDescription,- style: textTheme.miniFaint,- textAlign: TextAlign.left,- ),- )- : const SizedBox.shrink(),- ],- )- : const SizedBox.shrink(),+ ],+ )+ : const SizedBox.shrink(),+ ],),- PlatformDetector.isMobile()- ? Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- SizedBox(height: appLock ? 24 : 8),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.strings.hideContent,- ),- alignCaptionedTextToLeft: true,- singleBorderRadius: 8,- menuItemColor: colorTheme.fillFaint,- trailingWidget: ToggleSwitchWidget(- value: () => hideAppContent,- onChanged: () => _onHideContent(),- ),- ),- Padding(- padding: const EdgeInsets.only(- top: 14,- left: 14,- right: 12,- ),- child: Text(- Platform.isAndroid- ? context- .strings- .hideContentDescriptionAndroid- : context- .strings- .hideContentDescriptioniOS,- style: textTheme.miniFaint,- textAlign: TextAlign.left,- ),- ),- ],- )- : const SizedBox.shrink(),- ],- ),- ),- );- }, childCount: 1),+ ),+ );+ }, childCount: 1),+ ),+ ],),- ],+ ),),);}diff --git a/mobile/packages/lock_screen/lib/ui/lock_screen_password.dart b/mobile/packages/lock_screen/lib/ui/lock_screen_password.dartindex 5bbb303eac..faf631b4a2 100644--- a/mobile/packages/lock_screen/lib/ui/lock_screen_password.dart+++ b/mobile/packages/lock_screen/lib/ui/lock_screen_password.dart@@ -1,11 +1,10 @@+import "package:ente_components/ente_components.dart";import "package:ente_lock_screen/lock_screen_settings.dart";import "package:ente_lock_screen/ui/lock_screen_confirm_password.dart";import "package:ente_lock_screen/ui/lock_screen_options.dart";+import "package:ente_lock_screen/ui/lock_screen_submit_fab.dart";import "package:ente_strings/ente_strings.dart";import "package:ente_ui/components/android_text_input_autofocus.dart";-import "package:ente_ui/components/buttons/dynamic_fab.dart";-import "package:ente_ui/components/text_input_widget.dart";-import "package:ente_ui/theme/ente_theme.dart";import "package:flutter/material.dart";import "package:flutter/services.dart";import "package:flutter_svg/flutter_svg.dart";@@ -62,21 +61,10 @@ class _LockScreenPasswordState extends State<LockScreenPassword> {@overrideWidget build(BuildContext context) {- final colorTheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);- final isKeypadOpen = MediaQuery.viewInsetsOf(context).bottom > 100;-- FloatingActionButtonLocation? fabLocation() {- if (isKeypadOpen) {- return null;- } else {- return FloatingActionButtonLocation.centerFloat;- }- }+ final colorTheme = context.componentColors;return Scaffold(backgroundColor: colorTheme.backgroundBase,- resizeToAvoidBottomInset: isKeypadOpen,appBar: AppBar(backgroundColor: colorTheme.backgroundBase,elevation: 0,@@ -92,24 +80,15 @@ class _LockScreenPasswordState extends State<LockScreenPassword> {title: SvgPicture.asset(LockScreenSettings.instance.appLogoAsset,height: LockScreenSettings.instance.appLogoHeight,- colorFilter: ColorFilter.mode(colorTheme.primary700, BlendMode.srcIn),+ colorFilter: ColorFilter.mode(colorTheme.primary, BlendMode.srcIn),),),- floatingActionButton: ValueListenableBuilder<bool>(- valueListenable: _isFormValid,- builder: (context, isFormValid, child) {- return DynamicFAB(- isKeypadOpen: isKeypadOpen,- buttonText: context.strings.next,- isFormValid: isFormValid,- onPressedFunction: () async {- _submitNotifier.value = !_submitNotifier.value;- },- );- },+ floatingActionButton: LockScreenSubmitFab(+ label: context.strings.next,+ isFormValid: _isFormValid,+ onSubmit: () => _submitNotifier.value = !_submitNotifier.value,),- floatingActionButtonLocation: fabLocation(),- floatingActionButtonAnimator: NoScalingAnimation(),+ floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,body: SingleChildScrollView(child: Center(child: Padding(@@ -129,21 +108,21 @@ class _LockScreenPasswordState extends State<LockScreenPassword> {? context.strings.enterAppLockPassword: context.strings.setNewPassword,textAlign: TextAlign.center,- style: textTheme.bodyBold,+ style: TextStyles.bodyBold,),const Padding(padding: EdgeInsets.all(12)),Padding(padding: const EdgeInsets.symmetric(horizontal: 16),child: AndroidTextInputAutofocus(focusNode: _focusNode,- child: TextInputWidget(+ child: TextInputComponent(hintText: context.strings.password,- autoFocus: true,+ autofocus: true,focusNode: _focusNode,textCapitalization: TextCapitalization.none,+ textInputAction: TextInputAction.done,isPasswordInput: true,- shouldSurfaceExecutionStates: false,- onChange: (p0) {+ onChanged: (p0) {_passwordController.text = p0;_isFormValid.value =_passwordController.text.isNotEmpty;