@ -49,17 +49,23 @@ class SavedLogin extends StatefulWidget {
}
}
class _SavedLogin extends State < SavedLogin > {
class _SavedLogin extends State < SavedLogin > {
TextEditingController get phoneController = > TextEditingController (
TextEditingController ? phoneController ;
text: widget . savedLoginData . mobile ! . startsWith ( ' 0 ' ) ? widget . savedLoginData . mobile ! . substring ( 1 ) : widget . savedLoginData . mobile ,
final authService = AuthProvider ( ) ;
) ;
final authService = new AuthProvider ( ) ;
late ProjectViewModel projectViewModel ;
late ProjectViewModel projectViewModel ;
late ToDoCountProviderModel toDoProvider ;
late ToDoCountProviderModel toDoProvider ;
Country selectedCountry = Country . saudiArabia ;
Country selectedCountry = Country . saudiArabia ;
AppointmentRateViewModel appointmentRateViewModel = locator < AppointmentRateViewModel > ( ) ;
AppointmentRateViewModel appointmentRateViewModel = locator < AppointmentRateViewModel > ( ) ;
String ? phoneNumber ;
@ override
void initState ( ) {
super . initState ( ) ;
print ( " ==== Saved Login===== " ) ;
phoneController = TextEditingController ( text: widget . savedLoginData . mobile ! . startsWith ( ' 0 ' ) ? widget . savedLoginData . mobile ! . substring ( 1 ) : widget . savedLoginData . mobile ) ;
phoneNumber = widget . savedLoginData . mobile ! . startsWith ( ' 0 ' ) ? widget . savedLoginData . mobile ! . substring ( 1 ) : widget . savedLoginData . mobile ;
}
@ override
@ override
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
@ -163,7 +169,7 @@ class _SavedLogin extends State<SavedLogin> {
margin: EdgeInsets . all ( 16 ) ,
margin: EdgeInsets . all ( 16 ) ,
child: SvgPicture . asset (
child: SvgPicture . asset (
getTypeIcons ( widget . savedLoginData . logInType ! , context ) ,
getTypeIcons ( widget . savedLoginData . logInType ! , context ) ,
/ / color: Color( 0xFFED1C2B ) ,
color: widget. savedLoginData . logInType = = 4 ? null : Color( 0xFFED1C2B ) ,
height: 64 ,
height: 64 ,
width: 64 ,
width: 64 ,
) ,
) ,
@ -219,7 +225,7 @@ class _SavedLogin extends State<SavedLogin> {
child: SingleChildScrollView (
child: SingleChildScrollView (
child: GenericBottomSheet (
child: GenericBottomSheet (
countryCode: selectedCountry . countryCode ,
countryCode: selectedCountry . countryCode ,
initialPhoneNumber: phoneController . text ,
initialPhoneNumber: phoneController ! . text ,
textController: phoneController ,
textController: phoneController ,
isEnableCountryDropdown: false ,
isEnableCountryDropdown: false ,
isFromSavedLogin: true ,
isFromSavedLogin: true ,
@ -227,15 +233,20 @@ class _SavedLogin extends State<SavedLogin> {
selectedCountry = value ;
selectedCountry = value ;
setModalState ( ( ) { } ) ;
setModalState ( ( ) { } ) ;
} ,
} ,
onChange: ( String ? value ) {
phoneNumber = value ;
} ,
buttons: [
buttons: [
Padding (
Padding (
padding: const EdgeInsets . only ( bottom: 10 ) ,
padding: const EdgeInsets . only ( bottom: 10 ) ,
child: CustomButton (
child: CustomButton (
text: TranslationBase . of ( context ) . sendOTPSMS ,
text: TranslationBase . of ( context ) . sendOTPSMS ,
onPressed: ( ) {
onPressed: ( ) {
int ? val = Utils . onOtpBtnPressed ( OTPType . sms , phone Controll er) ;
int ? val = Utils . onOtpBtnPressed ( OTPType . sms , phone Numb er) ;
if ( val ! = null ) {
if ( val ! = null ) {
checkUserAuthentication ( val , ) ;
checkUserAuthentication (
val ,
) ;
}
}
} ,
} ,
backgroundColor: CustomColors . bgRedColor ,
backgroundColor: CustomColors . bgRedColor ,
@ -266,7 +277,7 @@ class _SavedLogin extends State<SavedLogin> {
child: CustomButton (
child: CustomButton (
text: TranslationBase . of ( context ) . sendOTPWHATSAPP ,
text: TranslationBase . of ( context ) . sendOTPWHATSAPP ,
onPressed: ( ) {
onPressed: ( ) {
int ? val = Utils . onOtpBtnPressed ( OTPType . whatsapp , phone Controll er) ;
int ? val = Utils . onOtpBtnPressed ( OTPType . whatsapp , phone Numb er) ;
if ( val ! = null ) {
if ( val ! = null ) {
GifLoaderDialogUtils . showMyDialog ( context ) ;
GifLoaderDialogUtils . showMyDialog ( context ) ;
checkUserAuthentication ( val ) ;
checkUserAuthentication ( val ) ;
@ -413,6 +424,19 @@ class _SavedLogin extends State<SavedLogin> {
/ / setDefault ( ) ;
/ / setDefault ( ) ;
sharedPref . setInt ( LAST_LOGIN , lastLogin ) ;
sharedPref . setInt ( LAST_LOGIN , lastLogin ) ;
checkActivationCode ( null , lastLogin , result [ ' LogInTokenID ' ] ) ;
checkActivationCode ( null , lastLogin , result [ ' LogInTokenID ' ] ) ;
} else if ( result [ ' ErrorEndUserMessage ' ] ! = null ) {
ConfirmDialog dialog = new ConfirmDialog (
context: context ,
confirmMessage: result [ ' ErrorEndUserMessage ' ] ,
okText: TranslationBase . of ( context ) . confirm ,
cancelText: TranslationBase . of ( context ) . cancel_nocaps ,
okFunction: ( ) = > {
ConfirmDialog . closeAlertDialog ( context ) ,
Navigator . of ( context ) . pushReplacement ( FadePage ( page: WelcomeLogin ( ) ) ) ,
} ,
cancelFunction: ( ) = > { } ) ;
dialog . showAlertDialog ( context ) ;
}
}
} ) . catchError ( ( err ) {
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
@ -470,19 +494,16 @@ class _SavedLogin extends State<SavedLogin> {
projectViewModel . analytics . loginRegistration . login_successful ( ) ,
projectViewModel . analytics . loginRegistration . login_successful ( ) ,
}
}
}
}
/ / else
else
/ / {
{
/ / / / Navigator . of ( context ) . pop ( ) ,
/ / Navigator . of ( context ) . pop ( ) ,
/ / GifLoaderDialogUtils . hideDialog ( context ) ,
GifLoaderDialogUtils . hideDialog ( context ) ,
/ / Future . delayed ( Duration ( seconds: 1 ) , ( ) {
Future . delayed ( Duration ( seconds: 1 ) , ( ) {
/ / Navigator . of ( context ) . pop ( ) ;
AppToast . showErrorToast ( message: result , localContext: context ) ;
/ / AppToast . showErrorToast ( message: result , localContext: context ) ;
} ) ,
/ / startSMSService ( tempType ) ;
projectViewModel . analytics . loginRegistration . login_fail ( error: result ) ,
/ / } ) ,
projectViewModel . analytics . errorTracking . log ( ' otp_verification_at_confirm_login ' , error: result )
/ /
}
/ / projectViewModel . analytics . loginRegistration . login_fail ( error: result ) ,
/ / projectViewModel . analytics . errorTracking . log ( ' otp_verification_at_confirm_login ' , error: result )
/ / }
} ) ;
} ) ;
}
}
@ -624,8 +645,6 @@ class _SavedLogin extends State<SavedLogin> {
}
}
} )
} )
. catchError ( ( err ) {
. catchError ( ( err ) {
print ( err ) ;
print ( err ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
ConfirmDialog dialog = new ConfirmDialog (
ConfirmDialog dialog = new ConfirmDialog (
@ -639,8 +658,7 @@ class _SavedLogin extends State<SavedLogin> {
} ,
} ,
cancelFunction: ( ) = > { } ) ;
cancelFunction: ( ) = > { } ) ;
dialog . showAlertDialog ( context ) ;
dialog . showAlertDialog ( context ) ;
projectViewModel . analytics . loginRegistration
projectViewModel . analytics . loginRegistration . login_fail ( error: err . toString ( ) ) ;
. login_fail ( error: err . toString ( ) ) ;
} ) ;
} ) ;
}
}
@ -697,7 +715,7 @@ class _SavedLogin extends State<SavedLogin> {
smsOtp = SMSOTP (
smsOtp = SMSOTP (
context ,
context ,
type ,
type ,
phoneController . text ,
phoneController ! . text ,
( code ) {
( code ) {
smsOtp . dispose ( ) ; / / Now we can reference it
smsOtp . dispose ( ) ; / / Now we can reference it
this . checkActivationCode ( code , type , loginToken ) ;
this . checkActivationCode ( code , type , loginToken ) ;