@ -19,6 +19,7 @@ import 'package:diplomaticquarterapp/models/InPatientServices/get_admission_requ
import ' package:diplomaticquarterapp/pages/landing/landing_page.dart ' ;
import ' package:diplomaticquarterapp/pages/login/login.dart ' ;
import ' package:diplomaticquarterapp/pages/login/register_new.dart ' ;
import ' package:diplomaticquarterapp/pages/login/user-login-agreement-page.dart ' ;
import ' package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart ' ;
import ' package:diplomaticquarterapp/routes.dart ' ;
import ' package:diplomaticquarterapp/services/authentication/auth_provider.dart ' ;
@ -48,11 +49,7 @@ class ConfirmLogin extends StatefulWidget {
final fromRegistration ;
final bool isDubai ;
const ConfirmLogin ( { Key ? key ,
this . changePageViewIndex ,
this . fromRegistration = false ,
this . isDubai = false } )
: super ( key: key ) ;
const ConfirmLogin ( { Key ? key , this . changePageViewIndex , this . fromRegistration = false , this . isDubai = false } ) : super ( key: key ) ;
@ override
_ConfirmLogin createState ( ) = > _ConfirmLogin ( ) ;
@ -64,8 +61,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
var sharedPref = AppSharedPreferences ( ) ;
bool authenticated = false ;
final authService = AuthProvider ( ) ;
PharmacyModuleViewModel pharmacyModuleViewModel =
locator < PharmacyModuleViewModel > ( ) ;
PharmacyModuleViewModel pharmacyModuleViewModel = locator < PharmacyModuleViewModel > ( ) ;
late int mobileNumber ;
String errorMsg = ' ' ;
SelectDeviceIMEIRES ? user ;
@ -95,10 +91,8 @@ class _ConfirmLogin extends State<ConfirmLogin> {
int fingrePrintBefore = 0 ;
AuthenticatedUserObject authenticatedUserObject =
locator < AuthenticatedUserObject > ( ) ;
AppointmentRateViewModel appointmentRateViewModel =
locator < AppointmentRateViewModel > ( ) ;
AuthenticatedUserObject authenticatedUserObject = locator < AuthenticatedUserObject > ( ) ;
AppointmentRateViewModel appointmentRateViewModel = locator < AppointmentRateViewModel > ( ) ;
late ProjectViewModel projectViewModel ;
late ToDoCountProviderModel toDoProvider ;
@ -145,35 +139,17 @@ class _ConfirmLogin extends State<ConfirmLogin> {
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text (
TranslationBase
. of ( context )
. welcomeBack ,
style: TextStyle (
fontSize: 12 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2B353E ) ,
letterSpacing: - 0.64 ) ,
TranslationBase . of ( context ) . welcomeBack ,
style: TextStyle ( fontSize: 12 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.64 ) ,
) ,
Text (
user ! . name ! . toLowerCase ( ) . capitalizeFirstofEach ,
style: TextStyle (
fontSize: 24 ,
fontWeight: FontWeight . w700 ,
color: Color ( 0xff2B353E ) ,
height: 1 ,
letterSpacing: - 1.44 ) ,
style: TextStyle ( fontSize: 24 , fontWeight: FontWeight . w700 , color: Color ( 0xff2B353E ) , height: 1 , letterSpacing: - 1.44 ) ,
) ,
SizedBox ( height: 10 ) ,
Text (
TranslationBase
. of ( context )
. accountInfo ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2B353E ) ,
letterSpacing: - 0.64 ,
height: 25 / 16 ) ,
TranslationBase . of ( context ) . accountInfo ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.64 , height: 25 / 16 ) ,
) ,
Container (
height: 72 ,
@ -192,48 +168,28 @@ class _ConfirmLogin extends State<ConfirmLogin> {
mainAxisSize: MainAxisSize . min ,
children: [
Row (
mainAxisAlignment:
MainAxisAlignment . spaceBetween ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
Text (
TranslationBase
. of ( context )
. lastLoginAt
. toCamelCase ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2B353E ) ,
letterSpacing: - 0.64 ) ,
TranslationBase . of ( context ) . lastLoginAt . toCamelCase ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.64 ) ,
) ,
Text (
/ / user ! . editedOn ! = null
/ / ? DateUtil . getDayMonthYearDateFormatted ( DateUtil . convertStringToDate ( user ! . editedOn ! ) )
/ / :
user ! . createdOn ! = null
? DateUtil . getDayMonthYearDateFormatted (
DateUtil . convertStringToDate (
user ! . createdOn ! ) )
: ' -- ' ,
style: TextStyle (
fontSize: 12 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2B353E ) ,
letterSpacing: - 0.48 ) ,
user ! . createdOn ! = null ? DateUtil . getDayMonthYearDateFormatted ( DateUtil . convertStringToDate ( user ! . createdOn ! ) ) : ' -- ' ,
style: TextStyle ( fontSize: 12 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.48 ) ,
) ,
] ,
) ,
Row (
mainAxisAlignment:
MainAxisAlignment . spaceBetween ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
Text (
TranslationBase
. of ( context )
. lastLoginWith
. toCamelCase ,
TranslationBase . of ( context ) . lastLoginWith . toCamelCase ,
style: TextStyle (
fontSize: 10 ,
fontWeight: FontWeight . w600 ,
@ -256,17 +212,8 @@ class _ConfirmLogin extends State<ConfirmLogin> {
/ / user ! . editedOn ! ) ,
/ / false )
/ / :
user ! . createdOn ! = null
? DateUtil . formatDateToTimeLang (
DateUtil . convertStringToDate (
user ! . createdOn ! ) ,
false )
: ' -- ' ,
style: TextStyle (
fontSize: 12 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff575757 ) ,
letterSpacing: - 0.48 ) ,
user ! . createdOn ! = null ? DateUtil . formatDateToTimeLang ( DateUtil . convertStringToDate ( user ! . createdOn ! ) , false ) : ' -- ' ,
style: TextStyle ( fontSize: 12 , fontWeight: FontWeight . w600 , color: Color ( 0xff575757 ) , letterSpacing: - 0.48 ) ,
) ,
] ,
)
@ -274,21 +221,11 @@ class _ConfirmLogin extends State<ConfirmLogin> {
) ,
) ,
Text (
TranslationBase
. of ( context )
. pleaseVerify ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2E303A ) ,
letterSpacing: - 0.64 ) ,
TranslationBase . of ( context ) . pleaseVerify ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: Color ( 0xff2E303A ) , letterSpacing: - 0.64 ) ,
) ,
GridView (
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount (
crossAxisCount: 2 ,
crossAxisSpacing: 13 ,
mainAxisSpacing: 9 ) ,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount ( crossAxisCount: 2 , crossAxisSpacing: 13 , mainAxisSpacing: 9 ) ,
physics: NeverScrollableScrollPhysics ( ) ,
padding: EdgeInsets . only ( top: 9 ) ,
shrinkWrap: true ,
@ -302,67 +239,40 @@ class _ConfirmLogin extends State<ConfirmLogin> {
] ,
)
else
Column (
mainAxisAlignment: MainAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: < Widget > [
Image . asset (
' assets/images/habib-logo.png ' ,
height: 90 ,
width: 90 ,
) ,
SizedBox ( height: 23 ) ,
this . onlySMSBox = = false
? Text (
TranslationBase
. of ( context )
. verifyLoginWith ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2B353E ) ,
letterSpacing: - 0.64 ,
height: 25 / 16 ) ,
)
: Text (
TranslationBase
. of ( context )
. verifyFingerprint2 ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2B353E ) ,
letterSpacing: - 0.64 ,
height: 25 / 16 ) ,
) ,
SizedBox ( height: 23 ) ,
Text (
TranslationBase
. of ( context )
. pleaseVerify ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
color: Color ( 0xff2E303A ) ,
letterSpacing: - 0.64 ) ,
) ,
GridView (
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount (
crossAxisCount: 2 ,
crossAxisSpacing: 13 ,
mainAxisSpacing: 9 ) ,
physics: NeverScrollableScrollPhysics ( ) ,
padding: EdgeInsets . only ( top: 9 ) ,
shrinkWrap: true ,
children: [
if ( onlySMSBox = = false ) getButton ( 3 ) ,
if ( onlySMSBox = = false ) getButton ( 2 ) ,
getButton ( 1 ) ,
getButton ( 4 ) ,
] ,
) ,
] ) ,
Column ( mainAxisAlignment: MainAxisAlignment . start , crossAxisAlignment: CrossAxisAlignment . start , children: < Widget > [
Image . asset (
' assets/images/habib-logo.png ' ,
height: 90 ,
width: 90 ,
) ,
SizedBox ( height: 23 ) ,
this . onlySMSBox = = false
? Text (
TranslationBase . of ( context ) . verifyLoginWith ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.64 , height: 25 / 16 ) ,
)
: Text (
TranslationBase . of ( context ) . verifyFingerprint2 ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: Color ( 0xff2B353E ) , letterSpacing: - 0.64 , height: 25 / 16 ) ,
) ,
SizedBox ( height: 23 ) ,
Text (
TranslationBase . of ( context ) . pleaseVerify ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: Color ( 0xff2E303A ) , letterSpacing: - 0.64 ) ,
) ,
GridView (
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount ( crossAxisCount: 2 , crossAxisSpacing: 13 , mainAxisSpacing: 9 ) ,
physics: NeverScrollableScrollPhysics ( ) ,
padding: EdgeInsets . only ( top: 9 ) ,
shrinkWrap: true ,
children: [
if ( onlySMSBox = = false ) getButton ( 3 ) ,
if ( onlySMSBox = = false ) getButton ( 2 ) ,
getButton ( 1 ) ,
getButton ( 4 ) ,
] ,
) ,
] ) ,
] ,
) ,
) ,
@ -370,13 +280,10 @@ class _ConfirmLogin extends State<ConfirmLogin> {
height: 12 ,
) ,
DefaultButton (
TranslationBase
. of ( context )
. useAnotherAccount ,
( ) {
TranslationBase . of ( context ) . useAnotherAccount ,
( ) {
Navigator . of ( context ) . pushNamed ( LOGIN_TYPE ) ;
projectViewModel . analytics . loginRegistration
. login_with_other_account ( ) ;
projectViewModel . analytics . loginRegistration . login_with_other_account ( ) ;
} ,
) ,
] ,
@ -387,8 +294,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
Future < void > _getAvailableBiometrics ( ) async {
final bool canAuthenticateWithBiometrics = await auth . canCheckBiometrics ;
final bool canAuthenticate =
canAuthenticateWithBiometrics | | await auth . isDeviceSupported ( ) ;
final bool canAuthenticate = canAuthenticateWithBiometrics | | await auth . isDeviceSupported ( ) ;
var availableBiometrics ;
try {
@ -417,8 +323,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
login_method = type ;
LoginRegistration . verificationMethod = type ;
/ / if ( ! widget . fromRegistration )
projectViewModel . analytics . loginRegistration
. login_verfication ( forRegistration: widget . fromRegistration ) ;
projectViewModel . analytics . loginRegistration . login_verfication ( forRegistration: widget . fromRegistration ) ;
switch ( type ) {
case 1 :
@ -436,8 +341,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
default :
break ;
}
sharedPref . setInt ( LAST_LOGIN ,
this . selectedOption ) ; / / this . cs . sharedService . setStorage ( this . selectedOption , AuthenticationService . LAST_LOGIN ) ;
sharedPref . setInt ( LAST_LOGIN , this . selectedOption ) ; / / this . cs . sharedService . setStorage ( this . selectedOption , AuthenticationService . LAST_LOGIN ) ;
}
loginWithSMS ( type ) {
@ -465,23 +369,22 @@ class _ConfirmLogin extends State<ConfirmLogin> {
sharedPref . setObject ( REGISTER_DATA_FOR_REGISTER , request ) ;
authService
. checkPatientAuthentication ( request )
. then ( ( value ) = >
{
GifLoaderDialogUtils . hideDialog ( context ) ,
if ( value [ ' isSMSSent ' ] )
{
sharedPref . setString ( LOGIN_TOKEN_ID , value [ ' LogInTokenID ' ] ) ,
this . loginTokenID = value [ ' LogInTokenID ' ] ,
sharedPref . setObject ( REGISTER_DATA_FOR_LOGIIN , request ) ,
/ / Future . delayed ( Duration ( seconds: 1 ) , ( ) {
this . sendActivationCode ( type )
/ / } )
}
else
{
if ( value [ ' IsAuthenticated ' ] ) { this . checkActivationCode ( ) }
}
} )
. then ( ( value ) = > {
GifLoaderDialogUtils . hideDialog ( context ) ,
if ( value [ ' isSMSSent ' ] )
{
sharedPref . setString ( LOGIN_TOKEN_ID , value [ ' LogInTokenID ' ] ) ,
this . loginTokenID = value [ ' LogInTokenID ' ] ,
sharedPref . setObject ( REGISTER_DATA_FOR_LOGIIN , request ) ,
/ / Future . delayed ( Duration ( seconds: 1 ) , ( ) {
this . sendActivationCode ( type )
/ / } )
}
else
{
if ( value [ ' IsAuthenticated ' ] ) { this . checkActivationCode ( ) }
}
} )
. catchError ( ( err ) {
print ( err ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
@ -494,8 +397,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
GifLoaderDialogUtils . showMyDialog ( context ) ;
if ( healthId ! = null | | widget . isDubai ) {
if ( ! widget . isDubai ) {
request . dob =
dob ; / / isHijri = = 1 ? dob : dateFormat2 . format ( dateFormat . parse ( dob ) ) ;
request . dob = dob ; / / isHijri = = 1 ? dob : dateFormat2 . format ( dateFormat . parse ( dob ) ) ;
}
request . healthId = healthId ;
request . isHijri = isHijri ;
@ -532,11 +434,10 @@ class _ConfirmLogin extends State<ConfirmLogin> {
context ,
type ,
this . mobileNumber ,
( value ) {
( value ) {
this . checkActivationCode ( value: value ) ;
} ,
( ) = >
{
( ) = > {
Navigator . pop ( context ) ,
} ,
) . displayDialog ( context ) ;
@ -612,28 +513,23 @@ class _ConfirmLogin extends State<ConfirmLogin> {
setDefault ( ) async {
showLoader ( true ) ;
if ( await sharedPref . getObject ( IMEI_USER_DATA ) ! = null )
user = SelectDeviceIMEIRES . fromJson (
await sharedPref . getObject ( IMEI_USER_DATA ) ) ;
if ( await sharedPref . getObject ( IMEI_USER_DATA ) ! = null ) user = SelectDeviceIMEIRES . fromJson ( await sharedPref . getObject ( IMEI_USER_DATA ) ) ;
if ( await sharedPref . getObject ( REGISTER_DATA_FOR_LOGIIN ) ! = null ) {
isMoreOption = true ;
this . registerd_data = await CheckPatientAuthenticationReq . fromJson (
await sharedPref . getObject ( REGISTER_DATA_FOR_LOGIIN ) ) ;
this . registerd_data = await CheckPatientAuthenticationReq . fromJson ( await sharedPref . getObject ( REGISTER_DATA_FOR_LOGIIN ) ) ;
}
this . mobileNumber = this . registerd_data ! = null
? this . registerd_data . patientMobileNumber
: int . parse ( this . user ! . mobile ! ) ;
this . mobileNumber = this . registerd_data ! = null ? this . registerd_data . patientMobileNumber : int . parse ( this . user ! . mobile ! ) ;
this . zipCode = this . registerd_data ! = null
? this . registerd_data . zipCode
: this . user ! . outSA = = true
? " 971 "
: " 966 " ;
? " 971 "
: " 966 " ;
this . patientOutSA = this . registerd_data ! = null
? this . registerd_data . zipCode = = " 966 "
? 0
: 1
? 0
: 1
: this . user ! . outSA ;
if ( this . registerd_data ! = null ) {
this . loginTokenID = await sharedPref . getString ( LOGIN_TOKEN_ID ) ;
@ -643,9 +539,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
if ( nhic ! = null ) {
final DateFormat dateFormat = DateFormat ( ' MM/dd/yyyy ' ) ;
final DateFormat dateFormat2 = DateFormat ( ' dd/MM/yyyy ' ) ;
dob = nhic [ ' IsHijri ' ]
? nhic [ ' DateOfBirth ' ]
: dateFormat2 . format ( dateFormat . parse ( nhic [ ' DateOfBirth ' ] ) ) ;
dob = nhic [ ' IsHijri ' ] ? nhic [ ' DateOfBirth ' ] : dateFormat2 . format ( dateFormat . parse ( nhic [ ' DateOfBirth ' ] ) ) ;
isHijri = nhic [ ' IsHijri ' ] ? 1 : 0 ;
healthId = nhic [ ' HealthId ' ] ;
@ -654,8 +548,8 @@ class _ConfirmLogin extends State<ConfirmLogin> {
this . lastLogin = await sharedPref . getInt ( LAST_LOGIN ) ! = null
? await sharedPref . getInt ( LAST_LOGIN )
: user ! = null
? user ! . logInType
: null ;
? user ! . logInType
: null ;
showLoader ( false ) ;
/ / this . cs . sharedService . getStorage ( AuthenticationService . LAST_LOGIN ) ;
@ -668,34 +562,22 @@ class _ConfirmLogin extends State<ConfirmLogin> {
request . deviceToken = this . deviceToken ;
request . projectOutSA = this . patientOutSA = = true ? true : false ;
request . loginType = this . selectedOption ;
request . oTPSendType =
type = = 1 ? type : 2 ; / / this . selectedOption = = 1 ? 1 : 2 ;
request . oTPSendType = type = = 1 ? type : 2 ; / / this . selectedOption = = 1 ? 1 : 2 ;
request . zipCode = this . zipCode ;
request . logInTokenID = this . loginTokenID ? ? " " ;
if ( this . registerd_data ! = null ) {
request . searchType = this . registerd_data . searchType ! = null
? this . registerd_data . searchType
: 1 ;
request . patientID = this . registerd_data . patientID ! = null
? this . registerd_data . patientID
: 0 ;
request . patientIdentificationID = request . nationalID =
this . registerd_data . patientIdentificationID ! = null
? this . registerd_data . patientIdentificationID
: ' 0 ' ;
request . searchType = this . registerd_data . searchType ! = null ? this . registerd_data . searchType : 1 ;
request . patientID = this . registerd_data . patientID ! = null ? this . registerd_data . patientID : 0 ;
request . patientIdentificationID = request . nationalID = this . registerd_data . patientIdentificationID ! = null ? this . registerd_data . patientIdentificationID : ' 0 ' ;
request . dob = this . registerd_data . dob ;
request . isRegister = this . registerd_data . isRegister ;
} else {
request . searchType = request . searchType ! = null ? request . searchType : 2 ;
request . patientID =
this . user ! . patientID ! = null ? this . user ! . patientID : 0 ;
request . nationalID =
request . nationalID ! = null ? request . nationalID : ' 0 ' ;
request . patientIdentificationID = request . patientIdentificationID ! = null
? request . patientIdentificationID
: ' 0 ' ;
request . patientID = this . user ! . patientID ! = null ? this . user ! . patientID : 0 ;
request . nationalID = request . nationalID ! = null ? request . nationalID : ' 0 ' ;
request . patientIdentificationID = request . patientIdentificationID ! = null ? request . patientIdentificationID : ' 0 ' ;
request . isRegister = false ;
}
request . deviceTypeID = request . searchType ;
@ -716,40 +598,31 @@ class _ConfirmLogin extends State<ConfirmLogin> {
authService
. checkActivationCodeRegister ( request , value )
. then ( ( result ) = >
{
res = result ,
if ( result is Map )
{
result = CheckActivationCode . fromJson (
result as Map < String , dynamic > ) ,
if ( this . registerd_data ! = null & &
this . registerd_data . isRegister = = true )
{
/ / if ( widget . isDubai = = false ) {
widget . changePageViewIndex ! ( 1 ) ,
/ / if ( widget . isDubai = = false ) {
Navigator . popUntil (
context ,
( route ) = >
Utils . route ( route , equalsTo: RegisterNew ) ) ,
}
}
else
{
/ / Navigator . of ( context ) . pop ( ) ,
GifLoaderDialogUtils . hideDialog ( context ) ,
Future . delayed ( Duration ( seconds: 1 ) , ( ) {
AppToast . showErrorToast ( message: result ) ;
} ) ,
projectViewModel . analytics . loginRegistration
. login_fail ( error: result ) ,
projectViewModel . analytics . errorTracking . log (
' otp_verification_at_confirm_login ' ,
error: result ) ,
}
} )
. then ( ( result ) = > {
res = result ,
if ( result is Map )
{
result = CheckActivationCode . fromJson ( result as Map < String , dynamic > ) ,
if ( this . registerd_data ! = null & & this . registerd_data . isRegister = = true )
{
/ / if ( widget . isDubai = = false ) {
widget . changePageViewIndex ! ( 1 ) ,
/ / if ( widget . isDubai = = false ) {
Navigator . popUntil ( context , ( route ) = > Utils . route ( route , equalsTo: RegisterNew ) ) ,
}
}
else
{
/ / Navigator . of ( context ) . pop ( ) ,
GifLoaderDialogUtils . hideDialog ( context ) ,
Future . delayed ( Duration ( seconds: 1 ) , ( ) {
AppToast . showErrorToast ( message: result ) ;
} ) ,
projectViewModel . analytics . loginRegistration . login_fail ( error: result ) ,
projectViewModel . analytics . errorTracking . log ( ' otp_verification_at_confirm_login ' , error: result ) ,
}
} )
. catchError ( ( err ) {
print ( err ) ;
GifLoaderDialogUtils . hideDialog ( context ) ;
@ -762,62 +635,56 @@ class _ConfirmLogin extends State<ConfirmLogin> {
authService
. checkActivationCode ( request , value )
. then ( ( result ) = > {
res = result ,
if ( result is Map )
{
result = CheckActivationCode . fromJson ( result as Map < String , dynamic > ) ,
if ( result . errorCode = = ' 699 ' ) {
/ / 699 block run here
GifLoaderDialogUtils . hideDialog ( context ) ,
Future . delayed ( Duration ( seconds: 2 ) , ( ) {
AppToast . showErrorToast ( message: result . errorEndUserMessage ) ;
Navigator . popUntil ( context , ( route ) = > Utils . route ( route , equalsTo: Login ) ) ;
res = result ,
if ( result is Map )
{
result = CheckActivationCode . fromJson ( result as Map < String , dynamic > ) ,
if ( result . errorCode = = ' 699 ' )
{
/ / 699 block run here
GifLoaderDialogUtils . hideDialog ( context ) ,
Future . delayed ( Duration ( seconds: 2 ) , ( ) {
AppToast . showErrorToast ( message: result . errorEndUserMessage ) ;
Navigator . popUntil ( context , ( route ) = > Utils . route ( route , equalsTo: Login ) ) ;
} )
}
else if ( this . registerd_data ! = null & & this . registerd_data . isRegister = = true )
{
widget . changePageViewIndex ! ( 1 ) ,
Navigator . popUntil ( context , ( route ) = > Utils . route ( route , equalsTo: RegisterNew ) ) ,
}
else
{
sharedPref . remove ( FAMILY_FILE ) ,
result . list . isFamily = false ,
userData = result . list ,
sharedPref . setString ( BLOOD_TYPE , result . patientBloodType ? ? " " ) ,
/ / Remove o + from here Added by Aamir
authenticatedUserObject . user = result . list ,
projectViewModel . setPrivilege ( privilegeList: res ) ,
sharedPref . setObject ( MAIN_USER , result . list ) ,
sharedPref . setObject ( USER_PROFILE , result . list ) ,
loginTokenID = result . logInTokenID ,
sharedPref . setObject ( LOGIN_TOKEN_ID , result . logInTokenID ) ,
sharedPref . setString ( TOKEN , result . authenticationTokenID ) ,
checkIfUserAgreedBefore ( result ) ,
projectViewModel . analytics . loginRegistration . login_successful ( ) ,
}
}
else
{
/ / Navigator . of ( context ) . pop ( ) ,
GifLoaderDialogUtils . hideDialog ( context ) ,
Future . delayed ( Duration ( seconds: 1 ) , ( ) {
Navigator . of ( context ) . pop ( ) ;
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 )
}
} )
}
else if ( this . registerd_data ! = null & &
this . registerd_data . isRegister = = true )
{
widget . changePageViewIndex ! ( 1 ) ,
Navigator . popUntil (
context ,
( route ) = >
Utils . route ( route , equalsTo: RegisterNew ) ) ,
}
else
{
sharedPref . remove ( FAMILY_FILE ) ,
result . list . isFamily = false ,
userData = result . list ,
sharedPref . setString ( BLOOD_TYPE , result . patientBloodType ? ? " " ) ,
/ / Remove o + from here Added by Aamir
authenticatedUserObject . user = result . list ,
projectViewModel . setPrivilege ( privilegeList: res ) ,
sharedPref . setObject ( MAIN_USER , result . list ) ,
sharedPref . setObject ( USER_PROFILE , result . list ) ,
loginTokenID = result . logInTokenID ,
sharedPref . setObject ( LOGIN_TOKEN_ID , result . logInTokenID ) ,
sharedPref . setString ( TOKEN , result . authenticationTokenID ) ,
checkIfUserAgreedBefore ( result ) ,
projectViewModel . analytics . loginRegistration . login_successful ( ) ,
}
}
else
{
/ / Navigator . of ( context ) . pop ( ) ,
GifLoaderDialogUtils . hideDialog ( context ) ,
Future . delayed ( Duration ( seconds: 1 ) , ( ) {
Navigator . of ( context ) . pop ( ) ;
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 )
}
} )
. catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
Future . delayed ( Duration ( seconds: 1 ) , ( ) {
@ -830,10 +697,37 @@ class _ConfirmLogin extends State<ConfirmLogin> {
}
checkIfUserAgreedBefore ( CheckActivationCode result ) {
this . authService . checkIfUserAgreed ( ) . then ( ( result ) {
if ( result [ ' IsPatientAlreadyAgreed ' ] ) {
goToHome ( ) ;
} else {
this . authService . getUserAgreementContent ( ) . then ( ( result ) {
GifLoaderDialogUtils . hideDialog ( AppGlobal . context ) ;
Navigator . pushAndRemoveUntil (
context ,
FadePage (
page: UserLoginAgreementPage (
userAgreementText: result [ ' UserAgreementContent ' ] ,
authenticatedUserObject: authenticatedUserObject ,
appointmentRateViewModel: appointmentRateViewModel ,
selectedOption: selectedOption ,
) ,
) ,
( r ) = > false ) ;
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( err ) ;
} ) ;
}
} ) . catchError ( ( err ) {
GifLoaderDialogUtils . hideDialog ( context ) ;
print ( err ) ;
} ) ;
/ / if ( result . isNeedUserAgreement = = true ) {
/ / move to agreement page .
/ / } else {
goToHome ( ) ;
/ / goToHome ( ) ;
/ / }
}
@ -851,25 +745,17 @@ class _ConfirmLogin extends State<ConfirmLogin> {
print ( " Has Admission Request: $ hasAdmissionRequest " ) ;
if ( isAdmitted ) {
if ( res [ ' PatientAdmittedInformation ' ] . length ! = 0 ) {
getAdmissionInfoResponseModel =
GetAdmissionInfoResponseModel . fromJson (
res [ ' PatientAdmittedInformation ' ] [ 0 ] ) ;
projectViewModel . setInPatientProjectID (
res [ ' PatientAdmittedInformation ' ] [ 0 ] [ ' ProjectID ' ] ) ;
projectViewModel
. setInPatientAdmissionInfo ( getAdmissionInfoResponseModel ) ;
getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel . fromJson ( res [ ' PatientAdmittedInformation ' ] [ 0 ] ) ;
projectViewModel . setInPatientProjectID ( res [ ' PatientAdmittedInformation ' ] [ 0 ] [ ' ProjectID ' ] ) ;
projectViewModel . setInPatientAdmissionInfo ( getAdmissionInfoResponseModel ) ;
projectViewModel . setIsPatientAdmitted ( true ) ;
}
}
if ( hasAdmissionRequest ) {
if ( res [ ' MedicalInstruction ' ] . length ! = 0 ) {
getAdmissionRequestInfoResponseModel =
GetAdmissionRequestInfoResponseModel . fromJson (
res [ ' MedicalInstruction ' ] [ 0 ] ) ;
projectViewModel . setInPatientProjectID (
res [ ' MedicalInstruction ' ] [ 0 ] [ ' ProjectID ' ] ) ;
projectViewModel . setInPatientAdmissionRequest (
getAdmissionRequestInfoResponseModel ) ;
getAdmissionRequestInfoResponseModel = GetAdmissionRequestInfoResponseModel . fromJson ( res [ ' MedicalInstruction ' ] [ 0 ] ) ;
projectViewModel . setInPatientProjectID ( res [ ' MedicalInstruction ' ] [ 0 ] [ ' ProjectID ' ] ) ;
projectViewModel . setInPatientAdmissionRequest ( getAdmissionRequestInfoResponseModel ) ;
projectViewModel . setPatientHasAdmissionRequest ( true ) ;
}
}
@ -878,10 +764,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
}
insertIMEI ( ) {
authService
. insertDeviceImei ( selectedOption )
. then ( ( value ) = > { } )
. catchError ( ( err ) {
authService . insertDeviceImei ( selectedOption ) . then ( ( value ) = > { } ) . catchError ( ( err ) {
print ( err ) ;
} ) ;
}
@ -891,8 +774,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
ClinicListService service = new ClinicListService ( ) ;
service . getActiveAppointmentNo ( context ) . then ( ( res ) {
if ( res [ ' MessageStatus ' ] = = 1 ) {
toDoProvider . setState ( res [ ' AppointmentActiveNumber ' ] ,
res [ ' AncillaryOrderListCount ' ] , true , " 0 " ) ;
toDoProvider . setState ( res [ ' AppointmentActiveNumber ' ] , res [ ' AncillaryOrderListCount ' ] , true , " 0 " ) ;
/ / toDoProvider . setState ( res [ ' AppointmentActiveNumber ' ] , true , " 0 " ) ;
} else { }
} ) . catchError ( ( err ) {
@ -911,42 +793,31 @@ class _ConfirmLogin extends State<ConfirmLogin> {
getToDoCount ( ) ;
appointmentRateViewModel
. getIsLastAppointmentRatedList ( projectViewModel . isArabic ? 1 : 2 )
. then ( ( value ) = >
{
GifLoaderDialogUtils . hideDialog ( AppGlobal . context ) ,
if ( appointmentRateViewModel . isHaveAppointmentNotRate )
{
Navigator . pushAndRemoveUntil (
context ,
FadePage (
page: RateAppointmentDoctor ( ) ,
) ,
( r ) = > false )
}
else
{
Navigator . pushAndRemoveUntil (
context ,
FadePage (
page: LandingPage ( ) ,
) ,
( r ) = > false )
} ,
insertIMEI ( )
} )
. then ( ( value ) = > {
GifLoaderDialogUtils . hideDialog ( AppGlobal . context ) ,
if ( appointmentRateViewModel . isHaveAppointmentNotRate )
{
Navigator . pushAndRemoveUntil (
context ,
FadePage (
page: RateAppointmentDoctor ( ) ,
) ,
( r ) = > false )
}
else
{
Navigator . pushAndRemoveUntil (
context ,
FadePage (
page: LandingPage ( ) ,
) ,
( r ) = > false )
} ,
insertIMEI ( )
} )
. catchError ( ( err ) {
print ( err ) ;
} ) ;
/ / getToDoCount ( ) ;
/ / Navigator . pushAndRemoveUntil (
/ / context ,
/ / FadePage (
/ / page: LandingPage ( ) ,
/ / ) ,
/ / ( r ) = > false ) ;
/ / insertIMEI ( ) ;
}
loading ( flag ) {
@ -956,26 +827,21 @@ class _ConfirmLogin extends State<ConfirmLogin> {
}
Widget _loginOptionButton ( String _title , String _icon , int _flag , int ? _loginIndex ) {
bool isDisable =
( _flag = = 3 & & ! checkIfBiometricAvailable ( BiometricType . face ) | |
_flag = = 2 & &
! checkIfBiometricAvailable ( BiometricType . fingerprint ) & &
_flag = = 2 & &
! checkIfBiometricAvailable ( BiometricType . strong ) ) ;
bool isDisable = ( _flag = = 3 & & ! checkIfBiometricAvailable ( BiometricType . face ) | |
_flag = = 2 & & ! checkIfBiometricAvailable ( BiometricType . fingerprint ) & & _flag = = 2 & & ! checkIfBiometricAvailable ( BiometricType . strong ) ) ;
return InkWell (
onTap: isDisable
? null
: ( ) {
if ( _flag = = 0 ) {
setState ( ( ) {
isMoreOption = true ;
} ) ;
} else {
authenticateUser ( _flag , isActive: _loginIndex ) ;
projectViewModel . analytics . loginRegistration . verify_otp_method (
forRegistration: widget . fromRegistration ) ;
}
} ,
if ( _flag = = 0 ) {
setState ( ( ) {
isMoreOption = true ;
} ) ;
} else {
authenticateUser ( _flag , isActive: _loginIndex ) ;
projectViewModel . analytics . loginRegistration . verify_otp_method ( forRegistration: widget . fromRegistration ) ;
}
} ,
child: Container (
padding: EdgeInsets . only ( left: 20 , right: 20 , bottom: 15 , top: 28 ) ,
decoration: BoxDecoration (
@ -997,17 +863,8 @@ class _ConfirmLogin extends State<ConfirmLogin> {
color: isDisable ? Color ( 0xff2B353E ) . withOpacity ( 0.7 ) : null ,
) ,
Text (
TranslationBase
. of ( context )
. verifyThrough + " " + _title ,
style: TextStyle (
fontSize: 16 ,
fontWeight: FontWeight . w600 ,
color: isDisable
? Color ( 0xff2B353E ) . withOpacity ( 0.7 )
: Color ( 0xff2B353E ) ,
letterSpacing: - 0.48 ,
height: 20 / 16 ) ,
TranslationBase . of ( context ) . verifyThrough + " " + _title ,
style: TextStyle ( fontSize: 16 , fontWeight: FontWeight . w600 , color: isDisable ? Color ( 0xff2B353E ) . withOpacity ( 0.7 ) : Color ( 0xff2B353E ) , letterSpacing: - 0.48 , height: 20 / 16 ) ,
) ,
] ,
) ,
@ -1019,49 +876,28 @@ class _ConfirmLogin extends State<ConfirmLogin> {
Widget getButton ( int flag ) {
switch ( flag ) {
case 4 :
return _loginOptionButton ( TranslationBase
. of ( context )
. verifyWhatsApp ,
' assets/images/new/verify_whatsapp.svg ' , flag , null ) ;
return _loginOptionButton ( TranslationBase . of ( context ) . verifyWhatsApp , ' assets/images/new/verify_whatsapp.svg ' , flag , null ) ;
break ;
case 1 :
return _loginOptionButton ( TranslationBase
. of ( context )
. verifySMS ,
' assets/images/new/verify_sms.svg ' , flag , null ) ;
return _loginOptionButton ( TranslationBase . of ( context ) . verifySMS , ' assets/images/new/verify_sms.svg ' , flag , null ) ;
break ;
case 2 :
return _loginOptionButton (
TranslationBase
. of ( context )
. verifyFingerprint ,
' assets/images/new/verify_thumb.svg ' ,
flag ,
BiometricType . fingerprint . index ) ;
return _loginOptionButton ( TranslationBase . of ( context ) . verifyFingerprint , ' assets/images/new/verify_thumb.svg ' , flag , BiometricType . fingerprint . index ) ;
break ;
case 3 :
return _loginOptionButton (
TranslationBase
. of ( context )
. verifyFaceID ,
' assets/images/new/verify_face.svg ' ,
flag ,
BiometricType . face . index ) ;
return _loginOptionButton ( TranslationBase . of ( context ) . verifyFaceID , ' assets/images/new/verify_face.svg ' , flag , BiometricType . face . index ) ;
break ;
default :
return InkWell (
onTap: ( ) = >
{
onTap: ( ) = > {
setState ( ( ) {
isMoreOption = true ;
} )
} ,
child: RoundedContainer (
height: 150 ,
backgroundColor: BiometricType . fingerprint . index = = 1
? Colors . white
: Colors . white . withOpacity ( . 7 ) ,
backgroundColor: BiometricType . fingerprint . index = = 1 ? Colors . white : Colors . white . withOpacity ( . 7 ) ,
borderColor: Colors . grey ,
showBorder: true ,
child: Padding (
@ -1075,17 +911,12 @@ class _ConfirmLogin extends State<ConfirmLogin> {
) ,
projectViewModel . isArabic
? SizedBox (
height: 15 ,
)
height: 15 ,
)
: SizedBox (
height: 20 ,
) ,
Texts ( TranslationBase
. of ( context )
. moreVerification ,
fontSize: SizeConfig . textMultiplier ! * 1.8 ,
textAlign: TextAlign . center ,
color: Colors . black )
height: 20 ,
) ,
Texts ( TranslationBase . of ( context ) . moreVerification , fontSize: SizeConfig . textMultiplier ! * 1.8 , textAlign: TextAlign . center , color: Colors . black )
] ,
) ,
) ,
@ -1097,29 +928,19 @@ class _ConfirmLogin extends State<ConfirmLogin> {
getType ( type , context ) {
switch ( type ) {
case 1 :
return TranslationBase
. of ( context )
. verifySMS ;
return TranslationBase . of ( context ) . verifySMS ;
break ;
case 2 :
return TranslationBase
. of ( context )
. verifyFingerprint ;
return TranslationBase . of ( context ) . verifyFingerprint ;
break ;
case 3 :
return TranslationBase
. of ( context )
. verifyFaceID ;
return TranslationBase . of ( context ) . verifyFaceID ;
break ;
case 4 :
return TranslationBase
. of ( context )
. verifyWhatsApp ;
return TranslationBase . of ( context ) . verifyWhatsApp ;
break ;
default :
return TranslationBase
. of ( context )
. verifySMS ;
return TranslationBase . of ( context ) . verifySMS ;
break ;
}
}