From 4acc409de0a0014a9fbb240a9a97213c81c7481a Mon Sep 17 00:00:00 2001 From: jahongireshonqulov Date: Sat, 1 Nov 2025 11:31:37 +0500 Subject: [PATCH] feat:some changes done in login --- lib/core/theme/app_theme_colors.dart | 39 +-- .../login_page/widgets/login_body.dart | 230 +++++++++++------- .../presentation/widgets/app_button.dart | 9 +- .../common/presentation/widgets/w_layout.dart | 12 +- .../blocs/splash_bloc/splash_bloc.dart | 3 +- lib/main.dart | 2 +- 6 files changed, 182 insertions(+), 113 deletions(-) diff --git a/lib/core/theme/app_theme_colors.dart b/lib/core/theme/app_theme_colors.dart index a456cb8..11d4826 100644 --- a/lib/core/theme/app_theme_colors.dart +++ b/lib/core/theme/app_theme_colors.dart @@ -7,31 +7,33 @@ class AppThemeColors extends ThemeExtension { final Color iconColor; final Color buttonInactiveColor; final Color borderColor; - + final Color inActiveColor; AppThemeColors({ required this.onBoardingColor, required this.boxShadow, required this.iconColor, required this.buttonInactiveColor, - required this.borderColor + required this.borderColor, + required this.inActiveColor, }); static AppThemeColors light = AppThemeColors( - onBoardingColor: AppColors.cFFFFFF, - boxShadow: AppColors.cD6D4D4, - buttonInactiveColor: AppColors.cE2E4EA, - iconColor: AppColors.cFFFFFF, - borderColor:AppColors.cE2E4EA - + onBoardingColor: AppColors.cFFFFFF, + boxShadow: AppColors.cD6D4D4, + buttonInactiveColor: AppColors.cE2E4EA, + iconColor: AppColors.cFFFFFF, + borderColor: AppColors.cE2E4EA, + inActiveColor: AppColors.cE2E4EA, ); static AppThemeColors dark = AppThemeColors( - onBoardingColor: AppColors.c131720, - boxShadow: AppColors.c524242, - buttonInactiveColor: AppColors.c292F3D, - iconColor: AppColors.c131720, - borderColor: AppColors.c292F3D + onBoardingColor: AppColors.c131720, + boxShadow: AppColors.c524242, + buttonInactiveColor: AppColors.c292F3D, + iconColor: AppColors.c131720, + borderColor: AppColors.c292F3D, + inActiveColor: AppColors.c292F3D, ); @override @@ -40,21 +42,24 @@ class AppThemeColors extends ThemeExtension { Color? boxShadow, Color? iconColor, Color? buttonInactiveColor, - Color? borderColor + Color? borderColor, + Color? inActiveColor, }) { return AppThemeColors( onBoardingColor: onBoardingColor ?? this.onBoardingColor, boxShadow: boxShadow ?? this.boxShadow, iconColor: iconColor ?? this.iconColor, buttonInactiveColor: buttonInactiveColor ?? this.buttonInactiveColor, - borderColor: borderColor??this.borderColor + borderColor: borderColor ?? this.borderColor, + inActiveColor: inActiveColor ?? this.inActiveColor, ); } @override ThemeExtension lerp( - covariant ThemeExtension? other, - double t,) { + covariant ThemeExtension? other, + double t, + ) { if (other is! AppThemeColors) return this; return t < 0.5 ? this : other; } diff --git a/lib/feature/auth/presentation/login_page/widgets/login_body.dart b/lib/feature/auth/presentation/login_page/widgets/login_body.dart index 4230f26..88f4cad 100644 --- a/lib/feature/auth/presentation/login_page/widgets/login_body.dart +++ b/lib/feature/auth/presentation/login_page/widgets/login_body.dart @@ -1,3 +1,5 @@ +import 'package:food_delivery_client/core/helpers/formatters.dart'; +import 'package:food_delivery_client/core/helpers/validator_helpers.dart'; import 'package:food_delivery_client/feature/auth/presentation/login_page/widgets/welcome_text.dart'; import 'package:food_delivery_client/feature/common/presentation/widgets/app_text_form_field.dart'; @@ -14,16 +16,30 @@ class _WLoginBodyState extends State { late TextEditingController _phoneNumberController; late TextEditingController _passwordController; final _formKey = GlobalKey(); + bool _isValidForm = false; + + void _validateForm() { + final isValid = _formKey.currentState?.validate() ?? false; + if (isValid != _isValidForm) { + setState(() { + _isValidForm = isValid; + }); + } + } @override void initState() { _phoneNumberController = TextEditingController(); _passwordController = TextEditingController(); + _passwordController.addListener(_validateForm); + _phoneNumberController.addListener(_validateForm); super.initState(); } @override void dispose() { + _phoneNumberController.removeListener(_validateForm); + _passwordController.removeListener(_validateForm); _phoneNumberController.dispose(); _passwordController.dispose(); super.dispose(); @@ -36,114 +52,146 @@ class _WLoginBodyState extends State { autovalidateMode: AutovalidateMode.onUserInteraction, child: WLayout( top: false, + left: false, + right: false, child: Scaffold( body: Stack( children: [ - SvgPicture.asset(AppIcons.icLogin), + SizedBox( + width: context.w, + child: SvgPicture.asset(AppIcons.icLogin, fit: BoxFit.fitWidth), + ), Positioned( child: Material( color: AppColors.cTransparent, - child: - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - 30.verticalSpace, - WBackButton(), - 20.verticalSpace, - WelcomeText( - text: context.loc.welcome_to_volt( - AppLocaleKeys.appName, + child: SingleChildScrollView( + keyboardDismissBehavior: + ScrollViewKeyboardDismissBehavior.onDrag, + child: + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + 30.verticalSpace, + //WBackButton(), + 60.verticalSpace, + WelcomeText( + text: context.loc.welcome_to_volt( + AppLocaleKeys.appName, + ), ), - ), - 8.verticalSpace, - Text( - context.loc.please_login, - style: AppTextStyles.size14Regular.copyWith( - color: AppColors.cA7AEC1, - height: 1.6, + 8.verticalSpace, + Text( + context.loc.please_login, + style: AppTextStyles.size14Regular.copyWith( + color: AppColors.cA7AEC1, + height: 1.6, + ), ), - ), - 54.verticalSpace, - Text( - context.loc.email_or_phone, - style: context.appThemeTextStyles.size16Medium, - ), - 10.verticalSpace, - AppTextFormField( - controller: _phoneNumberController, - hintText: context.loc.enter_email_or_phone, - ), - 20.verticalSpace, - Text( - context.loc.password, - style: context.appThemeTextStyles.size16Medium, - ), - 10.verticalSpace, - AppTextFormField( - obscureText: true, - controller: _passwordController, - hintText: context.loc.enter_password, - ), - 10.verticalSpace, - Align( - alignment: AlignmentGeometry.centerRight, - child: TextButton( - onPressed: () {}, - child: Text( - context.loc.forgot_password, - style: AppTextStyles.size14Regular.copyWith( - color: AppColors.cFF6F00, + 54.verticalSpace, + Text( + context.loc.email_or_phone, + style: context.appThemeTextStyles.size16Medium, + ), + 10.verticalSpace, + AppTextFormField( + prefixIcon: Text("+ 998"), + controller: _phoneNumberController, + hintText: context.loc.enter_email_or_phone, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + Formatters.phoneFormatter, + LengthLimitingTextInputFormatter(12), + ], + validator: (value) { + return Validators.validatePhoneNumber( + _phoneNumberController.text.trim(), + ); + }, + ), + 20.verticalSpace, + Text( + context.loc.password, + style: context.appThemeTextStyles.size16Medium, + ), + 10.verticalSpace, + AppTextFormField( + obscureText: true, + controller: _passwordController, + hintText: context.loc.enter_password, + validator: (value) { + return Validators.validatePassword( + _passwordController.text.trim(), + ); + }, + ), + 10.verticalSpace, + Align( + alignment: AlignmentGeometry.centerRight, + child: TextButton( + onPressed: () {}, + child: Text( + context.loc.forgot_password, + style: AppTextStyles.size14Regular.copyWith( + color: AppColors.cFF6F00, + ), ), ), ), - ), - 60.verticalSpace, - AppButton( - name: context.loc.login, - onPressed: () { - if (_formKey.currentState?.validate() ?? false) {} - }, - ), - 15.verticalSpace, - Align( - alignment: AlignmentGeometry.center, - child: RichText( - text: TextSpan( - text: context.loc.dont_have_account, - style: context.appThemeTextStyles.size14Regular, - children: [ - WidgetSpan( - baseline: TextBaseline.alphabetic, - alignment: PlaceholderAlignment.baseline, - - child: TextButton( - onPressed: () {}, - style: ButtonStyle( - shadowColor: WidgetStatePropertyAll( - AppColors.cFF6F00.newWithOpacity(.2), + 60.verticalSpace, + AppButton( + name: context.loc.login, + isActive: _isValidForm, + isLoading: false, + onPressed: () { + if (_formKey.currentState?.validate() ?? + false) {} + }, + ), + 15.verticalSpace, + Align( + alignment: AlignmentGeometry.center, + child: RichText( + text: TextSpan( + text: context.loc.dont_have_account, + style: + context.appThemeTextStyles.size14Regular, + children: [ + WidgetSpan( + baseline: TextBaseline.alphabetic, + alignment: PlaceholderAlignment.baseline, + child: TextButton( + onPressed: () {}, + style: ButtonStyle( + shadowColor: WidgetStatePropertyAll( + AppColors.cFF6F00.newWithOpacity( + .2, + ), + ), + padding: WidgetStatePropertyAll( + EdgeInsets.symmetric(horizontal: 4), + ), ), - padding: WidgetStatePropertyAll( - EdgeInsets.zero, + child: Text( + context.loc.register, + style: AppTextStyles.size14Bold + .copyWith( + color: AppColors.cFF6F00, + ), ), ), - child: Text( - context.loc.register, - style: AppTextStyles.size14Bold - .copyWith(color: AppColors.cFF6F00), - ), ), - ), - ], + ], + ), ), ), - ), - ], - ).paddingOnly( - left: 24, - right: 24, - top: context.mq.viewPadding.top, - bottom: context.mq.viewPadding.bottom, - ), + ], + ).paddingOnly( + left: 24, + right: 24, + top: context.mq.viewPadding.top, + bottom: context.mq.viewPadding.bottom, + ), + ), ), ), ], diff --git a/lib/feature/common/presentation/widgets/app_button.dart b/lib/feature/common/presentation/widgets/app_button.dart index 8fffaf9..45db84e 100644 --- a/lib/feature/common/presentation/widgets/app_button.dart +++ b/lib/feature/common/presentation/widgets/app_button.dart @@ -14,6 +14,7 @@ class AppButton extends StatelessWidget { this.leading, this.trailing, this.mainAxisAlignment, + this.isActive = true, this.isLoading = false, }); @@ -28,12 +29,14 @@ class AppButton extends StatelessWidget { final Widget? leading; final Widget? trailing; final bool isLoading; + final bool isActive; + final MainAxisAlignment? mainAxisAlignment; @override Widget build(BuildContext context) { return Bounceable( - onTap: onPressed, + onTap: isActive ? onPressed : null, duration: TimeDelayConst.durationMill150, child: Container( width: width ?? double.infinity, @@ -42,7 +45,9 @@ class AppButton extends StatelessWidget { alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( - color: backgroundColor ?? AppColors.cFF6F00, + color: isActive + ? backgroundColor ?? AppColors.cFF6F00 + : context.appThemeColors.inActiveColor, borderRadius: BorderRadius.circular(borderRadius ?? 12), ), child: isLoading diff --git a/lib/feature/common/presentation/widgets/w_layout.dart b/lib/feature/common/presentation/widgets/w_layout.dart index be3db2c..1427a36 100644 --- a/lib/feature/common/presentation/widgets/w_layout.dart +++ b/lib/feature/common/presentation/widgets/w_layout.dart @@ -6,19 +6,29 @@ class WLayout extends StatelessWidget { this.bgColor, this.bottom = true, this.top = true, + this.left = true, + this.right = true, required this.child, }); final Color? bgColor; final bool bottom; final bool top; + final bool right; + final bool left; final Widget child; @override Widget build(BuildContext context) { return Container( color: bgColor ?? context.theme.scaffoldBackgroundColor, - child: SafeArea(top: top, bottom: bottom, child: child), + child: SafeArea( + top: top, + bottom: bottom, + right: right, + left: left, + child: child, + ), ); } } diff --git a/lib/feature/onboarding/presentation/blocs/splash_bloc/splash_bloc.dart b/lib/feature/onboarding/presentation/blocs/splash_bloc/splash_bloc.dart index 08e94ef..f6a201b 100644 --- a/lib/feature/onboarding/presentation/blocs/splash_bloc/splash_bloc.dart +++ b/lib/feature/onboarding/presentation/blocs/splash_bloc/splash_bloc.dart @@ -17,8 +17,9 @@ class SplashBloc extends Bloc { _onStarted(_Started event, Emitter emit) async { await Future.delayed(TimeDelayConst.duration2); final token = _storageService.getString(key: AppLocaleKeys.token); + log("Token:$token"); if (token != null) { - emit(state.copyWith(status: RequestStatus.loaded)); + emit(state.copyWith(status: RequestStatus.error)); } else { emit(state.copyWith(status: RequestStatus.error)); } diff --git a/lib/main.dart b/lib/main.dart index ab2328e..f032b4c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -50,7 +50,7 @@ class _MyAppState extends State { debugShowCheckedModeBanner: false, theme: AppTheme.lightTheme, darkTheme: AppTheme.darkTheme, - themeMode: ThemeMode.dark, + themeMode: ThemeMode.light, routerConfig: sl().router, locale: state.currentLocale, supportedLocales: L10n.locales,