mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 22:14:55 +00:00
fix loading issue seperate loading states between verify and resend Otp&&perevent user to send api if otp length !=6
This commit is contained in:
@ -270,7 +270,7 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
|
|
||||||
Future<bool> reSendOtp({bool? forget}) async {
|
Future<bool> reSendOtp({bool? forget}) async {
|
||||||
try {
|
try {
|
||||||
emit(AuthLoading());
|
emit(ResendOtpLoading());
|
||||||
await AuthenticationAPI.sendOtp(body: {
|
await AuthenticationAPI.sendOtp(body: {
|
||||||
'email': email,
|
'email': email,
|
||||||
'type': forget == true ? 'PASSWORD' : 'VERIFICATION'
|
'type': forget == true ? 'PASSWORD' : 'VERIFICATION'
|
||||||
@ -286,7 +286,10 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
verifyOtp(bool isForgotPass) async {
|
verifyOtp(bool isForgotPass) async {
|
||||||
emit(AuthLoginLoading());
|
if (otpCode.length != 6) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit(AuthOtpLoading());
|
||||||
try {
|
try {
|
||||||
final response = await AuthenticationAPI.verifyPassCode(body: {
|
final response = await AuthenticationAPI.verifyPassCode(body: {
|
||||||
'email': email,
|
'email': email,
|
||||||
|
|||||||
@ -20,9 +20,13 @@ class AuthLoginLoading extends AuthLoading {}
|
|||||||
|
|
||||||
class AuthLoginSuccess extends AuthSuccess {}
|
class AuthLoginSuccess extends AuthSuccess {}
|
||||||
|
|
||||||
|
class AuthSignUpSuccess extends AuthSuccess {}
|
||||||
|
|
||||||
class AuthOtpSuccess extends AuthSuccess {}
|
class AuthOtpSuccess extends AuthSuccess {}
|
||||||
|
|
||||||
class AuthSignUpSuccess extends AuthSuccess {}
|
class AuthOtpLoading extends AuthLoading {}
|
||||||
|
|
||||||
|
class ResendOtpLoading extends AuthLoading {}
|
||||||
|
|
||||||
class ResendOtpSuccess extends AuthSuccess {}
|
class ResendOtpSuccess extends AuthSuccess {}
|
||||||
|
|
||||||
|
|||||||
@ -321,7 +321,7 @@ class _OtpViewState extends State<OtpView> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
isDone: state is AuthLoginSuccess,
|
isDone: state is AuthLoginSuccess,
|
||||||
isLoading: state is AuthLoading,
|
isLoading: state is AuthOtpLoading,
|
||||||
customButtonStyle: ButtonStyle(
|
customButtonStyle: ButtonStyle(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
MaterialStateProperty.all(
|
MaterialStateProperty.all(
|
||||||
@ -349,8 +349,8 @@ class _OtpViewState extends State<OtpView> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
isDone: state is AuthLoginSuccess,
|
isDone: state is ResendOtpSuccess,
|
||||||
isLoading: state is AuthLoading,
|
isLoading: state is ResendOtpLoading,
|
||||||
customButtonStyle: ButtonStyle(
|
customButtonStyle: ButtonStyle(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
MaterialStateProperty.all(
|
MaterialStateProperty.all(
|
||||||
@ -383,7 +383,8 @@ class _OtpViewState extends State<OtpView> {
|
|||||||
if (success) {
|
if (success) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) =>const SuccessDialog(
|
builder: (_) =>
|
||||||
|
const SuccessDialog(
|
||||||
key: ValueKey(
|
key: ValueKey(
|
||||||
'SuccessDialog'),
|
'SuccessDialog'),
|
||||||
message: 'New OTP sent!',
|
message: 'New OTP sent!',
|
||||||
|
|||||||
Reference in New Issue
Block a user