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"},
"notification": {"en": "Notifications", "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 '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/utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
AppSharedPreferences sharedPref = new AppSharedPreferences();
@ -43,6 +46,8 @@ class BaseAppClient {
if (!parsed['IsAuthenticated']) {
if (parsed['isSMSSent'] == true) {
onSuccess(parsed, statusCode);
} else {
logout();
}
// await helpers.logout();
//helpers.showErrorToast('Your session expired Please login agian');
@ -63,4 +68,8 @@ class BaseAppClient {
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 'core/service/hospital_service.dart';

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

@ -1,68 +1,68 @@
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
class CheckActivationCode {
Null date;
dynamic date;
int languageID;
int serviceName;
Null time;
Null androidLink;
dynamic time;
dynamic androidLink;
String authenticationTokenID;
Null data;
dynamic data;
bool dataw;
int dietType;
Null errorCode;
Null errorEndUserMessage;
Null errorEndUserMessageN;
Null errorMessage;
dynamic errorCode;
dynamic errorEndUserMessage;
dynamic errorEndUserMessageN;
dynamic errorMessage;
int errorType;
int foodCategory;
Null iOSLink;
dynamic iOSLink;
bool isAuthenticated;
int mealOrderStatus;
int mealType;
int messageStatus;
int numberOfResultRecords;
Null patientBlodType;
Null successMsg;
Null successMsgN;
Null doctorInformationList;
Null getAllPendingRecordsList;
Null getAllSharedRecordsByStatusList;
Null getResponseFileList;
dynamic patientBlodType;
dynamic successMsg;
dynamic successMsgN;
dynamic doctorInformationList;
dynamic getAllPendingRecordsList;
dynamic getAllSharedRecordsByStatusList;
dynamic getResponseFileList;
bool isHMGPatient;
bool isLoginSuccessfully;
bool isNeedUpdateIdintificationNo;
bool kioskSendSMS;
AuthenticatedUser list;
Null listAskHabibMobileLoginInfo;
Null listAskHabibPatientFile;
Null listMergeFiles;
Null listMobileLoginInfo;
Null listPatientCount;
Null logInTokenID;
Null mohemmPrivilegeList;
dynamic listAskHabibMobileLoginInfo;
dynamic listAskHabibPatientFile;
dynamic listMergeFiles;
dynamic listMobileLoginInfo;
dynamic listPatientCount;
dynamic logInTokenID;
dynamic mohemmPrivilegeList;
int pateintID;
Null patientBloodType;
String patientBloodType;
bool patientHasFile;
Null patientMergedIDs;
dynamic patientMergedIDs;
bool patientOutSA;
int patientShareRequestID;
int patientType;
int projectIDOut;
Null returnMessage;
dynamic returnMessage;
bool sMSLoginRequired;
Null servicePrivilegeList;
Null sharePatientName;
Null verificationCode;
Null email;
Null errorList;
dynamic servicePrivilegeList;
dynamic sharePatientName;
dynamic verificationCode;
dynamic email;
dynamic errorList;
bool hasFile;
bool isActiveCode;
bool isMerged;
bool isNeedUserAgreement;
bool isSMSSent;
Null memberList;
Null message;
dynamic memberList;
dynamic message;
int statusCode;
CheckActivationCode(
@ -283,52 +283,52 @@ class List {
int relationshipID;
int gender;
String dateofBirth;
Null dateofBirthN;
dynamic dateofBirthN;
String nationalityID;
Null phoneResi;
Null phoneOffice;
dynamic phoneResi;
dynamic phoneOffice;
String mobileNumber;
Null faxNumber;
dynamic faxNumber;
String emailAddress;
Null bloodGroup;
Null rHFactor;
dynamic bloodGroup;
dynamic rHFactor;
bool isEmailAlertRequired;
bool isSMSAlertRequired;
String preferredLanguage;
bool isPrivilegedMember;
Null memberID;
Null expiryDate;
Null isHmgEmployee;
Null employeeID;
Null emergencyContactName;
Null emergencyContactNo;
dynamic memberID;
dynamic expiryDate;
dynamic isHmgEmployee;
dynamic employeeID;
dynamic emergencyContactName;
dynamic emergencyContactNo;
int patientPayType;
Null dHCCPatientRefID;
dynamic dHCCPatientRefID;
bool isPatientDummy;
int status;
Null isStatusCleared;
dynamic isStatusCleared;
int patientIdentificationType;
String patientIdentificationNo;
int projectID;
int infoSourceID;
Null address;
dynamic address;
int age;
String ageDesc;
int areaID;
int createdBy;
String genderDescription;
Null iR;
Null iSOCityID;
Null iSOCountryID;
dynamic iR;
dynamic iSOCityID;
dynamic iSOCountryID;
ListPrivilege listPrivilege;
Null marital;
dynamic marital;
int outSA;
Null pOBox;
dynamic pOBox;
bool receiveHealthSummaryReport;
int sourceType;
Null strDateofBirth;
Null tempAddress;
Null zipCode;
dynamic strDateofBirth;
dynamic tempAddress;
dynamic zipCode;
List({
this.setupID,
@ -525,7 +525,7 @@ class ListPrivilege {
int iD;
String serviceName;
bool previlege;
Null region;
dynamic 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/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_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/check_activation_code_request.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.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/widgets/card/rounded_container.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:diplomaticquarterapp/routes.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';
class ConfirmLogin extends StatefulWidget {
@ -28,16 +28,16 @@ class ConfirmLogin extends StatefulWidget {
class _ConfirmLogin extends State<ConfirmLogin> {
final LocalAuthentication auth = LocalAuthentication();
List _availableBiometrics;
dynamic _availableBiometrics;
var sharedPref = new AppSharedPreferences();
bool authenticated;
final authService = new AuthProvider();
int mobileNumber;
String errorMsg = '';
var user;
SelectDeviceIMEIRES user;
bool isLoading = false;
CheckPatientAuthenticationReq registerd_data;
bool isMoreOption = false;
var zipCode;
var patientOutSA;
@ -58,6 +58,7 @@ class _ConfirmLogin extends State<ConfirmLogin> {
static BuildContext _context;
static bool _loading;
@override
void initState() {
_getAvailableBiometrics();
@ -80,10 +81,69 @@ class _ConfirmLogin extends State<ConfirmLogin> {
children: <Widget>[
Expanded(
flex: 3,
child: Column(
child: user != null && isMoreOption == false
? Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
'assets/images/habib-logo.png',
height: 80,
width: 80,
),
AppText(
TranslationBase.of(context)
.welcomeBack +
' ' +
user.name,
fontSize: SizeConfig.textMultiplier * 4,
),
AppText(
TranslationBase.of(context).accountInfo,
fontSize: SizeConfig.textMultiplier * 3,
),
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,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
'assets/images/habib-logo.png',
@ -95,25 +155,28 @@ class _ConfirmLogin extends State<ConfirmLogin> {
TranslationBase.of(context)
.verifyLoginWith,
fontSize:
SizeConfig.textMultiplier * 3.5,
SizeConfig.textMultiplier *
3.5,
textAlign: TextAlign.left,
)
: AppText(
TranslationBase.of(context)
.verifyFingerprint2,
fontSize:
SizeConfig.textMultiplier * 2.5,
SizeConfig.textMultiplier *
2.5,
textAlign: TextAlign.left,
),
])),
Expanded(
flex: 4,
user != null && isMoreOption == false
? Expanded(
flex: 2,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
onlySMSBox == false
? Row(
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
@ -125,178 +188,34 @@ class _ConfirmLogin extends State<ConfirmLogin> {
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: getButton(
user.logInType))),
Expanded(child: getButton(5))
])
]))
: Expanded(
flex: 4,
child: Column(
mainAxisAlignment:
MainAxisAlignment
.center,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
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(
onlySMSBox == false
? Row(
mainAxisAlignment:
MainAxisAlignment.center,
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,
)
],
),
))))
Expanded(child: getButton(3)),
Expanded(child: getButton(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(
MainAxisAlignment.center,
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(child: getButton(1)),
Expanded(child: getButton(4))
],
),
]),
@ -369,27 +288,50 @@ class _ConfirmLogin extends State<ConfirmLogin> {
loginWithSMS(type, isActive) {
//if (!el.disabled) {
if (this.user != null && this.registerd_data != null) {
if (this.user != null && this.registerd_data == null) {
this.checkUserAuthentication(type);
} else {
if (this.loginTokenID != null) {
Future.delayed(Duration(seconds: 1), () {
this.sendActivationCode(type);
});
} else {
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) {
var request = this.getCommonRequest();
loading(true);
this.authService.sendActivationCode(request).then((result) => {
if (result['isSMSSent'] == true)
if (result != null && result['isSMSSent'] == true)
{loading(false), this.startSMSService(type)}
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 {
// this.user = this.cs.sharedService.getSharedData(
// AuthenticationService.IMEI_USER_DATA,
// false
// );
setState(() {
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.registerd_data.patientMobileNumber
: int.parse(this.user.Mobile);
: int.parse(this.user.mobile);
this.zipCode = this.registerd_data != null
? this.registerd_data.zipCode
: this.user.OutSA ? "971" : "966";
: this.user.outSA == true ? "971" : "966";
this.patientOutSA = this.registerd_data != null
? this.registerd_data.zipCode == "966" ? 0 : 1
: this.user.OutSA;
: this.user.outSA;
if (this.registerd_data != null) {
this.loginTokenID = await sharedPref.getString(LOGIN_TOKEN_ID);
this.loginType = this.registerd_data.searchType;
}
this.deviceToken = await sharedPref.getString(PUSH_TOKEN);
this.lastLogin = await sharedPref.getInt(
LAST_LOGIN); //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN);
this.lastLogin = await sharedPref.getInt(LAST_LOGIN) != null
? await sharedPref.getInt(LAST_LOGIN)
: user.logInType;
//this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN);
}
getCommonRequest() {
@ -488,42 +443,54 @@ class _ConfirmLogin extends State<ConfirmLogin> {
request.patientMobileNumber = this.mobileNumber;
request.mobileNo = '0' + this.mobileNumber.toString();
request.deviceToken = this.deviceToken;
request.projectOutSA = this.patientOutSA;
request.projectOutSA = this.patientOutSA == true ? 1 : 0;
request.loginType = this.selectedOption;
request.oTPSendType = this.selectedOption == 1 ? 1 : 2;
request.zipCode = this.zipCode;
request.isRegister = false;
request.logInTokenID = this.loginTokenID ?? "";
if (this.registerd_data != null) {
request.searchType = this.registerd_data.searchType == 1
? this.registerd_data.searchType
: 1;
request.patientID = this.registerd_data.patientID != 0
? this.registerd_data.patientID
: 0;
request.patientIdentificationID =
request.nationalID = this.registerd_data.patientIdentificationID;
request.searchType = this.registerd_data.searchType ?? 1;
request.patientID = this.registerd_data.patientID ?? 0;
request.patientIdentificationID = request.nationalID =
this.registerd_data.patientIdentificationID ?? '0';
} else {
request.searchType = request.searchType == 1 ? request.searchType : 2;
request.patientID = int.parse(this.user.PatientID);
request.patientID = request.nationalID =
request.nationalID != null ? request.nationalID : 0;
request.searchType = request.searchType ?? 2;
request.patientID = this.user.patientID ?? 0;
request.nationalID = request.nationalID ?? '0';
request.patientIdentificationID = request.patientIdentificationID ?? '0';
}
request.deviceTypeID = request.searchType;
return request;
}
checkActivationCode({value}) {
SMSOTP.showLoadingDialog(context, true);
var request = this.getCommonRequest().toJson();
this.authService.checkActivationCode(request, value).then((result) => {
this.authService.checkActivationCode(request, value: value).then((result) =>
{
if (result != null)
{
result = CheckActivationCode.fromJson(result),
this.userData =
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;
});
}
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/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/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/services/authentication/auth_provider.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:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
class Login extends StatefulWidget {
@override
@ -34,6 +38,12 @@ class _Login extends State<Login> {
final authService = new AuthProvider();
var sharedPref = new AppSharedPreferences();
bool isLoading = false;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return AppScaffold(
@ -164,12 +174,44 @@ class _Login extends State<Login> {
}
else
{
if (value.IsAuthenticated) {this.checkActivationCode()}
if (value['IsAuthenticated']) {this.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),
});
}
checkActivationCode() {}
showLoader(bool isTrue) {
setState(() {
isLoading = isTrue;

@ -1,14 +1,30 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.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/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.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/material.dart';
import 'package:diplomaticquarterapp/routes.dart';
class WelcomeLogin extends StatelessWidget {
class WelcomeLogin extends StatefulWidget {
@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) {
return AppScaffold(
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.dart';
import 'package:diplomaticquarterapp/pages/login/register.dart';
import 'package:flutter/material.dart';
const String INIT_ROUTE = '/';
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);
neRequest.activationCode = value ?? "0000";
neRequest.isSilentLogin = value != null ? false : true;
@ -225,18 +225,20 @@ class AuthProvider with ChangeNotifier {
neRequest.languageID = 2;
neRequest.deviceTypeID = DeviceTypeID;
neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1;
neRequest.projectOutSA = neRequest.zipCode == '966' ? 0 : 1;
neRequest.isDentalAllowedBackend = false;
try {
dynamic localRes;
await new BaseAppClient().post(CHECK_ACTIVATION_CODE,
onSuccess: (dynamic response, int statusCode) {
localRes = CheckActivationCode.fromJson(response);
localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) {
throw error;
}, body: neRequest.toJson());
return Future.value(localRes);
} catch (error) {
print(error);
Future.error(error);
throw error;
}
}

@ -160,6 +160,12 @@ class TranslationBase {
localizedValues['notification'][locale.languageCode];
String get appsetting => localizedValues['app-settings'][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> {

@ -41,7 +41,7 @@ class _AppDrawerState extends State<AppDrawer> {
padding: EdgeInsets.zero,
children: <Widget>[
Container(
height: SizeConfig.screenHeight * .25,
height: SizeConfig.screenHeight * .30,
child: InkWell(
child: DrawerHeader(
child: Column(
@ -168,9 +168,7 @@ class _AppDrawerState extends State<AppDrawer> {
TranslationBase.of(context).loginregister,
Icons.lock_open),
onTap: () {
Navigator.of(context).pushNamed(
WELCOME_LOGIN,
);
login();
},
),
],
@ -214,6 +212,7 @@ class _AppDrawerState extends State<AppDrawer> {
}
checkUserData() async {
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson(
await this.sharedPref.getObject(USER_PROFILE));
setState(() {
@ -221,10 +220,27 @@ class _AppDrawerState extends State<AppDrawer> {
print(this.user);
});
}
}
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;
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/routes.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import '../progress_indicator/app_loader_widget.dart';
import 'arrow_back.dart';
@ -50,6 +51,9 @@ class AppScaffold extends StatelessWidget {
color: Colors.white,
onPressed: () {
// 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/104.png'),
Padding(
padding: EdgeInsets.only(top: 20),
padding: EdgeInsets.only(top: 5),
child: AppText(
TranslationBase.of(context).verificationMessage +
' XXXXXX' +

Loading…
Cancel
Save