login inprogress

merge-requests/13/merge
Sultan Khan 4 years ago
parent 41b438fd74
commit 8d0834ff3e

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

@ -120,5 +120,14 @@ const Map<String, Map<String, String>> localizedValues = {
"arabic-change": {"en": "عربي", "ar": "English"}, "arabic-change": {"en": "عربي", "ar": "English"},
"notification": {"en": "Notifications", "ar": "إشعارات"}, "notification": {"en": "Notifications", "ar": "إشعارات"},
"app-settings": {"en": "App Settings", "ar": "إعدادات التطبيق"}, "app-settings": {"en": "App Settings", "ar": "إعدادات التطبيق"},
"rate-app": {"en": "Rate Our App", "ar": "قيم التطبيق"} "rate-app": {"en": "Rate Our App", "ar": "قيم التطبيق"},
"more-verify": {
"en": "More Verification Options",
"ar": "المزيد من خيارات التحقق"
},
"welcome-back": {"en": "Welcome back!", "ar": "مرحبا بعودتك!"},
"account-info": {
"en": "Would you like to login with current username?",
"ar": "هل ترغب في تسجيل الدخول باسم المستخدم الحالي؟"
},
}; };

@ -1,8 +1,11 @@
import 'dart:convert'; import 'dart:convert';
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
AppSharedPreferences sharedPref = new AppSharedPreferences(); AppSharedPreferences sharedPref = new AppSharedPreferences();
@ -43,6 +46,8 @@ class BaseAppClient {
if (!parsed['IsAuthenticated']) { if (!parsed['IsAuthenticated']) {
if (parsed['isSMSSent'] == true) { if (parsed['isSMSSent'] == true) {
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} else {
logout();
} }
// await helpers.logout(); // await helpers.logout();
//helpers.showErrorToast('Your session expired Please login agian'); //helpers.showErrorToast('Your session expired Please login agian');
@ -63,4 +68,8 @@ class BaseAppClient {
onFailure(e.toString(), -1); onFailure(e.toString(), -1);
} }
} }
logout() async {
await sharedPref.remove(LOGIN_TOKEN_ID);
}
} }

@ -1,3 +1,4 @@
import 'package:diplomaticquarterapp/routes.dart';
import 'package:get_it/get_it.dart'; import 'package:get_it/get_it.dart';
import 'core/service/hospital_service.dart'; import 'core/service/hospital_service.dart';

