forget password changes

This commit is contained in:
mohammad
2024-08-15 12:34:17 +03:00
parent f4cb117464
commit 562bce8c4f
3 changed files with 22 additions and 15 deletions

View File

@ -83,7 +83,10 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
} }
emit(SuccessForgetState()); emit(SuccessForgetState());
} catch (failure) { } 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<AuthEvent, AuthState> {
String maskedEmail = ''; String maskedEmail = '';
String otpCode = ''; String otpCode = '';
String validate = ''; String validate = '';
String forgetValidate = '';
String regionUuid = ''; String regionUuid = '';
static Token token = Token.emptyConstructor(); static Token token = Token.emptyConstructor();
static UserModel? user; static UserModel? user;
@ -365,10 +369,17 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
emit(LoginInitial()); emit(LoginInitial());
return checkValidate; return checkValidate;
} }
changeValidate(ChangeValidateEvent event, Emitter<AuthState> emit,){ changeValidate(ChangeValidateEvent event, Emitter<AuthState> emit,){
emit(AuthLoading()); emit(AuthLoading());
validate=''; validate='';
print('validate'); print('validate');
emit(LoginInitial()); emit(LoginInitial());
} }
changeForgetValidate(ChangeValidateEvent event, Emitter<AuthState> emit,){
emit(AuthLoading());
forgetValidate='';
print('validate');
emit(LoginInitial());
}
} }

View File

@ -12,7 +12,7 @@ class ForgetPasswordPage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const ResponsiveLayout( return const ResponsiveLayout(
desktopBody: ForgetPasswordWebPage(), desktopBody: ForgetPasswordWebPage(),
mobileBody:ForgetPasswordMobilePage() mobileBody:ForgetPasswordWebPage()
); );
} }
} }

View File

@ -204,7 +204,6 @@ class ForgetPasswordWebPage extends StatelessWidget {
Text( Text(
"One Time Password", "One Time Password",
style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400), style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
SizedBox( SizedBox(
@ -220,9 +219,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
child: Center( child: Center(
child: InkWell( child: InkWell(
onTap: () { onTap: () {
BlocProvider.of<AuthBloc>( BlocProvider.of<AuthBloc>(context).add(StartTimerEvent());
context)
.add(StartTimerEvent());
}, },
child: Text( child: Text(
'Get Code ${state is TimerState && !state.isButtonEnabled ? "(${BlocProvider.of<AuthBloc>(context).formattedTime(state.remainingTime)}) " : ""}', 'Get Code ${state is TimerState && !state.isButtonEnabled ? "(${BlocProvider.of<AuthBloc>(context).formattedTime(state.remainingTime)}) " : ""}',
@ -251,20 +248,17 @@ class ForgetPasswordWebPage extends StatelessWidget {
Text( Text(
"Password", "Password",
style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400), style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
SizedBox( SizedBox(
child: TextFormField( child: TextFormField(
validator: forgetBloc.passwordValidator, validator: forgetBloc.passwordValidator,
keyboardType: TextInputType.visiblePassword, keyboardType: TextInputType.visiblePassword,
controller: controller: forgetBloc.forgetPasswordController,
forgetBloc.forgetPasswordController,
decoration: textBoxDecoration()!.copyWith( decoration: textBoxDecoration()!.copyWith(
hintText: 'At least 8 characters', hintText: 'At least 8 characters',
), ),
style: style: const TextStyle(color: Colors.black),
const TextStyle(color: Colors.black),
), ),
), ),
], ],
@ -283,9 +277,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
backgroundColor: ColorsManager.btnColor, backgroundColor: ColorsManager.btnColor,
child: const Text('Submit'), child: const Text('Submit'),
onPressed: () { onPressed: () {
if (forgetBloc if (forgetBloc.forgetFormKey.currentState!.validate()) {
.forgetFormKey.currentState!
.validate()) {
forgetBloc.add(ChangePasswordEvent()); forgetBloc.add(ChangePasswordEvent());
} }
}, },
@ -329,7 +321,11 @@ class ForgetPasswordWebPage extends StatelessWidget {
), ),
), ),
const SizedBox(height: 15.0), 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 ),),)],)
], ],
), ),
), ),