From 562bce8c4fea4e8c553ff441f0bcaa305738f8c9 Mon Sep 17 00:00:00 2001 From: mohammad Date: Thu, 15 Aug 2024 12:34:17 +0300 Subject: [PATCH] forget password changes --- lib/pages/auth/bloc/auth_bloc.dart | 13 ++++++++++- lib/pages/auth/view/forget_password_page.dart | 2 +- .../auth/view/forget_password_web_page.dart | 22 ++++++++----------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/pages/auth/bloc/auth_bloc.dart b/lib/pages/auth/bloc/auth_bloc.dart index 5898f2dd..e09feea6 100644 --- a/lib/pages/auth/bloc/auth_bloc.dart +++ b/lib/pages/auth/bloc/auth_bloc.dart @@ -83,7 +83,10 @@ class AuthBloc extends Bloc { } emit(SuccessForgetState()); } catch (failure) { - emit(FailureForgetState(error: failure.toString())); + forgetValidate='Invalid Credentials!'; + emit(AuthInitialState()); + + // emit(FailureForgetState(error: failure.toString())); } } @@ -103,6 +106,7 @@ class AuthBloc extends Bloc { String maskedEmail = ''; String otpCode = ''; String validate = ''; + String forgetValidate = ''; String regionUuid = ''; static Token token = Token.emptyConstructor(); static UserModel? user; @@ -365,10 +369,17 @@ class AuthBloc extends Bloc { emit(LoginInitial()); return checkValidate; } + changeValidate(ChangeValidateEvent event, Emitter emit,){ emit(AuthLoading()); validate=''; print('validate'); emit(LoginInitial()); } + changeForgetValidate(ChangeValidateEvent event, Emitter emit,){ + emit(AuthLoading()); + forgetValidate=''; + print('validate'); + emit(LoginInitial()); + } } diff --git a/lib/pages/auth/view/forget_password_page.dart b/lib/pages/auth/view/forget_password_page.dart index da09a888..f90b2ef4 100644 --- a/lib/pages/auth/view/forget_password_page.dart +++ b/lib/pages/auth/view/forget_password_page.dart @@ -12,7 +12,7 @@ class ForgetPasswordPage extends StatelessWidget { Widget build(BuildContext context) { return const ResponsiveLayout( desktopBody: ForgetPasswordWebPage(), - mobileBody:ForgetPasswordMobilePage() + mobileBody:ForgetPasswordWebPage() ); } } diff --git a/lib/pages/auth/view/forget_password_web_page.dart b/lib/pages/auth/view/forget_password_web_page.dart index cb137c6b..07b59495 100644 --- a/lib/pages/auth/view/forget_password_web_page.dart +++ b/lib/pages/auth/view/forget_password_web_page.dart @@ -204,7 +204,6 @@ class ForgetPasswordWebPage extends StatelessWidget { Text( "One Time Password", style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400), - ), const SizedBox(height: 10), SizedBox( @@ -220,9 +219,7 @@ class ForgetPasswordWebPage extends StatelessWidget { child: Center( child: InkWell( onTap: () { - BlocProvider.of( - context) - .add(StartTimerEvent()); + BlocProvider.of(context).add(StartTimerEvent()); }, child: Text( 'Get Code ${state is TimerState && !state.isButtonEnabled ? "(${BlocProvider.of(context).formattedTime(state.remainingTime)}) " : ""}', @@ -251,20 +248,17 @@ class ForgetPasswordWebPage extends StatelessWidget { Text( "Password", style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400), - ), const SizedBox(height: 10), SizedBox( child: TextFormField( validator: forgetBloc.passwordValidator, keyboardType: TextInputType.visiblePassword, - controller: - forgetBloc.forgetPasswordController, + controller: forgetBloc.forgetPasswordController, decoration: textBoxDecoration()!.copyWith( hintText: 'At least 8 characters', ), - style: - const TextStyle(color: Colors.black), + style: const TextStyle(color: Colors.black), ), ), ], @@ -283,9 +277,7 @@ class ForgetPasswordWebPage extends StatelessWidget { backgroundColor: ColorsManager.btnColor, child: const Text('Submit'), onPressed: () { - if (forgetBloc - .forgetFormKey.currentState! - .validate()) { + if (forgetBloc.forgetFormKey.currentState!.validate()) { forgetBloc.add(ChangePasswordEvent()); } }, @@ -329,7 +321,11 @@ class ForgetPasswordWebPage extends StatelessWidget { ), ), const SizedBox(height: 15.0), - + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ SizedBox(child: Text(forgetBloc.forgetValidate, + style: const TextStyle(fontWeight: FontWeight.w700,color: ColorsManager.red ),),)],) ], ), ),