@ -11,55 +11,55 @@ class AuthenticatedUser {
int relationshipID; int relationshipID;
int gender; int gender;
String dateofBirth; String dateofBirth;
Null dateofBirthN; dynamic dateofBirthN;
String nationalityID; String nationalityID;
Null phoneResi; dynamic phoneResi;
Null phoneOffice; dynamic phoneOffice;
String mobileNumber; String mobileNumber;
Null faxNumber; dynamic faxNumber;
String emailAddress; String emailAddress;
Null bloodGroup; dynamic bloodGroup;
Null rHFactor; dynamic rHFactor;
bool isEmailAlertRequired; bool isEmailAlertRequired;
bool isSMSAlertRequired; bool isSMSAlertRequired;
String preferredLanguage; String preferredLanguage;
bool isPrivilegedMember; bool isPrivilegedMember;
Null memberID; dynamic memberID;
Null expiryDate; dynamic expiryDate;
Null isHmgEmployee; dynamic isHmgEmployee;
Null employeeID; dynamic employeeID;
Null emergencyContactName; dynamic emergencyContactName;
Null emergencyContactNo; dynamic emergencyContactNo;
int patientPayType; int patientPayType;
Null dHCCPatientRefID; dynamic dHCCPatientRefID;
bool isPatientDummy; bool isPatientDummy;
int status; int status;
Null isStatusCleared; dynamic isStatusCleared;
int patientIdentificationType; int patientIdentificationType;
String patientIdentificationNo; String patientIdentificationNo;
int projectID; int projectID;
int infoSourceID; int infoSourceID;
Null address; dynamic address;
int age; int age;
String ageDesc; String ageDesc;
int areaID; int areaID;
int createdBy; int createdBy;
String genderDescription; String genderDescription;
Null iR; dynamic iR;
Null iSOCityID; dynamic iSOCityID;
Null iSOCountryID; dynamic iSOCountryID;
List<ListPrivilege> listPrivilege; List<ListPrivilege> listPrivilege;
Null marital; dynamic marital;
int outSA; int outSA;
Null pOBox; dynamic pOBox;
bool receiveHealthSummaryReport; bool receiveHealthSummaryReport;
int sourceType; int sourceType;
Null strDateofBirth; dynamic strDateofBirth;
Null tempAddress; dynamic tempAddress;
Null zipCode; dynamic zipCode;
// Null patientPayType; // dynamic patientPayType;
// Null patientType; // dynamic patientType;
// Null status; // dynamic status;
AuthenticatedUser({ AuthenticatedUser({
this.setupID, this.setupID,
@ -260,7 +260,7 @@ class ListPrivilege {
int iD; int iD;
String serviceName; String serviceName;
bool previlege; bool previlege;
Null region; dynamic region;
ListPrivilege({this.iD, this.serviceName, this.previlege, this.region}); ListPrivilege({this.iD, this.serviceName, this.previlege, this.region});

@ -1,68 +1,68 @@
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
class CheckActivationCode { class CheckActivationCode {
Null date; dynamic date;
int languageID; int languageID;
int serviceName; int serviceName;
Null time; dynamic time;
Null androidLink; dynamic androidLink;
String authenticationTokenID; String authenticationTokenID;
Null data; dynamic data;
bool dataw; bool dataw;
int dietType; int dietType;
Null errorCode; dynamic errorCode;
Null errorEndUserMessage; dynamic errorEndUserMessage;
Null errorEndUserMessageN; dynamic errorEndUserMessageN;
Null errorMessage; dynamic errorMessage;
int errorType; int errorType;
int foodCategory; int foodCategory;
Null iOSLink; dynamic iOSLink;
bool isAuthenticated; bool isAuthenticated;
int mealOrderStatus; int mealOrderStatus;
int mealType; int mealType;
int messageStatus; int messageStatus;
int numberOfResultRecords; int numberOfResultRecords;
Null patientBlodType; dynamic patientBlodType;
Null successMsg; dynamic successMsg;
Null successMsgN; dynamic successMsgN;
Null doctorInformationList; dynamic doctorInformationList;
Null getAllPendingRecordsList; dynamic getAllPendingRecordsList;
Null getAllSharedRecordsByStatusList; dynamic getAllSharedRecordsByStatusList;
Null getResponseFileList; dynamic getResponseFileList;
bool isHMGPatient; bool isHMGPatient;
bool isLoginSuccessfully; bool isLoginSuccessfully;
bool isNeedUpdateIdintificationNo; bool isNeedUpdateIdintificationNo;
bool kioskSendSMS; bool kioskSendSMS;
AuthenticatedUser list; AuthenticatedUser list;
Null listAskHabibMobileLoginInfo; dynamic listAskHabibMobileLoginInfo;
Null listAskHabibPatientFile; dynamic listAskHabibPatientFile;
Null listMergeFiles; dynamic listMergeFiles;
Null listMobileLoginInfo; dynamic listMobileLoginInfo;
Null listPatientCount; dynamic listPatientCount;
Null logInTokenID; dynamic logInTokenID;
Null mohemmPrivilegeList; dynamic mohemmPrivilegeList;
int pateintID; int pateintID;
Null patientBloodType; String patientBloodType;
bool patientHasFile; bool patientHasFile;
Null patientMergedIDs; dynamic patientMergedIDs;
bool patientOutSA; bool patientOutSA;
int patientShareRequestID; int patientShareRequestID;
int patientType; int patientType;
int projectIDOut; int projectIDOut;
Null returnMessage; dynamic returnMessage;
bool sMSLoginRequired; bool sMSLoginRequired;
Null servicePrivilegeList; dynamic servicePrivilegeList;
Null sharePatientName; dynamic sharePatientName;
Null verificationCode; dynamic verificationCode;
Null email; dynamic email;
Null errorList; dynamic errorList;
bool hasFile; bool hasFile;
bool isActiveCode; bool isActiveCode;
bool isMerged; bool isMerged;
bool isNeedUserAgreement; bool isNeedUserAgreement;
bool isSMSSent; bool isSMSSent;
Null memberList; dynamic memberList;
Null message; dynamic message;
int statusCode; int statusCode;
CheckActivationCode( CheckActivationCode(
@ -283,52 +283,52 @@ class List {
int relationshipID; int relationshipID;
int gender; int gender;
String dateofBirth; String dateofBirth;
Null dateofBirthN; dynamic dateofBirthN;
String nationalityID; String nationalityID;
Null phoneResi; dynamic phoneResi;
Null phoneOffice; dynamic phoneOffice;
String mobileNumber; String mobileNumber;
Null faxNumber; dynamic faxNumber;
String emailAddress; String emailAddress;
Null bloodGroup; dynamic bloodGroup;
Null rHFactor; dynamic rHFactor;
bool isEmailAlertRequired; bool isEmailAlertRequired;
bool isSMSAlertRequired; bool isSMSAlertRequired;
String preferredLanguage; String preferredLanguage;
bool isPrivilegedMember; bool isPrivilegedMember;
Null memberID; dynamic memberID;
Null expiryDate; dynamic expiryDate;
Null isHmgEmployee; dynamic isHmgEmployee;
Null employeeID; dynamic employeeID;
Null emergencyContactName; dynamic emergencyContactName;
Null emergencyContactNo; dynamic emergencyContactNo;
int patientPayType; int patientPayType;
Null dHCCPatientRefID; dynamic dHCCPatientRefID;
bool isPatientDummy; bool isPatientDummy;
int status; int status;
Null isStatusCleared; dynamic isStatusCleared;
int patientIdentificationType; int patientIdentificationType;
String patientIdentificationNo; String patientIdentificationNo;
int projectID; int projectID;
int infoSourceID; int infoSourceID;
Null address; dynamic address;
int age; int age;
String ageDesc; String ageDesc;
int areaID; int areaID;
int createdBy; int createdBy;
String genderDescription; String genderDescription;
Null iR; dynamic iR;
Null iSOCityID; dynamic iSOCityID;
Null iSOCountryID; dynamic iSOCountryID;
ListPrivilege listPrivilege; ListPrivilege listPrivilege;
Null marital; dynamic marital;
int outSA; int outSA;
Null pOBox; dynamic pOBox;
bool receiveHealthSummaryReport; bool receiveHealthSummaryReport;
int sourceType; int sourceType;
Null strDateofBirth; dynamic strDateofBirth;
Null tempAddress; dynamic tempAddress;
Null zipCode; dynamic zipCode;
List({ List({
this.setupID, this.setupID,
@ -525,7 +525,7 @@ class ListPrivilege {
int iD; int iD;
String serviceName; String serviceName;
bool previlege; bool previlege;
Null region; dynamic region;
ListPrivilege({this.iD, this.serviceName, this.previlege, this.region}); ListPrivilege({this.iD, this.serviceName, this.previlege, this.region});

@ -1,13 +1,13 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart';
import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart';
import 'package:diplomaticquarterapp/models/Authentication/send_activation_request.dart'; import 'package:diplomaticquarterapp/models/Authentication/send_activation_request.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
@ -18,7 +18,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/routes.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_flexible_toast/flutter_flexible_toast.dart'; import 'package:intl/intl.dart';
import 'package:local_auth/local_auth.dart'; import 'package:local_auth/local_auth.dart';
class ConfirmLogin extends StatefulWidget { class ConfirmLogin extends StatefulWidget {
@ -28,16 +28,16 @@ class ConfirmLogin extends StatefulWidget {
class _ConfirmLogin extends State<ConfirmLogin> { class _ConfirmLogin extends State<ConfirmLogin> {
final LocalAuthentication auth = LocalAuthentication(); final LocalAuthentication auth = LocalAuthentication();
List _availableBiometrics; dynamic _availableBiometrics;
var sharedPref = new AppSharedPreferences(); var sharedPref = new AppSharedPreferences();
bool authenticated; bool authenticated;
final authService = new AuthProvider(); final authService = new AuthProvider();
int mobileNumber; int mobileNumber;
String errorMsg = ''; String errorMsg = '';
var user; SelectDeviceIMEIRES user;
bool isLoading = false; bool isLoading = false;
CheckPatientAuthenticationReq registerd_data; CheckPatientAuthenticationReq registerd_data;
bool isMoreOption = false;
var zipCode; var zipCode;
var patientOutSA; var patientOutSA;
@ -58,6 +58,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
static BuildContext _context; static BuildContext _context;
static bool _loading; static bool _loading;
@override @override
void initState() { void initState() {
_getAvailableBiometrics(); _getAvailableBiometrics();
@ -80,227 +81,145 @@ class _ConfirmLogin extends State<ConfirmLogin> {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
flex: 3, flex: 3,
child: Column( child: user != null && isMoreOption == false
mainAxisAlignment: ? Column(
MainAxisAlignment.spaceEvenly, mainAxisAlignment:
crossAxisAlignment: CrossAxisAlignment.start, MainAxisAlignment.spaceEvenly,
children: <Widget>[ crossAxisAlignment:
Image.asset( CrossAxisAlignment.start,
'assets/images/habib-logo.png', children: <Widget>[
height: 80, Image.asset(
width: 80, 'assets/images/habib-logo.png',
), height: 80,
this.onlySMSBox == false width: 80,
? AppText( ),
TranslationBase.of(context) AppText(
.verifyLoginWith, TranslationBase.of(context)
fontSize: .welcomeBack +
SizeConfig.textMultiplier * 3.5, ' ' +
textAlign: TextAlign.left, user.name,
) fontSize: SizeConfig.textMultiplier * 4,
: AppText( ),
TranslationBase.of(context) AppText(
.verifyFingerprint2, TranslationBase.of(context).accountInfo,
fontSize: fontSize: SizeConfig.textMultiplier * 3,
SizeConfig.textMultiplier * 2.5, ),
textAlign: TextAlign.left, Card(
color: Colors.grey[300],
child: Row(
children: <Widget>[
Expanded(
child: ListTile(
title: Text(
TranslationBase.of(context)
.lastLoginAt,
textAlign: TextAlign.center,
),
subtitle: Text(
formatDate(DateUtil
.convertStringToDate(
user.editedOn)),
textAlign:
TextAlign.center),
)),
Expanded(
child: ListTile(
title: Text(
TranslationBase.of(context)
.lastLoginWith,
textAlign:
TextAlign.center),
subtitle: Text(
getType(user.logInType,
context),
textAlign:
TextAlign.center),
))
],
))
],
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
'assets/images/habib-logo.png',
height: 80,
width: 80,
), ),
])), this.onlySMSBox == false
Expanded( ? AppText(
flex: 4, TranslationBase.of(context)
child: Column( .verifyLoginWith,
mainAxisAlignment: MainAxisAlignment.start, fontSize:
crossAxisAlignment: CrossAxisAlignment.start, SizeConfig.textMultiplier *
children: <Widget>[ 3.5,
onlySMSBox == false textAlign: TextAlign.left,
? Row( )
: AppText(
TranslationBase.of(context)
.verifyFingerprint2,
fontSize:
SizeConfig.textMultiplier *
2.5,
textAlign: TextAlign.left,
),
])),
user != null && isMoreOption == false
? Expanded(
flex: 2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: InkWell(
onTap: () => {
authenticateUser(
3,
BiometricType
.face.index)
},
child: getButton(
user.logInType))),
Expanded(child: getButton(5))
])
]))
: Expanded(
flex: 4,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
onlySMSBox == false
? Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(child: getButton(3)),
Expanded(child: getButton(2))
],
)
: SizedBox(),
Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(child: getButton(1)),
child: InkWell( Expanded(child: getButton(4))
onTap: () => {
authenticateUser(
3,
BiometricType
.face.index)
},
child: RoundedContainer(
backgroundColor:
BiometricType.face
.index ==
1
? Colors.white
: Colors.white
.withOpacity(
.7),
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding:
EdgeInsets.fromLTRB(
20, 10, 20, 10),
child: Column(
mainAxisAlignment:
MainAxisAlignment
.center,
children: <Widget>[
Image.asset(
'assets/images/login/101.png',
height: SizeConfig
.imageSizeMultiplier *
13,
width: SizeConfig
.imageSizeMultiplier *
16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(
context)
.verifyFaceID,
fontSize: SizeConfig
.textMultiplier *
2,
)
],
),
)))),
Expanded(
child: InkWell(
onTap: () => {
authenticateUser(
2,
BiometricType
.fingerprint
.index)
},
child: RoundedContainer(
backgroundColor:
BiometricType
.fingerprint
.index ==
1
? Colors.white
: Colors.white
.withOpacity(
.7),
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding:
EdgeInsets.fromLTRB(
25, 10, 25, 10),
child: Column(
children: <Widget>[
Image.asset(
'assets/images/login/102.png',
height: SizeConfig
.imageSizeMultiplier *
13,
width: SizeConfig
.imageSizeMultiplier *
16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(
context)
.verifyFingerprint,
fontSize: SizeConfig
.textMultiplier *
2,
)
],
),
))))
], ],
) ),
: SizedBox(), ]),
Row( ),
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: InkWell(
onTap: () =>
{authenticateUser(1, true)},
child: RoundedContainer(
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding: EdgeInsets.fromLTRB(
20, 10, 20, 10),
child: Column(
mainAxisAlignment:
MainAxisAlignment
.center,
children: <Widget>[
Image.asset(
'assets/images/login/103.png',
height: SizeConfig
.imageSizeMultiplier *
13,
width: SizeConfig
.imageSizeMultiplier *
16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(
context)
.verifySMS,
fontSize: SizeConfig
.textMultiplier *
2,
)
],
),
)))),
Expanded(
child: InkWell(
onTap: () =>
{authenticateUser(4, true)},
child: RoundedContainer(
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding: EdgeInsets.fromLTRB(
25, 10, 25, 10),
child: Column(
children: <Widget>[
Image.asset(
'assets/images/login/104.png',
height: SizeConfig
.imageSizeMultiplier *
13,
width: SizeConfig
.imageSizeMultiplier *
16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(
context)
.verifyWhatsApp,
fontSize: SizeConfig
.textMultiplier *
2,
)
],
),
))))
],
),
]),
),
Expanded( Expanded(
flex: 1, flex: 1,
child: Column( child: Column(
@ -369,27 +288,50 @@ class _ConfirmLogin extends State<ConfirmLogin> {
loginWithSMS(type, isActive) { loginWithSMS(type, isActive) {
//if (!el.disabled) { //if (!el.disabled) {
if (this.user != null && this.registerd_data != null) { if (this.user != null && this.registerd_data == null) {
this.checkUserAuthentication(type); this.checkUserAuthentication(type);
} else { } else {
if (this.loginTokenID != null) { if (this.loginTokenID != null) {
this.sendActivationCode(type); Future.delayed(Duration(seconds: 1), () {
this.sendActivationCode(type);
});
} else { } else {
this.checkUserAuthentication(type); this.checkUserAuthentication(type);
} }
} }
} }
checkUserAuthentication(type) {} checkUserAuthentication(type) {
showLoader(true);
var req = getCommonRequest();
var request = CheckPatientAuthenticationReq.fromJson(req.toJson());
sharedPref.setObject(REGISTER_DATA_FOR_REGISTER, request);
authService.checkPatientAuthentication(request).then((value) => {
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()}
}
});
}
sendActivationCode(type) { sendActivationCode(type) {
var request = this.getCommonRequest(); var request = this.getCommonRequest();
loading(true); loading(true);
this.authService.sendActivationCode(request).then((result) => { this.authService.sendActivationCode(request).then((result) => {
if (result['isSMSSent'] == true) if (result != null && result['isSMSSent'] == true)
{loading(false), this.startSMSService(type)} {loading(false), this.startSMSService(type)}
else else
{} {loading(false)}
}); });
} }
@ -457,30 +399,43 @@ class _ConfirmLogin extends State<ConfirmLogin> {
}); });
} }
setUser() async {
user = SelectDeviceIMEIRES.fromJson(
await sharedPref.getObject(IMEI_USER_DATA));
}
setDefault() async { setDefault() async {
// this.user = this.cs.sharedService.getSharedData( // this.user = this.cs.sharedService.getSharedData(
// AuthenticationService.IMEI_USER_DATA, // AuthenticationService.IMEI_USER_DATA,
// false // false
// ); // );
this.registerd_data = CheckPatientAuthenticationReq.fromJson( setState(() {
await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); setUser();
});
if (await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN) != null) {
this.registerd_data = CheckPatientAuthenticationReq.fromJson(
await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN));
}
this.mobileNumber = this.registerd_data != null this.mobileNumber = this.registerd_data != null
? this.registerd_data.patientMobileNumber ? this.registerd_data.patientMobileNumber
: int.parse(this.user.Mobile); : int.parse(this.user.mobile);
this.zipCode = this.registerd_data != null this.zipCode = this.registerd_data != null
? this.registerd_data.zipCode ? this.registerd_data.zipCode
: this.user.OutSA ? "971" : "966"; : this.user.outSA == true ? "971" : "966";
this.patientOutSA = this.registerd_data != null this.patientOutSA = this.registerd_data != null
? this.registerd_data.zipCode == "966" ? 0 : 1 ? this.registerd_data.zipCode == "966" ? 0 : 1
: this.user.OutSA; : this.user.outSA;
if (this.registerd_data != null) { if (this.registerd_data != null) {
this.loginTokenID = await sharedPref.getString(LOGIN_TOKEN_ID); this.loginTokenID = await sharedPref.getString(LOGIN_TOKEN_ID);
this.loginType = this.registerd_data.searchType; this.loginType = this.registerd_data.searchType;
} }
this.deviceToken = await sharedPref.getString(PUSH_TOKEN); this.deviceToken = await sharedPref.getString(PUSH_TOKEN);
this.lastLogin = await sharedPref.getInt( this.lastLogin = await sharedPref.getInt(LAST_LOGIN) != null
LAST_LOGIN); //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); ? await sharedPref.getInt(LAST_LOGIN)
: user.logInType;
//this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN);
} }
getCommonRequest() { getCommonRequest() {
@ -488,42 +443,54 @@ class _ConfirmLogin extends State<ConfirmLogin> {
request.patientMobileNumber = this.mobileNumber; request.patientMobileNumber = this.mobileNumber;
request.mobileNo = '0' + this.mobileNumber.toString(); request.mobileNo = '0' + this.mobileNumber.toString();
request.deviceToken = this.deviceToken; request.deviceToken = this.deviceToken;
request.projectOutSA = this.patientOutSA; request.projectOutSA = this.patientOutSA == true ? 1 : 0;
request.loginType = this.selectedOption; request.loginType = this.selectedOption;
request.oTPSendType = this.selectedOption == 1 ? 1 : 2; request.oTPSendType = this.selectedOption == 1 ? 1 : 2;
request.zipCode = this.zipCode; request.zipCode = this.zipCode;
request.isRegister = false; request.isRegister = false;
request.logInTokenID = this.loginTokenID ?? ""; request.logInTokenID = this.loginTokenID ?? "";
if (this.registerd_data != null) { if (this.registerd_data != null) {
request.searchType = this.registerd_data.searchType == 1 request.searchType = this.registerd_data.searchType ?? 1;
? this.registerd_data.searchType request.patientID = this.registerd_data.patientID ?? 0;
: 1; request.patientIdentificationID = request.nationalID =
request.patientID = this.registerd_data.patientID != 0 this.registerd_data.patientIdentificationID ?? '0';
? this.registerd_data.patientID
: 0;
request.patientIdentificationID =
request.nationalID = this.registerd_data.patientIdentificationID;
} else { } else {
request.searchType = request.searchType == 1 ? request.searchType : 2; request.searchType = request.searchType ?? 2;
request.patientID = int.parse(this.user.PatientID); request.patientID = this.user.patientID ?? 0;
request.patientID = request.nationalID = request.nationalID = request.nationalID ?? '0';
request.nationalID != null ? request.nationalID : 0; request.patientIdentificationID = request.patientIdentificationID ?? '0';
} }
request.deviceTypeID = request.searchType;
return request; return request;
} }
checkActivationCode({value}) { checkActivationCode({value}) {
SMSOTP.showLoadingDialog(context, true); SMSOTP.showLoadingDialog(context, true);
var request = this.getCommonRequest().toJson(); var request = this.getCommonRequest().toJson();
this.authService.checkActivationCode(request, value).then((result) => {
this.userData = this.authService.checkActivationCode(request, value: value).then((result) =>
result.list, //AuthenticatedUser.fromJson(result['List'][0]), {
this.sharedPref.setObject(USER_PROFILE, result.list), if (result != null)
this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), {
this.sharedPref.setString(TOKEN, result.authenticationTokenID), result = CheckActivationCode.fromJson(result),
this.checkIfUserAgreedBefore(result),
Navigator.of(context).pop(), this.userData =
SMSOTP.showLoadingDialog(context, false), result.list, //AuthenticatedUser.fromJson(result['List'][0]),
this.sharedPref.setObject(USER_PROFILE, result.list),
this.loginTokenID = result.logInTokenID,
this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
this.sharedPref.setString(TOKEN, result.authenticationTokenID),
this.checkIfUserAgreedBefore(result),
Navigator.of(context).pop(),
SMSOTP.showLoadingDialog(context, false),
}
else
{
AppToast.showErrorToast(message: 'Please Enter Valid Code'),
Navigator.of(context).pop(),
SMSOTP.showLoadingDialog(context, false)
}
}); });
} }
@ -580,4 +547,185 @@ class _ConfirmLogin extends State<ConfirmLogin> {
isLoading = flag; isLoading = flag;
}); });
} }
Widget getButton(flag) {
switch (flag) {
case 4:
return InkWell(
onTap: () => {authenticateUser(4, true)},
child: RoundedContainer(
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding: EdgeInsets.fromLTRB(25, 10, 25, 10),
child: Column(
children: <Widget>[
Image.asset(
'assets/images/login/104.png',
height: SizeConfig.imageSizeMultiplier * 13,
width: SizeConfig.imageSizeMultiplier * 16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).verifyWhatsApp,
fontSize: SizeConfig.textMultiplier * 2,
)
],
),
)));
break;
case 1:
return InkWell(
onTap: () => {authenticateUser(1, true)},
child: RoundedContainer(
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'assets/images/login/103.png',
height: SizeConfig.imageSizeMultiplier * 13,
width: SizeConfig.imageSizeMultiplier * 16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).verifySMS,
fontSize: SizeConfig.textMultiplier * 2,
)
],
),
)));
break;
case 2:
return InkWell(
onTap: () => {authenticateUser(2, BiometricType.fingerprint.index)},
child: RoundedContainer(
backgroundColor: BiometricType.fingerprint.index == 1
? Colors.white
: Colors.white.withOpacity(.7),
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding: EdgeInsets.fromLTRB(25, 10, 25, 10),
child: Column(
children: <Widget>[
Image.asset(
'assets/images/login/102.png',
height: SizeConfig.imageSizeMultiplier * 13,
width: SizeConfig.imageSizeMultiplier * 16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).verifyFingerprint,
fontSize: SizeConfig.textMultiplier * 2,
)
],
),
)));
break;
case 3:
return InkWell(
onTap: () => {authenticateUser(3, BiometricType.face.index)},
child: RoundedContainer(
backgroundColor: BiometricType.face.index == 1
? Colors.white
: Colors.white.withOpacity(.7),
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'assets/images/login/101.png',
height: SizeConfig.imageSizeMultiplier * 13,
width: SizeConfig.imageSizeMultiplier * 16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).verifyFaceID,
fontSize: SizeConfig.textMultiplier * 2,
)
],
),
)));
break;
default:
return InkWell(
onTap: () => {
setState(() {
isMoreOption = true;
})
},
child: RoundedContainer(
backgroundColor: BiometricType.fingerprint.index == 1
? Colors.white
: Colors.white.withOpacity(.7),
borderColor: Colors.grey,
showBorder: true,
child: Padding(
padding: EdgeInsets.fromLTRB(0, 10, 0, 5),
child: Column(
children: <Widget>[
Image.asset(
'assets/images/login/more_icon.png',
height: SizeConfig.imageSizeMultiplier * 13,
width: SizeConfig.imageSizeMultiplier * 16,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).moreVerification,
fontSize: SizeConfig.textMultiplier * 2,
textAlign: TextAlign.center,
)
],
),
)));
}
}
getType(type, context) {
switch (type) {
case 1:
return TranslationBase.of(context).verifySMS;
break;
case 2:
return TranslationBase.of(context).verifyFingerprint;
break;
case 3:
return TranslationBase.of(context).verifyFaceID;
break;
case 4:
return TranslationBase.of(context).verifyWhatsApp;
break;
default:
return TranslationBase.of(context).verifySMS;
break;
}
}
formatDate(date) {
return DateFormat('MMM dd, yyy, kk:mm').format(date);
}
showLoader(bool isTrue) {
setState(() {
isLoading = isTrue;
});
}
} }

