π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refactor: remove LockScreenConfig usage and update UI components to use SVG assets
AmanRajSinghMouryae6e16061686e
diff --git a/mobile/packages/lock_screen/lib/lock_screen_config.dart b/mobile/packages/lock_screen/lib/lock_screen_config.dartdeleted file mode 100644index 3ac27f61c5..0000000000--- a/mobile/packages/lock_screen/lib/lock_screen_config.dart+++ /dev/null@@ -1,175 +0,0 @@-import "package:ente_ui/theme/colors.dart";-import "package:ente_ui/theme/ente_theme.dart";-import "package:ente_ui/theme/theme_config.dart";-import "package:flutter/material.dart";--/// Configuration for lock screen UI-class LockScreenConfig {- final Widget titleWidget;- final Widget Function(BuildContext, TextEditingController?) iconBuilder;- final double pinBoxHeight;- final double pinBoxWidth;- final EdgeInsets? pinBoxPadding;- final double pinBoxBorderRadius;- final Color? pinBoxBorderColor;- final Color? pinBoxBackgroundColor;- final bool useDynamicColors;-- const LockScreenConfig({- required this.titleWidget,- required this.iconBuilder,- required this.pinBoxHeight,- required this.pinBoxWidth,- this.pinBoxPadding,- required this.pinBoxBorderRadius,- this.pinBoxBorderColor,- this.pinBoxBackgroundColor,- this.useDynamicColors = false,- });-- /// Default configuration for Auth app- static const LockScreenConfig auth = LockScreenConfig(- titleWidget: SizedBox.shrink(),- iconBuilder: _buildAuthIcon,- pinBoxHeight: 48,- pinBoxWidth: 48,- pinBoxPadding: EdgeInsets.only(top: 6.0),- pinBoxBorderRadius: 15.0,- pinBoxBorderColor: Color.fromRGBO(45, 194, 98, 1.0),- pinBoxBackgroundColor: null,- useDynamicColors: false,- );-- /// Configuration for Locker app- static LockScreenConfig locker = LockScreenConfig(- titleWidget: _buildLockerTitle(),- iconBuilder: _buildLockerIcon,- pinBoxHeight: 48,- pinBoxWidth: 48,- pinBoxPadding: const EdgeInsets.only(top: 6.0),- pinBoxBorderRadius: 15.0,- pinBoxBorderColor: null,- pinBoxBackgroundColor: null,- useDynamicColors: true,- );-- /// Get current configuration based on AppThemeConfig- static LockScreenConfig get current {- switch (AppThemeConfig.currentApp) {- case EnteApp.locker:- return locker;- case EnteApp.auth:- return auth;- }- }-- /// Check if title should be shown (not a SizedBox.shrink)- bool get showTitle => titleWidget is! SizedBox;-- /// Get border color based on config and theme- Color getBorderColor(EnteColorScheme colorTheme) {- if (useDynamicColors) {- return colorTheme.fillMuted;- }- return pinBoxBorderColor ?? colorTheme.fillMuted;- }-- /// Get background color based on config and theme- Color? getBackgroundColor(EnteColorScheme colorTheme) {- if (useDynamicColors) {- return colorTheme.backgroundBase;- }- return pinBoxBackgroundColor;- }-- // Helper methods for building title- static Widget _buildLockerTitle() {- return Image.asset(- 'assets/locker-logo-blue.png',- height: 24,- );- }-- // Helper methods for building icons- static Widget _buildAuthIcon(- BuildContext context,- TextEditingController? controller,- ) {- final colorTheme = getEnteColorScheme(context);- return SizedBox(- height: 120,- width: 120,- child: Stack(- alignment: Alignment.center,- children: [- Container(- width: 82,- height: 82,- decoration: BoxDecoration(- shape: BoxShape.circle,- gradient: LinearGradient(- colors: [- Colors.grey.shade500.withValues(alpha: 0.2),- Colors.grey.shade50.withValues(alpha: 0.1),- Colors.grey.shade400.withValues(alpha: 0.2),- Colors.grey.shade300.withValues(alpha: 0.4),- ],- begin: Alignment.topCenter,- end: Alignment.bottomCenter,- ),- ),- child: Padding(- padding: const EdgeInsets.all(1.0),- child: Container(- decoration: BoxDecoration(- shape: BoxShape.circle,- color: colorTheme.backgroundBase,- ),- ),- ),- ),- if (controller != null)- SizedBox(- height: 75,- width: 75,- child: ValueListenableBuilder(- valueListenable: controller,- builder: (context, value, child) {- return TweenAnimationBuilder<double>(- tween: Tween<double>(- begin: 0,- end: controller.text.length / 4,- ),- curve: Curves.ease,- duration: const Duration(milliseconds: 250),- builder: (context, value, _) => CircularProgressIndicator(- backgroundColor: colorTheme.fillFaintPressed,- value: value,- color: colorTheme.primary400,- strokeWidth: 1.5,- ),- );- },- ),- ),- Icon(- Icons.lock,- color: colorTheme.textBase,- size: 30,- ),- ],- ),- );- }-- static Widget _buildLockerIcon(- BuildContext context,- TextEditingController? controller,- ) {- return Image.asset(- 'packages/ente_lock_screen/assets/locker_pin.png',- width: 129,- height: 95,- );- }-}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 dc8e52b227..cac0d99965 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,4 +1,3 @@-import "package:ente_lock_screen/lock_screen_config.dart";import "package:ente_lock_screen/lock_screen_settings.dart";import "package:ente_strings/ente_strings.dart";import "package:ente_ui/components/buttons/dynamic_fab.dart";@@ -6,6 +5,7 @@ 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";class LockScreenConfirmPassword extends StatefulWidget {const LockScreenConfirmPassword({@@ -58,7 +58,6 @@ class _LockScreenConfirmPasswordState extends State<LockScreenConfirmPassword> {Widget build(BuildContext context) {final colorTheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);- final config = LockScreenConfig.current;final isKeypadOpen = MediaQuery.viewInsetsOf(context).bottom > 100;FloatingActionButtonLocation? fabLocation() {@@ -70,11 +69,12 @@ class _LockScreenConfirmPasswordState extends State<LockScreenConfirmPassword> {}return Scaffold(- backgroundColor: config.getBackgroundColor(colorTheme),+ backgroundColor: colorTheme.backgroundBase,resizeToAvoidBottomInset: isKeypadOpen,appBar: AppBar(- backgroundColor: config.getBackgroundColor(colorTheme),+ backgroundColor: colorTheme.backgroundBase,elevation: 0,+ scrolledUnderElevation: 0,leading: IconButton(onPressed: () {FocusScope.of(context).unfocus();@@ -85,8 +85,15 @@ class _LockScreenConfirmPasswordState extends State<LockScreenConfirmPassword> {color: colorTheme.textBase,),),- centerTitle: config.showTitle,- title: config.titleWidget,+ centerTitle: true,+ title: SvgPicture.asset(+ 'assets/svg/app-logo.svg',+ height: 24,+ colorFilter: ColorFilter.mode(+ colorTheme.primary700,+ BlendMode.srcIn,+ ),+ ),),floatingActionButton: ValueListenableBuilder<bool>(valueListenable: _isFormValid,@@ -106,15 +113,17 @@ class _LockScreenConfirmPasswordState extends State<LockScreenConfirmPassword> {body: SingleChildScrollView(child: Center(child: Padding(- padding: EdgeInsets.symmetric(- horizontal: config.showTitle ? 16.0 : 0,- ),+ padding: const EdgeInsets.symmetric(horizontal: 16.0),child: Column(crossAxisAlignment: CrossAxisAlignment.center,children: [- SizedBox(height: config.showTitle ? 40 : 0),- config.iconBuilder(context, null),- SizedBox(height: config.showTitle ? 24 : 0),+ const SizedBox(height: 40),+ Image.asset(+ 'assets/lock_screen_icon.png',+ width: 129,+ height: 95,+ ),+ const SizedBox(height: 24),Text(context.strings.reEnterPassword,textAlign: TextAlign.center,diff --git a/mobile/packages/lock_screen/lib/ui/lock_screen_confirm_pin.dart b/mobile/packages/lock_screen/lib/ui/lock_screen_confirm_pin.dartindex 3353d45cb2..258f755db2 100644--- a/mobile/packages/lock_screen/lib/ui/lock_screen_confirm_pin.dart+++ b/mobile/packages/lock_screen/lib/ui/lock_screen_confirm_pin.dart@@ -1,12 +1,14 @@import "dart:io";-import "package:ente_lock_screen/lock_screen_config.dart";import "package:ente_lock_screen/lock_screen_settings.dart";import "package:ente_lock_screen/ui/custom_pin_keypad.dart";import "package:ente_strings/ente_strings.dart";+import "package:ente_ui/theme/colors.dart";import "package:ente_ui/theme/ente_theme.dart";+import "package:ente_ui/theme/text_style.dart";import "package:flutter/material.dart";import "package:flutter/services.dart";+import "package:flutter_svg/flutter_svg.dart";import "package:pinput/pinput.dart";class LockScreenConfirmPin extends StatefulWidget {@@ -58,13 +60,13 @@ class _LockScreenConfirmPinState extends State<LockScreenConfirmPin> {Widget build(BuildContext context) {final colorTheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);- final config = LockScreenConfig.current;return Scaffold(- backgroundColor: config.getBackgroundColor(colorTheme),+ backgroundColor: colorTheme.backgroundBase,appBar: AppBar(- backgroundColor: config.getBackgroundColor(colorTheme),+ backgroundColor: colorTheme.backgroundBase,elevation: 0,+ scrolledUnderElevation: 0,leading: IconButton(onPressed: () {Navigator.of(context).pop(false);@@ -74,43 +76,54 @@ class _LockScreenConfirmPinState extends State<LockScreenConfirmPin> {color: colorTheme.textBase,),),- centerTitle: config.showTitle,- title: config.titleWidget,+ centerTitle: true,+ title: SvgPicture.asset(+ 'assets/svg/app-logo.svg',+ height: 24,+ colorFilter: ColorFilter.mode(+ colorTheme.primary700,+ BlendMode.srcIn,+ ),+ ),),floatingActionButton: isPlatformDesktop? null: CustomPinKeypad(controller: _confirmPinController),floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,body: SingleChildScrollView(- child: _getBody(colorTheme, textTheme, config),+ child: _getBody(colorTheme, textTheme),),);}- Widget _getBody(colorTheme, textTheme, LockScreenConfig config) {+ Widget _getBody(EnteColorScheme colorTheme, EnteTextTheme textTheme) {final pinPutDecoration = PinTheme(- height: config.pinBoxHeight,- width: config.pinBoxWidth,- padding: config.pinBoxPadding,+ height: 48,+ width: 48,+ padding: const EdgeInsets.only(top: 6.0),decoration: BoxDecoration(- color: config.getBackgroundColor(colorTheme),+ color: colorTheme.backgroundBase,border: Border.all(- color: config.getBorderColor(colorTheme),+ color: colorTheme.fillMuted,width: 1,),- borderRadius: BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),),);return Center(child: Padding(- padding: EdgeInsets.symmetric(horizontal: config.showTitle ? 24.0 : 0),+ padding: const EdgeInsets.symmetric(horizontal: 24.0),child: Column(crossAxisAlignment: CrossAxisAlignment.center,children: [- SizedBox(height: config.showTitle ? 40 : 0),- config.iconBuilder(context, _confirmPinController),- SizedBox(height: config.showTitle ? 24 : 0),+ const SizedBox(height: 40),+ Image.asset(+ 'assets/lock_screen_icon.png',+ width: 129,+ height: 95,+ ),+ const SizedBox(height: 24),Text(context.strings.reEnterPin,style: textTheme.bodyBold,@@ -125,51 +138,42 @@ class _LockScreenConfirmPinState extends State<LockScreenConfirmPin> {defaultPinTheme: pinPutDecoration.copyWith(textStyle: textTheme.h3Bold,decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(- color: config.getBorderColor(colorTheme),+ color: colorTheme.fillMuted,),),),submittedPinTheme: pinPutDecoration.copyWith(textStyle: textTheme.h3Bold.copyWith(- color: config.showTitle ? colorTheme.primary700 : null,+ color: colorTheme.primary700,),decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(- color: config.showTitle- ? colorTheme.primary700- : colorTheme.fillBase,+ color: colorTheme.primary700,),),),followingPinTheme: pinPutDecoration.copyWith(decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(- color: config.getBorderColor(colorTheme),+ color: colorTheme.fillMuted,),),),focusedPinTheme: pinPutDecoration.copyWith(decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(- color: config.showTitle- ? colorTheme.fillBase- : config.getBorderColor(colorTheme),+ color: colorTheme.fillBase,),),),errorPinTheme: pinPutDecoration.copyWith(decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(color: colorTheme.warning400,),diff --git a/mobile/packages/lock_screen/lib/ui/lock_screen_password.dart b/mobile/packages/lock_screen/lib/ui/lock_screen_password.dartindex 06b4a930b9..f795806b89 100644--- a/mobile/packages/lock_screen/lib/ui/lock_screen_password.dart+++ b/mobile/packages/lock_screen/lib/ui/lock_screen_password.dart@@ -1,7 +1,6 @@import "dart:convert";import "package:ente_crypto_dart/ente_crypto_dart.dart";-import "package:ente_lock_screen/lock_screen_config.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";@@ -11,6 +10,7 @@ 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";/// [isChangingLockScreenSettings] Authentication required for changing lock screen settings./// Set to true when the app requires the user to authenticate before allowing@@ -69,7 +69,6 @@ class _LockScreenPasswordState extends State<LockScreenPassword> {Widget build(BuildContext context) {final colorTheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);- final config = LockScreenConfig.current;final isKeypadOpen = MediaQuery.viewInsetsOf(context).bottom > 100;FloatingActionButtonLocation? fabLocation() {@@ -81,11 +80,12 @@ class _LockScreenPasswordState extends State<LockScreenPassword> {}return Scaffold(- backgroundColor: config.getBackgroundColor(colorTheme),+ backgroundColor: colorTheme.backgroundBase,resizeToAvoidBottomInset: isKeypadOpen,appBar: AppBar(- backgroundColor: config.getBackgroundColor(colorTheme),+ backgroundColor: colorTheme.backgroundBase,elevation: 0,+ scrolledUnderElevation: 0,leading: IconButton(onPressed: () {FocusScope.of(context).unfocus();@@ -96,8 +96,15 @@ class _LockScreenPasswordState extends State<LockScreenPassword> {color: colorTheme.textBase,),),- centerTitle: config.showTitle,- title: config.titleWidget,+ centerTitle: true,+ title: SvgPicture.asset(+ 'assets/svg/app-logo.svg',+ height: 24,+ colorFilter: ColorFilter.mode(+ colorTheme.primary700,+ BlendMode.srcIn,+ ),+ ),),floatingActionButton: ValueListenableBuilder<bool>(valueListenable: _isFormValid,@@ -117,15 +124,17 @@ class _LockScreenPasswordState extends State<LockScreenPassword> {body: SingleChildScrollView(child: Center(child: Padding(- padding: EdgeInsets.symmetric(- horizontal: config.showTitle ? 16.0 : 0,- ),+ padding: const EdgeInsets.symmetric(horizontal: 16.0),child: Column(crossAxisAlignment: CrossAxisAlignment.center,children: [- SizedBox(height: config.showTitle ? 40 : 0),- config.iconBuilder(context, null),- SizedBox(height: config.showTitle ? 24 : 0),+ const SizedBox(height: 40),+ Image.asset(+ 'assets/lock_screen_icon.png',+ width: 129,+ height: 95,+ ),+ const SizedBox(height: 24),Text(widget.isChangingLockScreenSettings? context.strings.enterAppLockPassworddiff --git a/mobile/packages/lock_screen/lib/ui/lock_screen_pin.dart b/mobile/packages/lock_screen/lib/ui/lock_screen_pin.dartindex ee8b6f7ff6..c95592ec38 100644--- a/mobile/packages/lock_screen/lib/ui/lock_screen_pin.dart+++ b/mobile/packages/lock_screen/lib/ui/lock_screen_pin.dart@@ -2,7 +2,6 @@ import "dart:convert";import "dart:io";import "package:ente_crypto_dart/ente_crypto_dart.dart";-import "package:ente_lock_screen/lock_screen_config.dart";import "package:ente_lock_screen/lock_screen_settings.dart";import "package:ente_lock_screen/ui/custom_pin_keypad.dart";import "package:ente_lock_screen/ui/lock_screen_confirm_pin.dart";@@ -13,6 +12,7 @@ import "package:ente_ui/theme/ente_theme.dart";import "package:ente_ui/theme/text_style.dart";import "package:flutter/material.dart";import "package:flutter/services.dart";+import "package:flutter_svg/flutter_svg.dart";import 'package:pinput/pinput.dart';/// [isChangingLockScreenSettings] Authentication required for changing lock screen settings.@@ -49,6 +49,7 @@ class _LockScreenPinState extends State<LockScreenPin> {bool isPinValid = false;int invalidAttemptsCount = 0;bool isPlatformDesktop = false;+@overridevoid initState() {super.initState();@@ -125,26 +126,26 @@ class _LockScreenPinState extends State<LockScreenPin> {Widget build(BuildContext context) {final colorTheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);- final config = LockScreenConfig.current;final pinPutDecoration = PinTheme(- height: config.pinBoxHeight,- width: config.pinBoxWidth,- padding: config.pinBoxPadding,+ height: 48,+ width: 48,+ padding: const EdgeInsets.only(top: 6.0),decoration: BoxDecoration(- color: config.getBackgroundColor(colorTheme),+ color: colorTheme.backgroundBase,border: Border.all(- color: config.getBorderColor(colorTheme),+ color: colorTheme.fillMuted,width: 1,),- borderRadius: BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),),);return Scaffold(- backgroundColor: config.getBackgroundColor(colorTheme),+ backgroundColor: colorTheme.backgroundBase,appBar: AppBar(- backgroundColor: config.getBackgroundColor(colorTheme),+ backgroundColor: colorTheme.backgroundBase,elevation: 0,+ scrolledUnderElevation: 0,leading: IconButton(onPressed: () {Navigator.of(context).pop(false);@@ -154,15 +155,22 @@ class _LockScreenPinState extends State<LockScreenPin> {color: colorTheme.textBase,),),- centerTitle: config.showTitle,- title: config.titleWidget,+ centerTitle: true,+ title: SvgPicture.asset(+ 'assets/svg/app-logo.svg',+ height: 24,+ colorFilter: ColorFilter.mode(+ colorTheme.primary700,+ BlendMode.srcIn,+ ),+ ),),floatingActionButton: isPlatformDesktop? null: CustomPinKeypad(controller: _pinController),floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,body: SingleChildScrollView(- child: _getBody(colorTheme, textTheme, pinPutDecoration, config),+ child: _getBody(colorTheme, textTheme, pinPutDecoration),),);}@@ -171,17 +179,20 @@ class _LockScreenPinState extends State<LockScreenPin> {EnteColorScheme colorTheme,EnteTextTheme textTheme,PinTheme pinPutDecoration,- LockScreenConfig config,) {return Center(child: Padding(- padding: EdgeInsets.symmetric(horizontal: config.showTitle ? 24.0 : 0),+ padding: const EdgeInsets.symmetric(horizontal: 24.0),child: Column(crossAxisAlignment: CrossAxisAlignment.center,children: [- SizedBox(height: config.showTitle ? 40 : 0),- config.iconBuilder(context, _pinController),- SizedBox(height: config.showTitle ? 24 : 0),+ const SizedBox(height: 40),+ Image.asset(+ 'assets/lock_screen_icon.png',+ width: 129,+ height: 95,+ ),+ const SizedBox(height: 24),Text(widget.isChangingLockScreenSettings? context.strings.enterAppLockPin@@ -198,51 +209,42 @@ class _LockScreenPinState extends State<LockScreenPin> {defaultPinTheme: pinPutDecoration.copyWith(textStyle: textTheme.h3Bold,decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(- color: config.getBorderColor(colorTheme),+ color: colorTheme.fillMuted,),),),submittedPinTheme: pinPutDecoration.copyWith(textStyle: textTheme.h3Bold.copyWith(- color: config.showTitle ? colorTheme.primary700 : null,+ color: colorTheme.primary700,),decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(- color: config.showTitle- ? colorTheme.primary700- : colorTheme.fillBase,+ color: colorTheme.primary700,),),),followingPinTheme: pinPutDecoration.copyWith(decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(- color: config.getBorderColor(colorTheme),+ color: colorTheme.fillMuted,),),),focusedPinTheme: pinPutDecoration.copyWith(decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(- color: config.showTitle- ? colorTheme.fillBase- : config.getBorderColor(colorTheme),+ color: colorTheme.fillBase,),),),errorPinTheme: pinPutDecoration.copyWith(decoration: BoxDecoration(- borderRadius:- BorderRadius.circular(config.pinBoxBorderRadius),+ borderRadius: BorderRadius.circular(15.0),border: Border.all(color: colorTheme.warning400,),