diff --git a/lib/features/auth/bloc/auth_cubit.dart b/lib/features/auth/bloc/auth_cubit.dart index f0025b2..f7f3544 100644 --- a/lib/features/auth/bloc/auth_cubit.dart +++ b/lib/features/auth/bloc/auth_cubit.dart @@ -270,7 +270,7 @@ class AuthCubit extends Cubit { Future reSendOtp({bool? forget}) async { try { - emit(AuthLoading()); + emit(ResendOtpLoading()); await AuthenticationAPI.sendOtp(body: { 'email': email, 'type': forget == true ? 'PASSWORD' : 'VERIFICATION' @@ -286,7 +286,10 @@ class AuthCubit extends Cubit { } verifyOtp(bool isForgotPass) async { - emit(AuthLoginLoading()); + if (otpCode.length != 6) { + return; + } + emit(AuthOtpLoading()); try { final response = await AuthenticationAPI.verifyPassCode(body: { 'email': email, diff --git a/lib/features/auth/bloc/auth_state.dart b/lib/features/auth/bloc/auth_state.dart index 1692d4b..6c506e8 100644 --- a/lib/features/auth/bloc/auth_state.dart +++ b/lib/features/auth/bloc/auth_state.dart @@ -20,9 +20,13 @@ class AuthLoginLoading extends AuthLoading {} class AuthLoginSuccess extends AuthSuccess {} +class AuthSignUpSuccess extends AuthSuccess {} + class AuthOtpSuccess extends AuthSuccess {} -class AuthSignUpSuccess extends AuthSuccess {} +class AuthOtpLoading extends AuthLoading {} + +class ResendOtpLoading extends AuthLoading {} class ResendOtpSuccess extends AuthSuccess {} diff --git a/lib/features/auth/view/otp_view.dart b/lib/features/auth/view/otp_view.dart index 066cdd5..9622ee4 100644 --- a/lib/features/auth/view/otp_view.dart +++ b/lib/features/auth/view/otp_view.dart @@ -321,7 +321,7 @@ class _OtpViewState extends State { Expanded( child: DefaultButton( isDone: state is AuthLoginSuccess, - isLoading: state is AuthLoading, + isLoading: state is AuthOtpLoading, customButtonStyle: ButtonStyle( backgroundColor: MaterialStateProperty.all( @@ -349,8 +349,8 @@ class _OtpViewState extends State { ), Expanded( child: DefaultButton( - isDone: state is AuthLoginSuccess, - isLoading: state is AuthLoading, + isDone: state is ResendOtpSuccess, + isLoading: state is ResendOtpLoading, customButtonStyle: ButtonStyle( backgroundColor: MaterialStateProperty.all( @@ -383,7 +383,8 @@ class _OtpViewState extends State { if (success) { showDialog( context: context, - builder: (_) =>const SuccessDialog( + builder: (_) => + const SuccessDialog( key: ValueKey( 'SuccessDialog'), message: 'New OTP sent!',