@ -1,7 +1,10 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart';
import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart';
import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart';
import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/routes.dart';
@ -18,6 +21,7 @@ import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_pro
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
class Login extends StatefulWidget { class Login extends StatefulWidget {
@override @override
@ -34,6 +38,12 @@ class _Login extends State<Login> {
final authService = new AuthProvider(); final authService = new AuthProvider();
var sharedPref = new AppSharedPreferences(); var sharedPref = new AppSharedPreferences();
bool isLoading = false; bool isLoading = false;
@override
void initState() {
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return AppScaffold(
@ -164,12 +174,44 @@ class _Login extends State<Login> {
} }
else else
{ {
if (value.IsAuthenticated) {this.checkActivationCode()} if (value['IsAuthenticated']) {this.checkActivationCode()}
} }
}); });
} }
checkActivationCode() {} checkActivationCode({code}) async {
Map<String, dynamic> request = {};
// request.logInTokenID = await sharedPref.getString(LOGIN_TOKEN_ID);
// request.activationCode = code ?? "0000";
// request.isSilentLogin = code != null ? false : true;
request['PatientMobileNumber'] = int.parse(mobileNo);
request['ZipCode'] = countryCode;
request['SearchType'] = loginType;
request['LoginType'] = loginType;
if (this.loginType == 1) {
request['PatientIdentificationID'] = this.nationalIDorFile.text;
request['PatientID'] = 0;
} else {
request['PatientIdentificationID'] = '';
request['PatientID'] = int.parse(nationalIDorFile.text);
}
// request.isRegister = false;
this
.authService
.checkActivationCode(request, value: code)
.then((result) => {
result = CheckActivationCode.fromJson(result),
this.sharedPref.setObject(USER_PROFILE, result.list),
this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
this.sharedPref.setString(TOKEN, result.authenticationTokenID),
//this.checkIfUserAgreedBefore(result),
Navigator.of(context).pushNamed(
HOME,
)
// SMSOTP.showLoadingDialog(context, false),
});
}
showLoader(bool isTrue) { showLoader(bool isTrue) {
setState(() { setState(() {
isLoading = isTrue; isLoading = isTrue;

@ -1,14 +1,30 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart';
import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/routes.dart';
class WelcomeLogin extends StatelessWidget { class WelcomeLogin extends StatefulWidget {
@override @override
_WelcomeLogin createState() => _WelcomeLogin();
}
class _WelcomeLogin extends State<WelcomeLogin> {
bool isLoading = true;
@override
void initState() {
isLoading = true;
// checkUser(context);
super.initState();
}
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return AppScaffold(
appBarTitle: TranslationBase.of(context).welcome, appBarTitle: TranslationBase.of(context).welcome,

@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/login/welcome.dart';
import 'package:diplomaticquarterapp/pages/login/login-type.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart';
import 'package:diplomaticquarterapp/pages/login/login.dart'; import 'package:diplomaticquarterapp/pages/login/login.dart';
import 'package:diplomaticquarterapp/pages/login/register.dart'; import 'package:diplomaticquarterapp/pages/login/register.dart';
import 'package:flutter/material.dart';
const String INIT_ROUTE = '/'; const String INIT_ROUTE = '/';
const String ROOT = 'root'; const String ROOT = 'root';

@ -213,7 +213,7 @@ class AuthProvider with ChangeNotifier {
} }
} }
Future<CheckActivationCode> checkActivationCode(request, value) async { Future checkActivationCode(request, {value}) async {
var neRequest = CheckActivationCodeReq.fromJson(request); var neRequest = CheckActivationCodeReq.fromJson(request);
neRequest.activationCode = value ?? "0000"; neRequest.activationCode = value ?? "0000";
neRequest.isSilentLogin = value != null ? false : true; neRequest.isSilentLogin = value != null ? false : true;
@ -225,18 +225,20 @@ class AuthProvider with ChangeNotifier {
neRequest.languageID = 2; neRequest.languageID = 2;
neRequest.deviceTypeID = DeviceTypeID; neRequest.deviceTypeID = DeviceTypeID;
neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1; neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1;
neRequest.projectOutSA = neRequest.zipCode == '966' ? 0 : 1;
neRequest.isDentalAllowedBackend = false; neRequest.isDentalAllowedBackend = false;
try { try {
dynamic localRes; dynamic localRes;
await new BaseAppClient().post(CHECK_ACTIVATION_CODE, await new BaseAppClient().post(CHECK_ACTIVATION_CODE,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
localRes = CheckActivationCode.fromJson(response); localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
throw error; throw error;
}, body: neRequest.toJson()); }, body: neRequest.toJson());
return Future.value(localRes); return Future.value(localRes);
} catch (error) { } catch (error) {
print(error); Future.error(error);
throw error; throw error;
} }
} }

@ -160,6 +160,12 @@ class TranslationBase {
localizedValues['notification'][locale.languageCode]; localizedValues['notification'][locale.languageCode];
String get appsetting => localizedValues['app-settings'][locale.languageCode]; String get appsetting => localizedValues['app-settings'][locale.languageCode];
String get rateApp => localizedValues['rate-app'][locale.languageCode]; String get rateApp => localizedValues['rate-app'][locale.languageCode];
String get moreVerification =>
localizedValues['more-verify'][locale.languageCode];
String get welcomeBack =>
localizedValues['welcome-back'][locale.languageCode];
String get accountInfo =>
localizedValues['account-info'][locale.languageCode];
} }
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> { class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

@ -41,7 +41,7 @@ class _AppDrawerState extends State<AppDrawer> {
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
children: <Widget>[ children: <Widget>[
Container( Container(
height: SizeConfig.screenHeight * .25, height: SizeConfig.screenHeight * .30,
child: InkWell( child: InkWell(
child: DrawerHeader( child: DrawerHeader(
child: Column( child: Column(
@ -168,9 +168,7 @@ class _AppDrawerState extends State<AppDrawer> {
TranslationBase.of(context).loginregister, TranslationBase.of(context).loginregister,
Icons.lock_open), Icons.lock_open),
onTap: () { onTap: () {
Navigator.of(context).pushNamed( login();
WELCOME_LOGIN,
);
}, },
), ),
], ],
@ -214,17 +212,35 @@ class _AppDrawerState extends State<AppDrawer> {
} }
checkUserData() async { checkUserData() async {
var data = AuthenticatedUser.fromJson( if (await this.sharedPref.getObject(USER_PROFILE) != null) {
await this.sharedPref.getObject(USER_PROFILE)); var data = AuthenticatedUser.fromJson(
setState(() { await this.sharedPref.getObject(USER_PROFILE));
this.user = data; setState(() {
print(this.user); this.user = data;
}); print(this.user);
});
}
} }
logout() async { logout() async {
this.sharedPref.remove(USER_PROFILE); // this.sharedPref.remove(USER_PROFILE);
// this.sharedPref.remove(IMEI_USER_DATA);
// this.sharedPref.remove(TOKEN);
// this.sharedPref.remove(LOGIN_TOKEN_ID);
await sharedPref.clear();
this.user = null; this.user = null;
Navigator.of(context).pushNamed(HOME); Navigator.of(context).pushNamed(HOME);
} }
login() async {
var data = await sharedPref.getObject(IMEI_USER_DATA);
if (data != null) {
Navigator.of(context).pushNamed(CONFIRM_LOGIN);
} else {
Navigator.of(context).pushNamed(
WELCOME_LOGIN,
);
}
}
} }

@ -1,4 +1,5 @@
import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import '../progress_indicator/app_loader_widget.dart'; import '../progress_indicator/app_loader_widget.dart';
import 'arrow_back.dart'; import 'arrow_back.dart';
@ -50,6 +51,9 @@ class AppScaffold extends StatelessWidget {
color: Colors.white, color: Colors.white,
onPressed: () { onPressed: () {
// TODO add navigator to home page // TODO add navigator to home page
Navigator.of(context).pushNamed(
HOME,
);
}, },
), ),
], ],

@ -74,7 +74,7 @@ class SMSOTP {
? Image.asset('assets/images/login/103.png') ? Image.asset('assets/images/login/103.png')
: Image.asset('assets/images/login/104.png'), : Image.asset('assets/images/login/104.png'),
Padding( Padding(
padding: EdgeInsets.only(top: 20), padding: EdgeInsets.only(top: 5),
child: AppText( child: AppText(
TranslationBase.of(context).verificationMessage + TranslationBase.of(context).verificationMessage +
' XXXXXX' + ' XXXXXX' +

Loading…
Cancel
Save