@ -57,30 +57,21 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
@ override
Widget build ( BuildContext context ) {
mobileLoginInfoListModel ? ? = ModalRoute . of ( context ) ! . settings . arguments
as GetMobileLoginInfoListModel ;
String empName = AppState ( ) . isArabic ( context )
? AppState ( ) . memberInformationList ! . eMPLOYEEDISPLAYNAMEAr !
: AppState ( ) . memberInformationList ! . eMPLOYEEDISPLAYNAMEEn ! ;
mobileLoginInfoListModel ? ? = ModalRoute . of ( context ) ! . settings . arguments as GetMobileLoginInfoListModel ;
String empName = AppState ( ) . isArabic ( context ) ? AppState ( ) . memberInformationList ! . eMPLOYEEDISPLAYNAMEAr ! : AppState ( ) . memberInformationList ! . eMPLOYEEDISPLAYNAMEEn ! ;
return Scaffold (
appBar: AppBar (
backgroundColor: Colors . transparent ,
automaticallyImplyLeading: false ,
title: ( mobileLoginInfoListModel ? . businessCardPrivilege ? ? false )
? LocaleKeys . viewBusinessCard
. tr ( )
. toText12 ( color: MyColors . textMixColor , isUnderLine: true )
. onPress ( ( ) {
? LocaleKeys . viewBusinessCard . tr ( ) . toText12 ( color: MyColors . textMixColor , isUnderLine: true ) . onPress ( ( ) {
showMDialog ( context , child: BusinessCardDialog ( ) ) ;
} )
: null ,
actions: [
Center (
child: LocaleKeys . employeeDigitalID
. tr ( )
. toText12 ( color: MyColors . textMixColor , isUnderLine: true )
. onPress ( ( ) {
child: LocaleKeys . employeeDigitalID . tr ( ) . toText12 ( color: MyColors . textMixColor , isUnderLine: true ) . onPress ( ( ) {
showMDialog ( context , child: EmployeeDigitialIdDialog ( ) ) ;
} ) ) ,
21. width
@ -99,12 +90,9 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
LocaleKeys . welcomeBack . tr ( ) . toText12 ( ) ,
mobileLoginInfoListModel ! . employeeName !
. toText24 ( isBold: true ) ,
mobileLoginInfoListModel ! . employeeName ! . toText24 ( isBold: true ) ,
10. height ,
LocaleKeys . wouldYouLikeToLoginWithCurrentUsername
. tr ( )
. toText16 ( ) ,
LocaleKeys . wouldYouLikeToLoginWithCurrentUsername . tr ( ) . toText16 ( ) ,
Container (
height: 72 ,
margin: const EdgeInsets . only ( top: 23 , bottom: 23 ) ,
@ -126,42 +114,26 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
LocaleKeys . lastLoginDetails . tr ( ) . toText16 ( ) ,
DateUtil . formatDateToDate (
DateUtil . convertStringToDate (
mobileLoginInfoListModel ! . editedOn ! ) ,
false )
. toText12 ( ) ,
DateUtil . formatDateToDate ( DateUtil . convertStringToDate ( mobileLoginInfoListModel ! . editedOn ! ) , false ) . toText12 ( ) ,
] ,
) ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
crossAxisAlignment: CrossAxisAlignment . center ,
children: [
LocaleKeys . verificationType
. tr ( )
. toText10 ( color: MyColors . grey57Color ) ,
getVerificationType (
mobileLoginInfoListModel ! . loginType ! )
. toText12 ( ) ,
LocaleKeys . verificationType . tr ( ) . toText10 ( color: MyColors . grey57Color ) ,
getVerificationType ( mobileLoginInfoListModel ! . loginType ! ) . toText12 ( ) ,
Expanded ( child: SizedBox ( ) ) ,
DateUtil . formatDateToTime (
DateUtil . convertStringToDate (
mobileLoginInfoListModel ! . editedOn ! ) )
. toText12 ( ) ,
DateUtil . formatDateToTime ( DateUtil . convertStringToDate ( mobileLoginInfoListModel ! . editedOn ! ) ) . toText12 ( ) ,
] ,
)
] ,
) ,
) ,
LocaleKeys . pleaseVerify . tr ( ) . toText16 ( ) ,
if ( isNeedVerifyWithFaceIDAndBiometrics )
LocaleKeys . pleaseVerifyForBio . tr ( ) . toText12 ( ) ,
if ( isNeedVerifyWithFaceIDAndBiometrics ) LocaleKeys . pleaseVerifyForBio . tr ( ) . toText12 ( ) ,
GridView (
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount (
crossAxisCount: 2 ,
crossAxisSpacing: 13 ,
mainAxisSpacing: 9 ) ,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount ( crossAxisCount: 2 , crossAxisSpacing: 13 , mainAxisSpacing: 9 ) ,
physics: const NeverScrollableScrollPhysics ( ) ,
padding: const EdgeInsets . only ( top: 9 ) ,
shrinkWrap: true ,
@ -214,9 +186,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
DefaultButton (
LocaleKeys . useAnotherAccount . tr ( ) ,
( ) {
Navigator . pushNamedAndRemoveUntil (
context , AppRoutes . login , ( Route < dynamic > route ) = > false ,
arguments: false ) ;
Navigator . pushNamedAndRemoveUntil ( context , AppRoutes . login , ( Route < dynamic > route ) = > false , arguments: false ) ;
} ,
) . insideContainer ,
] ,
@ -248,19 +218,11 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
}
Future < bool > loginWithFaceIDAndBiometrics ( ) async {
IOSAuthMessages iosStrings = const IOSAuthMessages (
cancelButton: ' cancel ' ,
goToSettingsButton: ' settings ' ,
goToSettingsDescription: ' Please set up your Touch ID. ' ,
lockOut: ' Please reenable your Touch ID ' ) ;
IOSAuthMessages iosStrings =
const IOSAuthMessages ( cancelButton: ' cancel ' , goToSettingsButton: ' settings ' , goToSettingsDescription: ' Please set up your Touch ID. ' , lockOut: ' Please reenable your Touch ID ' ) ;
bool authenticated = false ;
try {
authenticated = await auth . authenticate (
localizedReason: ' Scan your fingerprint to authenticate ' ,
useErrorDialogs: true ,
stickyAuth: true ,
biometricOnly: true ,
iOSAuthStrings: iosStrings ) ;
authenticated = await auth . authenticate ( localizedReason: ' Scan your fingerprint to authenticate ' , useErrorDialogs: true , stickyAuth: true , biometricOnly: true , iOSAuthStrings: iosStrings ) ;
} on PlatformException catch ( e ) {
print ( e ) ;
Utils . hideLoading ( context ) ;
@ -269,11 +231,8 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
return authenticated ;
}
Widget _loginOptionButton (
String _title , String _icon , int _flag , int ? _loginIndex ) {
bool isDisable = ( ( _flag = = 3 & &
! checkBiometricIsAvailable ( BiometricType . face ) ) | |
( _flag = = 4 & & ! checkBiometricIsAvailable ( BiometricType . fingerprint ) ) ) ;
Widget _loginOptionButton ( String _title , String _icon , int _flag , int ? _loginIndex ) {
bool isDisable = ( ( _flag = = 3 & & ! checkBiometricIsAvailable ( BiometricType . face ) ) | | ( _flag = = 4 & & ! checkBiometricIsAvailable ( BiometricType . fingerprint ) ) ) ;
return InkWell (
onTap: isDisable
? null
@ -284,21 +243,18 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
} ) ;
} else {
if ( _flag = = 3 | | _flag = = 4 ) {
bool authenticateWithFaceAndTouchID =
await loginWithFaceIDAndBiometrics ( ) ;
bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics ( ) ;
if ( ! authenticateWithFaceAndTouchID ) {
return ;
} else {
if ( mobileLoginInfoListModel ! . loginType = = 3 | |
mobileLoginInfoListModel ! . loginType = = 4 ) {
if ( mobileLoginInfoListModel ! . loginType = = 3 | | mobileLoginInfoListModel ! . loginType = = 4 ) {
/ / bool authenticateWithFaceAndTouchID = await loginWithFaceIDAndBiometrics ( ) ;
/ / if ( ! authenticateWithFaceAndTouchID ) {
/ / return ;
/ / } else {
/ / performApiCall ( _title , _icon , _flag , isDirectLogin: true ) ;
/ / }
performApiCall ( _title , _icon , _flag , _flag ,
isDirectLogin: true ) ;
performApiCall ( _title , _icon , _flag , _flag , isDirectLogin: true ) ;
} else {
isNeedVerifyWithFaceIDAndBiometrics = true ;
selectedFlag = _flag ;
@ -316,8 +272,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
}
} ,
child: Container (
padding:
const EdgeInsets . only ( left: 20 , right: 20 , bottom: 15 , top: 28 ) ,
padding: const EdgeInsets . only ( left: 20 , right: 20 , bottom: 15 , top: 28 ) ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 15 ) ,
color: isDisable ? Colors . grey . withOpacity ( 0.3 ) : Colors . white ,
@ -343,23 +298,13 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
Widget getButton ( int flag ) {
switch ( flag ) {
case 1 :
return _loginOptionButton ( LocaleKeys . verifyThroughSMS . tr ( ) ,
' assets/images/login/verify_sms.svg ' , flag , null ) ;
return _loginOptionButton ( LocaleKeys . verifyThroughSMS . tr ( ) , ' assets/images/login/verify_sms.svg ' , flag , null ) ;
case 2 :
return _loginOptionButton ( LocaleKeys . verifyThroughWhatsapp . tr ( ) ,
' assets/images/login/verify_whatsapp.svg ' , flag , null ) ;
return _loginOptionButton ( LocaleKeys . verifyThroughWhatsapp . tr ( ) , ' assets/images/login/verify_whatsapp.svg ' , flag , null ) ;
case 3 :
return _loginOptionButton (
LocaleKeys . verifyThroughFace . tr ( ) ,
' assets/images/login/verify_face.svg ' ,
flag ,
BiometricType . face . index ) ;
return _loginOptionButton ( LocaleKeys . verifyThroughFace . tr ( ) , ' assets/images/login/verify_face.svg ' , flag , BiometricType . face . index ) ;
case 4 :
return _loginOptionButton (
LocaleKeys . verifyThroughFingerprint . tr ( ) ,
' assets/images/login/verify_thumb.svg ' ,
flag ,
BiometricType . fingerprint . index ) ;
return _loginOptionButton ( LocaleKeys . verifyThroughFingerprint . tr ( ) , ' assets/images/login/verify_thumb.svg ' , flag , BiometricType . fingerprint . index ) ;
default :
return const SizedBox ( ) ;
}
@ -376,9 +321,7 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
return isAvailable ;
}
Future < void > performApiCall (
String _title , String _icon , int _flag , int sendVerificationFlat ,
{ bool isDirectLogin = false } ) async {
Future < void > performApiCall ( String _title , String _icon , int _flag , int sendVerificationFlat , { bool isDirectLogin = false } ) async {
try {
if ( isDirectLogin )
setState ( ( ) {
@ -387,16 +330,10 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
else
Utils . showLoading ( context ) ;
await LoginApiClient ( ) . checkMobileAppVersion ( ) ;
await LoginApiClient ( )
. memberLogin ( AppState ( ) . getUserName ! , AppState ( ) . password ! ) ;
await LoginApiClient ( ) . memberLogin ( AppState ( ) . getUserName ! , AppState ( ) . password ! ) ;
if ( ! isDirectLogin )
BasicMemberInformationModel ? memberInformationModel =
await LoginApiClient ( )
. mohemmSendActivationCodeByOTPNotificationType (
0 ,
AppState ( ) . memberLoginList ? . pMOBILENUMBER ,
sendVerificationFlat ,
AppState ( ) . getUserName ) ;
await LoginApiClient ( ) . mohemmSendActivationCodeByOTPNotificationType ( 0 , AppState ( ) . memberLoginList ? . pMOBILENUMBER , sendVerificationFlat , AppState ( ) . getUserName ) ;
if ( isDirectLogin ) performDirectApiCall ( _title , _icon , _flag , " " ) ;
if ( ! isDirectLogin ) Utils . hideLoading ( context ) ;
if ( ! isDirectLogin )
@ -411,6 +348,9 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
( ) = > {
Navigator . pop ( context ) ,
} ,
onResendCode: ( ) {
performApiCall ( _title , _icon , _flag , sendVerificationFlat , isDirectLogin: isDirectLogin ) ;
} ,
) . displayDialog ( context ) ;
} catch ( ex ) {
Utils . hideLoading ( context ) ;
@ -418,34 +358,26 @@ class _VerifyLastLoginScreenState extends State<VerifyLastLoginScreen> {
}
}
Future < void > performDirectApiCall (
String _title , String _icon , int _flag , String value ,
{ bool isDirectLogin = false } ) async {
Future < void > performDirectApiCall ( String _title , String _icon , int _flag , String value , { bool isDirectLogin = false } ) async {
try {
GenericResponseModel ? genericResponseModel = await LoginApiClient ( )
. checkActivationCode ( false , AppState ( ) . memberLoginList ? . pMOBILENUMBER ,
value , AppState ( ) . getUserName ) ;
GenericResponseModel ? genericResponseModel1 = await LoginApiClient ( )
. insertMobileLoginInfoNEW (
AppState ( ) . memberLoginList ? . pEMAILADDRESS ? ? " " ,
genericResponseModel ? . pSESSIONID ? ? 0 ,
genericResponseModel ? . memberInformationList ! [ 0 ] . eMPLOYEENAME ? ?
" " ,
_flag ,
AppState ( ) . memberLoginList ? . pMOBILENUMBER ? ? " " ,
AppState ( ) . getUserName ! ,
mobileLoginInfoListModel ! . deviceToken ! ,
Platform . isAndroid ? " android " : " ios " ) ;
AppState ( ) . setMemberInformationListModel =
genericResponseModel ! . memberInformationList ? . first ;
GenericResponseModel ? genericResponseModel = await LoginApiClient ( ) . checkActivationCode ( false , AppState ( ) . memberLoginList ? . pMOBILENUMBER , value , AppState ( ) . getUserName ) ;
GenericResponseModel ? genericResponseModel1 = await LoginApiClient ( ) . insertMobileLoginInfoNEW (
AppState ( ) . memberLoginList ? . pEMAILADDRESS ? ? " " ,
genericResponseModel ? . pSESSIONID ? ? 0 ,
genericResponseModel ? . memberInformationList ! [ 0 ] . eMPLOYEENAME ? ? " " ,
_flag ,
AppState ( ) . memberLoginList ? . pMOBILENUMBER ? ? " " ,
AppState ( ) . getUserName ! ,
mobileLoginInfoListModel ! . deviceToken ! ,
Platform . isAndroid ? " android " : " ios " ) ;
AppState ( ) . setMemberInformationListModel = genericResponseModel ! . memberInformationList ? . first ;
if ( genericResponseModel ? . errorMessage ! = null ) {
Utils . showToast ( genericResponseModel ? . errorMessage ? ? " " ) ;
/ / Navigator . pop ( context ) ;
}
Utils . hideLoading ( context ) ;
Navigator . pop ( context ) ;
Navigator . pushNamedAndRemoveUntil (
context , AppRoutes . dashboard , ( Route < dynamic > route ) = > false ) ;
Navigator . pushNamedAndRemoveUntil ( context , AppRoutes . dashboard , ( Route < dynamic > route ) = > false ) ;
} catch ( ex ) {
Utils . hideLoading ( context ) ;
Utils . handleException ( ex , context , null ) ;