Merge pull request #107 from SyncrowIOT/SP-1562-FE-On-verify-OTP-screen-when-the-user-verifies-the-OTP-both-buttons-Verify-Resend-get-intoo-loading-state

fix loading issue seperate loading states between verify and resend O…
This commit is contained in:
Rafeek-khoudare
2025-05-22 04:55:52 -05:00
committed by GitHub
3 changed files with 15 additions and 7 deletions

View File

@ -270,7 +270,7 @@ class AuthCubit extends Cubit<AuthState> {
Future<bool> 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<AuthState> {
}
verifyOtp(bool isForgotPass) async {
emit(AuthLoginLoading());
if (otpCode.length != 6) {
return;
}
emit(AuthOtpLoading());
try {
final response = await AuthenticationAPI.verifyPassCode(body: {
'email': email,

View File

@ -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 {}

View File

@ -321,7 +321,7 @@ class _OtpViewState extends State<OtpView> {
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<OtpView> {
),
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<OtpView> {
if (success) {
showDialog(
context: context,
builder: (_) =>const SuccessDialog(
builder: (_) =>
const SuccessDialog(
key: ValueKey(
'SuccessDialog'),
message: 'New OTP sent!',