Merge branch 'development' into medical-profile-services

# Conflicts:
#	lib/locator.dart
merge-requests/672/head
mosazaid 5 years ago
commit 9e80a1879e

@ -322,4 +322,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 649616dc336b3659ac6b2b25159d8e488e042b69
COCOAPODS: 1.10.1
COCOAPODS: 1.10.0.rc.1

@ -3,12 +3,14 @@ import 'dart:io' show Platform;
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'package:provider/provider.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = new Helpers();
@ -21,6 +23,8 @@ class BaseAppClient {
Function(String error, int statusCode) onFailure,
bool isAllowAny = false}) async {
String url = BASE_URL + endPoint;
bool callLog= true;
try {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
String token = await sharedPref.getString(TOKEN);
@ -99,7 +103,7 @@ class BaseAppClient {
if (body['OTP_SendType'] != null) {
onFailure(getError(parsed), statusCode);
} else if (!isAllowAny) {
await Helpers.logout();
await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX, listen: false).logout(isSessionTimeout: true);
Helpers.showErrorToast('Your session expired Please login again');
}
if (isAllowAny) {

@ -331,9 +331,6 @@ var SERVICES_PATIANT_HEADER_AR = [
"المريض المحول مني",
"المريض الواصل"
];
//******************
// Colors ////// by : ibrahim
var DEVICE_TOKEN = "";
const PRIMARY_COLOR = 0xff515B5D;

@ -579,10 +579,11 @@ const Map<String, Map<String, String>> localizedValues = {
"ar": "الرجاء اختيار احدى الخيارات التالية للتحقق من البيانات"
},
"register-user": {"en": "Register", "ar": "تسجيل"},
"verify-with-fingerprint": {"en": "Verify through Fingerprint", "ar": "بصمة"},
"verify-with-faceid": {"en": "Verify through Face ID", "ar": "معرف الوجه"},
"verify-with-sms": {"en": "Verify through SMS", "ar": "الرسائل القصيرة"},
"verify-with-whatsapp": {"en": "Verify through WhatsApp", "ar": " الواتس اب"},
"verify-with-fingerprint": {"en": "Fingerprint", "ar": "بصمة"},
"verify-with-faceid": {"en": "Face ID", "ar": "معرف الوجه"},
"verify-with-sms": {"en": " SMS", "ar": "الرسائل القصيرة"},
"verify-with-whatsapp": {"en": "WhatsApp", "ar": " الواتس اب"},
"verify-with": {"en": "Verify through ", "ar": " الواتس اب"},
"last-login": {
"en": "Last login details:",
"ar": "تفاصيل تسجيل الدخول الأخير:"

@ -0,0 +1,46 @@
enum AuthMethodTypes { SMS, WhatsApp, Fingerprint,FaceID,MoreOptions }
extension SelectedAuthMethodTypesService on AuthMethodTypes {
// ignore: missing_return
int getTypeIdService() {
switch (this) {
case AuthMethodTypes.SMS:
return 1;
break;
case AuthMethodTypes.WhatsApp:
return 2;
break;
case AuthMethodTypes.Fingerprint:
return 3;
break;
case AuthMethodTypes.FaceID:
return 4;
break;
case AuthMethodTypes.MoreOptions:
return 5;
break;
}
}
// ignore: missing_return
static getMethodsTypeService( int typeId) {
switch (typeId) {
case 1:
return AuthMethodTypes.SMS;
break;
case 2:
return AuthMethodTypes.WhatsApp;
break;
case 3:
return AuthMethodTypes.Fingerprint;
break;
case 4:
return AuthMethodTypes.FaceID;
break;
case 5:
return AuthMethodTypes.MoreOptions;
break;
}
}
}

@ -1,4 +1,4 @@
class ActivationCodeModel2 {
class ActivationCodeForVerificationScreenModel {
int oTPSendType;
String mobileNumber;
String zipCode;
@ -12,7 +12,7 @@ class ActivationCodeModel2 {
String vidaAuthTokenID;
String vidaRefreshTokenID;
String iMEI;
ActivationCodeModel2(
ActivationCodeForVerificationScreenModel(
{this.oTPSendType,
this.mobileNumber,
this.zipCode,
@ -27,7 +27,7 @@ class ActivationCodeModel2 {
this.vidaRefreshTokenID,
this.iMEI});
ActivationCodeModel2.fromJson(Map<String, dynamic> json) {
ActivationCodeForVerificationScreenModel.fromJson(Map<String, dynamic> json) {
oTPSendType = json['OTP_SendType'];
mobileNumber = json['MobileNumber'];
zipCode = json['ZipCode'];

@ -0,0 +1,192 @@
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
class CheckActivationCodeForDoctorAppResponseModel {
String authenticationTokenID;
List<ListDoctorsClinic> listDoctorsClinic;
List<DoctorProfileModel> listDoctorProfile;
MemberInformation memberInformation;
CheckActivationCodeForDoctorAppResponseModel(
{this.authenticationTokenID,
this.listDoctorsClinic,
this.memberInformation});
CheckActivationCodeForDoctorAppResponseModel.fromJson(
Map<String, dynamic> json) {
authenticationTokenID = json['AuthenticationTokenID'];
if (json['List_DoctorsClinic'] != null) {
listDoctorsClinic = new List<ListDoctorsClinic>();
json['List_DoctorsClinic'].forEach((v) {
listDoctorsClinic.add(new ListDoctorsClinic.fromJson(v));
});
}
if (json['List_DoctorProfile'] != null) {
listDoctorProfile = new List<DoctorProfileModel>();
json['List_DoctorProfile'].forEach((v) {
listDoctorProfile.add(new DoctorProfileModel.fromJson(v));
});
}
memberInformation = json['memberInformation'] != null
? new MemberInformation.fromJson(json['memberInformation'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['AuthenticationTokenID'] = this.authenticationTokenID;
if (this.listDoctorsClinic != null) {
data['List_DoctorsClinic'] =
this.listDoctorsClinic.map((v) => v.toJson()).toList();
}
if (this.listDoctorProfile != null) {
data['List_DoctorProfile'] =
this.listDoctorProfile.map((v) => v.toJson()).toList();
}
if (this.memberInformation != null) {
data['memberInformation'] = this.memberInformation.toJson();
}
return data;
}
}
class ListDoctorsClinic {
Null setupID;
int projectID;
int doctorID;
int clinicID;
bool isActive;
String clinicName;
ListDoctorsClinic({this.setupID,
this.projectID,
this.doctorID,
this.clinicID,
this.isActive,
this.clinicName});
ListDoctorsClinic.fromJson(Map<String, dynamic> json) {
setupID = json['SetupID'];
projectID = json['ProjectID'];
doctorID = json['DoctorID'];
clinicID = json['ClinicID'];
isActive = json['IsActive'];
clinicName = json['ClinicName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['SetupID'] = this.setupID;
data['ProjectID'] = this.projectID;
data['DoctorID'] = this.doctorID;
data['ClinicID'] = this.clinicID;
data['IsActive'] = this.isActive;
data['ClinicName'] = this.clinicName;
return data;
}
}
class MemberInformation {
List<Clinics> clinics;
int doctorId;
String email;
int employeeId;
int memberId;
Null memberName;
Null memberNameArabic;
String preferredLanguage;
List<Roles> roles;
MemberInformation({this.clinics,
this.doctorId,
this.email,
this.employeeId,
this.memberId,
this.memberName,
this.memberNameArabic,
this.preferredLanguage,
this.roles});
MemberInformation.fromJson(Map<String, dynamic> json) {
if (json['clinics'] != null) {
clinics = new List<Clinics>();
json['clinics'].forEach((v) {
clinics.add(new Clinics.fromJson(v));
});
}
doctorId = json['doctorId'];
email = json['email'];
employeeId = json['employeeId'];
memberId = json['memberId'];
memberName = json['memberName'];
memberNameArabic = json['memberNameArabic'];
preferredLanguage = json['preferredLanguage'];
if (json['roles'] != null) {
roles = new List<Roles>();
json['roles'].forEach((v) {
roles.add(new Roles.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.clinics != null) {
data['clinics'] = this.clinics.map((v) => v.toJson()).toList();
}
data['doctorId'] = this.doctorId;
data['email'] = this.email;
data['employeeId'] = this.employeeId;
data['memberId'] = this.memberId;
data['memberName'] = this.memberName;
data['memberNameArabic'] = this.memberNameArabic;
data['preferredLanguage'] = this.preferredLanguage;
if (this.roles != null) {
data['roles'] = this.roles.map((v) => v.toJson()).toList();
}
return data;
}
}
class Clinics {
bool defaultClinic;
int id;
String name;
Clinics({this.defaultClinic, this.id, this.name});
Clinics.fromJson(Map<String, dynamic> json) {
defaultClinic = json['defaultClinic'];
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['defaultClinic'] = this.defaultClinic;
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}
class Roles {
String name;
int roleId;
Roles({this.name, this.roleId});
Roles.fromJson(Map<String, dynamic> json) {
name = json['name'];
roleId = json['roleId'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['name'] = this.name;
data['roleId'] = this.roleId;
return data;
}
}

@ -0,0 +1,113 @@
class NewLoginInformationModel {
int doctorID;
List<ListMemberInformation> listMemberInformation;
String logInTokenID;
String mobileNumber;
Null sELECTDeviceIMEIbyIMEIList;
int userID;
String zipCode;
bool isActiveCode;
bool isSMSSent;
NewLoginInformationModel(
{this.doctorID,
this.listMemberInformation,
this.logInTokenID,
this.mobileNumber,
this.sELECTDeviceIMEIbyIMEIList,
this.userID,
this.zipCode,
this.isActiveCode,
this.isSMSSent});
NewLoginInformationModel.fromJson(Map<String, dynamic> json) {
doctorID = json['DoctorID'];
if (json['List_MemberInformation'] != null) {
listMemberInformation = new List<ListMemberInformation>();
json['List_MemberInformation'].forEach((v) {
listMemberInformation.add(new ListMemberInformation.fromJson(v));
});
}
logInTokenID = json['LogInTokenID'];
mobileNumber = json['MobileNumber'];
sELECTDeviceIMEIbyIMEIList = json['SELECTDeviceIMEIbyIMEI_List'];
userID = json['UserID'];
zipCode = json['ZipCode'];
isActiveCode = json['isActiveCode'];
isSMSSent = json['isSMSSent'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['DoctorID'] = this.doctorID;
if (this.listMemberInformation != null) {
data['List_MemberInformation'] =
this.listMemberInformation.map((v) => v.toJson()).toList();
}
data['LogInTokenID'] = this.logInTokenID;
data['MobileNumber'] = this.mobileNumber;
data['SELECTDeviceIMEIbyIMEI_List'] = this.sELECTDeviceIMEIbyIMEIList;
data['UserID'] = this.userID;
data['ZipCode'] = this.zipCode;
data['isActiveCode'] = this.isActiveCode;
data['isSMSSent'] = this.isSMSSent;
return data;
}
}
class ListMemberInformation {
Null setupID;
int memberID;
String memberName;
Null memberNameN;
String preferredLang;
String pIN;
String saltHash;
int referenceID;
int employeeID;
int roleID;
int projectid;
ListMemberInformation(
{this.setupID,
this.memberID,
this.memberName,
this.memberNameN,
this.preferredLang,
this.pIN,
this.saltHash,
this.referenceID,
this.employeeID,
this.roleID,
this.projectid});
ListMemberInformation.fromJson(Map<String, dynamic> json) {
setupID = json['SetupID'];
memberID = json['MemberID'];
memberName = json['MemberName'];
memberNameN = json['MemberNameN'];
preferredLang = json['PreferredLang'];
pIN = json['PIN'];
saltHash = json['SaltHash'];
referenceID = json['ReferenceID'];
employeeID = json['EmployeeID'];
roleID = json['RoleID'];
projectid = json['projectid'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['SetupID'] = this.setupID;
data['MemberID'] = this.memberID;
data['MemberName'] = this.memberName;
data['MemberNameN'] = this.memberNameN;
data['PreferredLang'] = this.preferredLang;
data['PIN'] = this.pIN;
data['SaltHash'] = this.saltHash;
data['ReferenceID'] = this.referenceID;
data['EmployeeID'] = this.employeeID;
data['RoleID'] = this.roleID;
data['projectid'] = this.projectid;
return data;
}
}

@ -0,0 +1,29 @@
class SendActivationCodeForDoctorAppResponseModel {
String logInTokenID;
String verificationCode;
String vidaAuthTokenID;
String vidaRefreshTokenID;
SendActivationCodeForDoctorAppResponseModel(
{this.logInTokenID,
this.verificationCode,
this.vidaAuthTokenID,
this.vidaRefreshTokenID});
SendActivationCodeForDoctorAppResponseModel.fromJson(
Map<String, dynamic> json) {
logInTokenID = json['LogInTokenID'];
verificationCode = json['VerificationCode'];
vidaAuthTokenID = json['VidaAuthTokenID'];
vidaRefreshTokenID = json['VidaRefreshTokenID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['LogInTokenID'] = this.logInTokenID;
data['VerificationCode'] = this.verificationCode;
data['VidaAuthTokenID'] = this.vidaAuthTokenID;
data['VidaRefreshTokenID'] = this.vidaRefreshTokenID;
return data;
}
}

@ -0,0 +1,48 @@
class GetHospitalsRequestModel {
int languageID;
String stamp;
String iPAdress;
double versionID;
int channel;
String tokenID;
String sessionID;
bool isLoginForDoctorApp;
String memberID;
GetHospitalsRequestModel(
{this.languageID,
this.stamp,
this.iPAdress,
this.versionID,
this.channel,
this.tokenID,
this.sessionID,
this.isLoginForDoctorApp,
this.memberID});
GetHospitalsRequestModel.fromJson(Map<String, dynamic> json) {
languageID = json['LanguageID'];
stamp = json['stamp'];
iPAdress = json['IPAdress'];
versionID = json['VersionID'];
channel = json['Channel'];
tokenID = json['TokenID'];
sessionID = json['SessionID'];
isLoginForDoctorApp = json['IsLoginForDoctorApp'];
memberID = json['MemberID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['LanguageID'] = this.languageID;
data['stamp'] = this.stamp;
data['IPAdress'] = this.iPAdress;
data['VersionID'] = this.versionID;
data['Channel'] = this.channel;
data['TokenID'] = this.tokenID;
data['SessionID'] = this.sessionID;
data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp;
data['MemberID'] = this.memberID;
return data;
}
}

@ -0,0 +1,22 @@
class GetHospitalsResponseModel {
String facilityGroupId;
int facilityId;
String facilityName;
GetHospitalsResponseModel(
{this.facilityGroupId, this.facilityId, this.facilityName});
GetHospitalsResponseModel.fromJson(Map<String, dynamic> json) {
facilityGroupId = json['facilityGroupId'];
facilityId = json['facilityId'];
facilityName = json['facilityName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['facilityGroupId'] = this.facilityGroupId;
data['facilityId'] = this.facilityId;
data['facilityName'] = this.facilityName;
return data;
}
}

@ -0,0 +1,163 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/auth/activation_Code_req_model.dart';
import 'package:doctor_app_flutter/core/model/auth/activation_code_for_verification_screen_model.dart';
import 'package:doctor_app_flutter/core/model/auth/check_activation_code_for_doctor_app_response_model.dart';
import 'package:doctor_app_flutter/core/model/auth/check_activation_code_request_model.dart';
import 'package:doctor_app_flutter/core/model/auth/imei_details.dart';
import 'package:doctor_app_flutter/core/model/auth/insert_imei_model.dart';
import 'package:doctor_app_flutter/core/model/auth/new_login_information_response_model.dart';
import 'package:doctor_app_flutter/core/model/auth/send_activation_code_for_doctor_app_response_model.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:doctor_app_flutter/models/doctor/user_model.dart';
class AuthenticationService extends BaseService {
List<GetIMEIDetailsModel> _imeiDetails = [];
List<GetIMEIDetailsModel> get dashboardItemsList => _imeiDetails;
NewLoginInformationModel _loginInfo = NewLoginInformationModel();
NewLoginInformationModel get loginInfo => _loginInfo;
SendActivationCodeForDoctorAppResponseModel _activationCodeVerificationScreenRes = SendActivationCodeForDoctorAppResponseModel();
SendActivationCodeForDoctorAppResponseModel get activationCodeVerificationScreenRes => _activationCodeVerificationScreenRes;
SendActivationCodeForDoctorAppResponseModel _activationCodeForDoctorAppRes = SendActivationCodeForDoctorAppResponseModel();
SendActivationCodeForDoctorAppResponseModel get activationCodeForDoctorAppRes => _activationCodeForDoctorAppRes;
CheckActivationCodeForDoctorAppResponseModel _checkActivationCodeForDoctorAppRes = CheckActivationCodeForDoctorAppResponseModel();
CheckActivationCodeForDoctorAppResponseModel get checkActivationCodeForDoctorAppRes => _checkActivationCodeForDoctorAppRes;
Map<String, dynamic> _insertDeviceImeiRes = {};
List<DoctorProfileModel> _doctorProfilesList = [];
List<DoctorProfileModel> get doctorProfilesList => _doctorProfilesList;
Future selectDeviceImei(imei) async {
try {
await baseAppClient.post(SELECT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
_imeiDetails = [];
response['List_DoctorDeviceDetails'].forEach((v) {
_imeiDetails.add(GetIMEIDetailsModel.fromJson(v));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: {"IMEI": imei, "TokenID": "@dm!n"});
} catch (error) {
hasError = true;
super.error = error;
}
}
Future login(UserModel userInfo) async {
hasError = false;
_loginInfo = NewLoginInformationModel();
try {
await baseAppClient.post(LOGIN_URL,
onSuccess: (dynamic response, int statusCode) {
_loginInfo = NewLoginInformationModel.fromJson(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: userInfo.toJson());
} catch (error) {
hasError = true;
super.error = error;
}
}
Future sendActivationCodeVerificationScreen(ActivationCodeForVerificationScreenModel activationCodeModel) async {
hasError = false;
_activationCodeVerificationScreenRes = SendActivationCodeForDoctorAppResponseModel();
try {
await baseAppClient.post(SEND_ACTIVATION_CODE_FOR_VERIFICATION_SCREEN,
onSuccess: (dynamic response, int statusCode) {
_activationCodeVerificationScreenRes = SendActivationCodeForDoctorAppResponseModel.fromJson(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: activationCodeModel.toJson());
} catch (error) {
hasError = true;
super.error = error;
}
}
Future sendActivationCodeForDoctorApp(ActivationCodeModel activationCodeModel)async {
hasError = false;
_activationCodeForDoctorAppRes = SendActivationCodeForDoctorAppResponseModel();
try {
await baseAppClient.post(SEND_ACTIVATION_CODE_FOR_DOCTOR_APP,
onSuccess: (dynamic response, int statusCode) {
_activationCodeForDoctorAppRes = SendActivationCodeForDoctorAppResponseModel.fromJson(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: activationCodeModel.toJson());
} catch (error) {
hasError = true;
super.error = error;
}
}
Future checkActivationCodeForDoctorApp(CheckActivationCodeRequestModel checkActivationCodeRequestModel)async {
hasError = false;
_checkActivationCodeForDoctorAppRes = CheckActivationCodeForDoctorAppResponseModel();
try {
await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_DOCTOR_APP,
onSuccess: (dynamic response, int statusCode) {
_checkActivationCodeForDoctorAppRes = CheckActivationCodeForDoctorAppResponseModel.fromJson(response);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: checkActivationCodeRequestModel.toJson());
} catch (error) {
hasError = true;
super.error = error;
}
}
Future insertDeviceImei(InsertIMEIDetailsModel insertIMEIDetailsModel)async {
hasError = false;
_insertDeviceImeiRes = {};
try {
await baseAppClient.post(INSERT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
_insertDeviceImeiRes = response;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: insertIMEIDetailsModel.toJson());
} catch (error) {
hasError = true;
super.error = error;
}
}
Future getDoctorProfileBasedOnClinic(ProfileReqModel profileReqModel)async {
hasError = false;
try {
await baseAppClient.post(GET_DOC_PROFILES,
onSuccess: (dynamic response, int statusCode) {
_doctorProfilesList.clear();
response['DoctorProfileList'].forEach((v) {
_doctorProfilesList.add(DoctorProfileModel.fromJson(v));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: profileReqModel.toJson());
} catch (error) {
hasError = true;
super.error = error;
}
}
}

@ -1,62 +0,0 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/auth/imei_details.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/doctor/user_model.dart';
class AuthService extends BaseService {
List<GetIMEIDetailsModel> _imeiDetails = [];
List<GetIMEIDetailsModel> get dashboardItemsList => _imeiDetails;
Map<String, dynamic> _loginInfo = {};
Map<String, dynamic> get loginInfo => _loginInfo;
Future selectDeviceImei(imei) async {
try {
// dynamic localRes;
await baseAppClient.post(SELECT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
_imeiDetails = [];
response['List_DoctorDeviceDetails'].forEach((v) {
_imeiDetails.add(GetIMEIDetailsModel.fromJson(v));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: {"IMEI": imei, "TokenID": "@dm!n"});
//return Future.value(localRes);
} catch (error) {
hasError = true;
super.error = error;
}
}
Future login(UserModel userInfo) async {
hasError = false;
_loginInfo = {};
try {
await baseAppClient.post(LOGIN_URL,
onSuccess: (dynamic response, int statusCode) {
_loginInfo = response;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: userInfo.toJson());
} catch (error) {
hasError = true;
super.error = error;
}
// await baseAppClient.post(SELECT_DEVICE_IMEI,
// onSuccess: (dynamic response, int statusCode) {
// _imeiDetails = [];
// response['List_DoctorDeviceDetails'].forEach((v) {
// _imeiDetails.add(GetIMEIDetailsModel.fromJson(v));
// });
// }, onFailure: (String error, int statusCode) {
// hasError = true;
// super.error = error;
// }, body: {});
// } catch (error) {
// hasError = true;
// super.error = error;
// }
}
}

@ -0,0 +1,27 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_response_model.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
class HospitalsService extends BaseService {
List<GetHospitalsResponseModel> hospitals =List();
Future getHospitals(GetHospitalsRequestModel getHospitalsRequestModel) async {
hasError = false;
await baseAppClient.post(
GET_PROJECTS,
onSuccess: (dynamic response, int statusCode) {
hospitals.clear();
response['ProjectInfo'].forEach((hospital) {
hospitals.add(GetHospitalsResponseModel.fromJson(hospital));
});
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
body: getHospitalsRequestModel.toJson(),
);
}
}

@ -1,233 +0,0 @@
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/model/auth/imei_details.dart';
import 'package:doctor_app_flutter/core/model/auth/insert_imei_model.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/models/auth/activation_Code_req_model.dart';
import 'package:doctor_app_flutter/models/auth/check_activation_code_request_model.dart';
import 'package:doctor_app_flutter/models/auth/send_activation_code_model2.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import '../../models/doctor/user_model.dart';
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
class AuthViewModel extends BaseViewModel {
List<ClinicModel> doctorsClinicList = [];
String selectedClinicName;
bool isLogin = false;
bool isLoading = true;
DoctorProfileModel doctorProfile;
BaseAppClient baseAppClient = BaseAppClient();
setDoctorProfile(DoctorProfileModel profileModel) {
doctorProfile = profileModel;
notifyListeners();
}
AuthViewModel() {
getUserAuthentication();
}
getUserAuthentication() async {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
if (profile != null) {
doctorProfile = new DoctorProfileModel.fromJson(profile);
isLoading = false;
isLogin = true;
} else {
isLoading = false;
isLogin = false;
}
notifyListeners();
}
APP_STATUS get stutas {
if (isLoading) {
return APP_STATUS.LOADING;
} else {
if (this.isLogin) {
return APP_STATUS.AUTHENTICATED;
} else {
return APP_STATUS.UNAUTHENTICATED;
}
}
}
Future<dynamic> login(UserModel userInfo) async {
try {
dynamic localRes;
await baseAppClient.post(LOGIN_URL,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: userInfo.toJson());
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future insertDeviceImei(request) async {
var loggedIn = await sharedPref.getObj(LOGGED_IN_USER);
var user = await sharedPref.getObj(LAST_LOGIN_USER);
if (user != null) {
user = GetIMEIDetailsModel.fromJson(user);
}
request['IMEI'] = DEVICE_TOKEN;
request['LogInTypeID'] = await sharedPref.getInt(OTP_TYPE);
request['BioMetricEnabled'] = true;
request['MobileNo'] =
loggedIn != null ? loggedIn['MobileNumber'] : user.mobile;
InsertIMEIDetailsModel nRequest = InsertIMEIDetailsModel.fromJson(request);
nRequest.genderDescription = request['Gender_Description'];
nRequest.genderDescriptionN = request['Gender_DescriptionN'];
nRequest.genderDescriptionN = request['Gender_DescriptionN'];
nRequest.titleDescription = request['Title_Description'];
nRequest.titleDescriptionN = request['Title_DescriptionN'];
nRequest.projectID = await sharedPref.getInt(PROJECT_ID);
nRequest.doctorID = loggedIn != null
? loggedIn['List_MemberInformation'][0]['MemberID']
: user.doctorID;
nRequest.outSA = loggedIn != null ? loggedIn['PatientOutSA'] : user.outSA;
nRequest.vidaAuthTokenID = await sharedPref.getString(VIDA_AUTH_TOKEN_ID);
nRequest.vidaRefreshTokenID =
await sharedPref.getString(VIDA_REFRESH_TOKEN_ID);
nRequest.password = await sharedPref.getString(PASSWORD);
try {
var localRes;
await baseAppClient.post(INSERT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {}, body: nRequest.toJson());
return Future.value(localRes);
} catch (error) {
throw error;
}
}
Future sendActivationCodeByOtpNotificationType(activationCodeModel) async {
try {
var localRes;
await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: activationCodeModel);
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future sendActivationCodeForDoctorApp(
ActivationCodeModel activationCodeModel) async {
try {
var localRes;
await baseAppClient.post(SEND_ACTIVATION_CODE_FOR_DOCTOR_APP,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: activationCodeModel.toJson());
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future<dynamic> memberCheckActivationCodeNew(activationCodeModel) async {
try {
dynamic localRes;
await baseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
selectedClinicName =
ClinicModel.fromJson(response['List_DoctorsClinic'][0]).clinicName;
response['List_DoctorsClinic'].forEach((v) {
doctorsClinicList.add(new ClinicModel.fromJson(v));
});
}, onFailure: (String error, int statusCode) {
throw error;
}, body: activationCodeModel);
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future<dynamic> checkActivationCodeForDoctorApp(
CheckActivationCodeRequestModel checkActivationCodeRequestModel) async {
try {
dynamic localRes;
await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_DOCTOR_APP,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
selectedClinicName =
ClinicModel.fromJson(response['List_DoctorsClinic'][0]).clinicName;
response['List_DoctorsClinic'].forEach((v) {
doctorsClinicList.add(new ClinicModel.fromJson(v));
});
}, onFailure: (String error, int statusCode) {
throw error;
}, body: checkActivationCodeRequestModel.toJson());
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future<dynamic> getDocProfiles(docInfo,
{bool allowChangeProfile = true}) async {
try {
dynamic localRes;
await baseAppClient.post(GET_DOC_PROFILES,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
if (allowChangeProfile) {
doctorProfile =
DoctorProfileModel.fromJson(response['DoctorProfileList'][0]);
selectedClinicName =
response['DoctorProfileList'][0]['ClinicDescription'];
}
}, onFailure: (String error, int statusCode) {
throw error;
}, body: docInfo);
notifyListeners();
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
Future sendActivationCodeVerificationScreen(
ActivationCodeModel2 activationCodeModel) async {
try {
var localRes;
await baseAppClient.post(SEND_ACTIVATION_CODE_FOR_VERIFICATION_SCREEN,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: activationCodeModel.toJson());
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
}

@ -0,0 +1,425 @@
import 'dart:io';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/auth_method_types.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/auth/activation_Code_req_model.dart';
import 'package:doctor_app_flutter/core/model/auth/activation_code_for_verification_screen_model.dart';
import 'package:doctor_app_flutter/core/model/auth/check_activation_code_for_doctor_app_response_model.dart';
import 'package:doctor_app_flutter/core/model/auth/check_activation_code_request_model.dart';
import 'package:doctor_app_flutter/core/model/auth/imei_details.dart';
import 'package:doctor_app_flutter/core/model/auth/insert_imei_model.dart';
import 'package:doctor_app_flutter/core/model/auth/new_login_information_response_model.dart';
import 'package:doctor_app_flutter/core/model/auth/send_activation_code_for_doctor_app_response_model.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_response_model.dart';
import 'package:doctor_app_flutter/core/service/authentication_service.dart';
import 'package:doctor_app_flutter/core/service/hospitals/hospitals_service.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:doctor_app_flutter/models/doctor/user_model.dart';
import 'package:doctor_app_flutter/root_page.dart';
import 'package:doctor_app_flutter/screens/auth/login_screen.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:local_auth/auth_strings.dart';
import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED, UNVERIFIED }
class AuthenticationViewModel extends BaseViewModel {
AuthenticationService _authService = locator<AuthenticationService>();
HospitalsService _hospitalsService = locator<HospitalsService>();
List<GetIMEIDetailsModel> get imeiDetails => _authService.dashboardItemsList;
List<GetHospitalsResponseModel> get hospitals => _hospitalsService.hospitals;
NewLoginInformationModel get loginInfo => _authService.loginInfo;
List<DoctorProfileModel> get doctorProfilesList => _authService.doctorProfilesList;
SendActivationCodeForDoctorAppResponseModel
get activationCodeVerificationScreenRes =>
_authService.activationCodeVerificationScreenRes;
SendActivationCodeForDoctorAppResponseModel
get activationCodeForDoctorAppRes =>
_authService.activationCodeForDoctorAppRes;
CheckActivationCodeForDoctorAppResponseModel
get checkActivationCodeForDoctorAppRes =>
_authService.checkActivationCodeForDoctorAppRes;
NewLoginInformationModel loggedUser;
GetIMEIDetailsModel user;
UserModel userInfo = UserModel();
final LocalAuthentication auth = LocalAuthentication();
List<BiometricType> _availableBiometrics;
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
bool isLogin = false;
bool unverified = false;
AuthenticationViewModel({bool checkDeviceInfo = false}) {
getDeviceInfoFromFirebase();
getDoctorProfile();
}
/// select Device IMEI
Future selectDeviceImei(imei) async {
setState(ViewState.Busy);
await _authService.selectDeviceImei(imei);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
/// Insert Device IMEI
Future insertDeviceImei() async {
var loggedIn = await sharedPref.getObj(LOGGED_IN_USER);
var user = await sharedPref.getObj(LAST_LOGIN_USER);
if (user != null) {
user = GetIMEIDetailsModel.fromJson(user);
}
var profileInfo = await sharedPref.getObj(DOCTOR_PROFILE);
profileInfo['IMEI'] = DEVICE_TOKEN;
profileInfo['LogInTypeID'] = await sharedPref.getInt(OTP_TYPE);
profileInfo['BioMetricEnabled'] = true;
profileInfo['MobileNo'] =
loggedIn != null ? loggedIn['MobileNumber'] : user.mobile;
InsertIMEIDetailsModel insertIMEIDetailsModel = InsertIMEIDetailsModel.fromJson(profileInfo);
insertIMEIDetailsModel.genderDescription = profileInfo['Gender_Description'];
insertIMEIDetailsModel.genderDescriptionN = profileInfo['Gender_DescriptionN'];
insertIMEIDetailsModel.genderDescriptionN = profileInfo['Gender_DescriptionN'];
insertIMEIDetailsModel.titleDescription = profileInfo['Title_Description'];
insertIMEIDetailsModel.titleDescriptionN = profileInfo['Title_DescriptionN'];
insertIMEIDetailsModel.projectID = await sharedPref.getInt(PROJECT_ID);
insertIMEIDetailsModel.doctorID = loggedIn != null
? loggedIn['List_MemberInformation'][0]['MemberID']
: user.doctorID;
insertIMEIDetailsModel.outSA = loggedIn != null ? loggedIn['PatientOutSA'] : user.outSA;
insertIMEIDetailsModel.vidaAuthTokenID = await sharedPref.getString(VIDA_AUTH_TOKEN_ID);
insertIMEIDetailsModel.vidaRefreshTokenID =
await sharedPref.getString(VIDA_REFRESH_TOKEN_ID);
insertIMEIDetailsModel.password = await sharedPref.getString(PASSWORD);
await _authService.insertDeviceImei(insertIMEIDetailsModel);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
/// first step login
Future login(UserModel userInfo) async {
setState(ViewState.BusyLocal);
await _authService.login(userInfo);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.ErrorLocal);
} else {
sharedPref.setInt(PROJECT_ID, userInfo.projectID);
loggedUser = loginInfo;
saveObjToString(LOGGED_IN_USER, loginInfo);
sharedPref.remove(LAST_LOGIN_USER);
sharedPref.setString(TOKEN, loginInfo.logInTokenID);
setState(ViewState.Idle);
}
}
/// send activation code for for msg methods
Future sendActivationCodeVerificationScreen( AuthMethodTypes authMethodType) async {
setState(ViewState.BusyLocal);
ActivationCodeForVerificationScreenModel activationCodeModel =
ActivationCodeForVerificationScreenModel(
iMEI: user.iMEI,
facilityId: user.projectID,
memberID: user.doctorID,
zipCode: user.outSA == true ? '971' : '966',
mobileNumber: user.mobile,
oTPSendType: authMethodType.getTypeIdService(),
isMobileFingerPrint: 1,
vidaAuthTokenID: user.vidaAuthTokenID,
vidaRefreshTokenID: user.vidaRefreshTokenID);
await _authService.sendActivationCodeVerificationScreen(activationCodeModel);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
/// send activation code for silent login
Future sendActivationCodeForDoctorApp({AuthMethodTypes authMethodType, String password }) async {
setState(ViewState.BusyLocal);
int projectID = await sharedPref.getInt(PROJECT_ID);
ActivationCodeModel activationCodeModel = ActivationCodeModel(
facilityId: projectID,
memberID: loggedUser.listMemberInformation[0].memberID,
zipCode: loggedUser.zipCode,
mobileNumber: loggedUser.mobileNumber,
otpSendType: authMethodType.getTypeIdService().toString(),
password: password);
await _authService.sendActivationCodeForDoctorApp(activationCodeModel);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
/// check activation code for sms and whats app
Future checkActivationCodeForDoctorApp({String activationCode}) async {
setState(ViewState.BusyLocal);
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp =
new CheckActivationCodeRequestModel(
zipCode:
loggedUser != null ? loggedUser.zipCode :user.zipCode,
mobileNumber:
loggedUser != null ? loggedUser.mobileNumber : user.mobile,
projectID: await sharedPref.getInt(PROJECT_ID) != null
? await sharedPref.getInt(PROJECT_ID)
: user.projectID,
logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID),
activationCode: activationCode ?? '0000',
oTPSendType: await sharedPref.getInt(OTP_TYPE),
generalid: "Cs2020@2016\$2958");
await _authService.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Idle);
}
}
/// get list of Hospitals
Future getHospitalsList(memberID) async {
GetHospitalsRequestModel getHospitalsRequestModel =GetHospitalsRequestModel();
getHospitalsRequestModel.memberID = memberID;
await _hospitalsService.getHospitals(getHospitalsRequestModel);
if (_hospitalsService.hasError) {
error = _hospitalsService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
/// get type name based on id.
getType(type, context) {
switch (type) {
case 1:
return TranslationBase
.of(context)
.verifySMS;
break;
case 3:
return TranslationBase
.of(context)
.verifyFingerprint;
break;
case 4:
return TranslationBase
.of(context)
.verifyFaceID;
break;
case 2:
return TranslationBase.of(context).verifyWhatsApp;
break;
default:
return TranslationBase.of(context).verifySMS;
break;
}
}
/// add  token to shared preferences in case of send activation code is success
setDataAfterSendActivationSuccess(SendActivationCodeForDoctorAppResponseModel sendActivationCodeForDoctorAppResponseModel) {
print("VerificationCode : " +
sendActivationCodeForDoctorAppResponseModel.verificationCode);
sharedPref.setString(VIDA_AUTH_TOKEN_ID,
sendActivationCodeForDoctorAppResponseModel.vidaAuthTokenID);
sharedPref.setString(VIDA_REFRESH_TOKEN_ID,
sendActivationCodeForDoctorAppResponseModel.vidaRefreshTokenID);
sharedPref.setString(LOGIN_TOKEN_ID,
sendActivationCodeForDoctorAppResponseModel.logInTokenID);
}
saveObjToString(String key, value) async {
sharedPref.setObj(key, value);
}
/// ask user to add his biometric
showIOSAuthMessages() async {
const iosStrings = const IOSAuthMessages(
cancelButton: 'cancel',
goToSettingsButton: 'settings',
goToSettingsDescription: 'Please set up your Touch ID.',
lockOut: 'Please Enable Your Touch ID');
try {
await auth.authenticateWithBiometrics(
localizedReason: 'Scan your fingerprint to authenticate',
useErrorDialogs: true,
stickyAuth: true,
iOSAuthStrings: iosStrings);
} on PlatformException catch (e) {
DrAppToastMsg.showErrorToast(e.toString());
}
}
/// add profile to base view model super class
localSetDoctorProfile(DoctorProfileModel profile) {
super.setDoctorProfile(profile);
}
/// get doctor profile based on clinic model
Future getDoctorProfileBasedOnClinic(ClinicModel clinicInfo) async {
ProfileReqModel docInfo = new ProfileReqModel(
doctorID: clinicInfo.doctorID,
clinicID: clinicInfo.clinicID,
license: true,
projectID: clinicInfo.projectID,
tokenID: '',
languageID: 2);
await _authService.getDoctorProfileBasedOnClinic(docInfo);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.ErrorLocal);
} else {
localSetDoctorProfile(doctorProfilesList.first);
setState(ViewState.Idle);
}
}
/// add some logic in case of check activation code is success
onCheckActivationCodeSuccess() async {
sharedPref.setString(
TOKEN,
checkActivationCodeForDoctorAppRes.authenticationTokenID);
if (checkActivationCodeForDoctorAppRes.listDoctorProfile != null &&
checkActivationCodeForDoctorAppRes.listDoctorProfile
.isNotEmpty) {
localSetDoctorProfile(
checkActivationCodeForDoctorAppRes.listDoctorProfile[0]);
} else {
sharedPref.setObj(
CLINIC_NAME,
checkActivationCodeForDoctorAppRes.listDoctorsClinic);
ClinicModel clinic = ClinicModel.fromJson(
checkActivationCodeForDoctorAppRes.listDoctorsClinic[0]
.toJson());
await getDoctorProfileBasedOnClinic(clinic);
}
}
/// check specific biometric if it available or not
Future <bool> checkIfBiometricAvailable(BiometricType biometricType) async {
bool isAvailable = false;
await _getAvailableBiometrics();
if (_availableBiometrics != null) {
for (var i = 0; i < _availableBiometrics.length; i++) {
if (biometricType == _availableBiometrics[i]) isAvailable = true;
}
}
return isAvailable;
}
/// get all available biometric on the device for local Auth service
Future<void> _getAvailableBiometrics() async {
try {
_availableBiometrics = await auth.getAvailableBiometrics();
} on PlatformException catch (e) {
print(e);
}
}
/// call firebase service to check if the user already login in before or not
getDeviceInfoFromFirebase() async {
_firebaseMessaging.setAutoInitEnabled(true);
if (Platform.isIOS) {
_firebaseMessaging.requestNotificationPermissions();
}
setState(ViewState.Busy);
var token = await _firebaseMessaging.getToken();
if (DEVICE_TOKEN == "") {
DEVICE_TOKEN = token;
await _authService.selectDeviceImei(DEVICE_TOKEN);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.ErrorLocal);
} else {
if (_authService.dashboardItemsList.length > 0) {
user =_authService.dashboardItemsList[0];
sharedPref.setObj(
LAST_LOGIN_USER, _authService.dashboardItemsList[0]);
this.unverified = true;
}
setState(ViewState.Idle);
}
} else {
setState(ViewState.Idle);
}
}
/// determine the status of the app
APP_STATUS get status {
if (state == ViewState.Busy) {
return APP_STATUS.LOADING;
} else {
if (this.unverified) {
return APP_STATUS.UNVERIFIED;
} else if (this.isLogin) {
return APP_STATUS.AUTHENTICATED;
} else {
return APP_STATUS.UNAUTHENTICATED;
}
}
}
/// logout function
logout({bool isSessionTimeout = false}) async {
DEVICE_TOKEN = "";
String lang = await sharedPref.getString(APP_Language);
await Helpers.clearSharedPref();
sharedPref.setString(APP_Language, lang);
deleteUser();
if(isSessionTimeout)
await getDeviceInfoFromFirebase();
Navigator.pushAndRemoveUntil(
AppGlobal.CONTEX,
FadePage(
page: RootPage(),
),
(r) => false);
}
deleteUser(){
user = null;
unverified = false;
isLogin = false;
notifyListeners();
}
}

@ -45,5 +45,10 @@ class BaseViewModel extends ChangeNotifier {
} else {
return doctorProfile;
}
}
}
setDoctorProfile(DoctorProfileModel doctorProfile){
sharedPref.setObj(DOCTOR_PROFILE, doctorProfile);
doctorProfile = doctorProfile;
}
}

@ -1,12 +1,14 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart';import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/service/home/dasboard_service.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import '../../locator.dart';
import 'authentication_view_model.dart';
import 'base_view_model.dart';
class DashboardViewModel extends BaseViewModel {
@ -17,7 +19,7 @@ class DashboardViewModel extends BaseViewModel {
List<DashboardModel> get dashboardItemsList =>
_dashboardService.dashboardItemsList;
Future setFirebaseNotification(ProjectViewModel projectsProvider, AuthViewModel authProvider) async{
Future setFirebaseNotification(ProjectViewModel projectsProvider, AuthenticationViewModel authProvider) async{
setState(ViewState.Busy);
await projectsProvider.getDoctorClinicsList();
@ -33,9 +35,7 @@ class DashboardViewModel extends BaseViewModel {
_firebaseMessaging.getToken().then((String token) async {
if (token != '') {
DEVICE_TOKEN = token;
var request = await sharedPref.getObj(DOCTOR_PROFILE);
authProvider.insertDeviceImei(request).then((value) {
});
authProvider.insertDeviceImei();
}
});
}
@ -50,7 +50,7 @@ class DashboardViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future changeClinic(int clinicId, AuthViewModel authProvider) async {
Future changeClinic(int clinicId, AuthenticationViewModel authProvider) async {
setState(ViewState.BusyLocal);
await getDoctorProfile();
ProfileReqModel docInfo = new ProfileReqModel(
@ -60,14 +60,11 @@ class DashboardViewModel extends BaseViewModel {
projectID: doctorProfile.projectID,
tokenID: '',
languageID: 2);
await authProvider.getDocProfiles(docInfo.toJson()).then((res) async {
sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]);
setState(ViewState.Idle);
}).catchError((err) {
error = err;
setState(ViewState.ErrorLocal);
});
ClinicModel clinicModel = ClinicModel(doctorID:doctorProfile.doctorID,clinicID: doctorProfile.clinicID, projectID: doctorProfile.projectID,);
await authProvider.getDoctorProfileBasedOnClinic(clinicModel);
if(authProvider.state == ViewState.ErrorLocal) {
error = authProvider.error;
}
}
getPatientCount(DashboardModel inPatientCount) {

@ -1,32 +0,0 @@
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:flutter/cupertino.dart';
// TODO change it when change login
class HospitalViewModel with ChangeNotifier {
BaseAppClient baseAppClient = BaseAppClient();
Future<Map> getProjectsList(memberID) async {
const url = GET_PROJECTS;
// TODO create model or remove it if no info need
var info = {
"LanguageID": 1,
"stamp": "2020-02-26T13:51:44.111Z",
"IPAdress": "11.11.11.11",
"VersionID": 5.8,
"Channel": 9,
"TokenID": "",
"SessionID": "i1UJwCTSqt",
"IsLoginForDoctorApp": true,
"MemberID": memberID
};
dynamic localRes;
await baseAppClient.post(url, onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: info);
return Future.value(localRes);
}
}

@ -0,0 +1,27 @@
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart';
import 'package:doctor_app_flutter/core/service/hospitals/hospitals_service.dart';
import 'package:flutter/cupertino.dart';
import '../../locator.dart';
import 'base_view_model.dart';
class HospitalViewModel extends BaseViewModel {
HospitalsService _hospitalsService = locator<HospitalsService>();
// List<GetIMEIDetailsModel> get imeiDetails => _authService.dashboardItemsList;
// get loginInfo => _authService.loginInfo;
Future getHospitalsList(memberID) async {
GetHospitalsRequestModel getHospitalsRequestModel =GetHospitalsRequestModel();
getHospitalsRequestModel.memberID = memberID;
setState(ViewState.Busy);
await _hospitalsService.getHospitals(getHospitalsRequestModel);
if (_hospitalsService.hasError) {
error = _hospitalsService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
}

@ -1,33 +0,0 @@
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/auth/imei_details.dart';
import 'package:doctor_app_flutter/core/service/home/auth_service.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';
import 'package:doctor_app_flutter/models/doctor/user_model.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
class IMEIViewModel extends BaseViewModel {
AuthService _authService = locator<AuthService>();
List<GetIMEIDetailsModel> get imeiDetails => _authService.dashboardItemsList;
get loginInfo => _authService.loginInfo;
Future selectDeviceImei(imei) async {
setState(ViewState.Busy);
await _authService.selectDeviceImei(imei);
if (_authService.hasError) {
error = _authService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
Future login(UserModel userInfo) async {
setState(ViewState.Busy);
await _authService.login(userInfo);
if (_authService.hasError) {
error = _authService.error;
Helpers.showErrorToast(error);
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
}

@ -4,15 +4,15 @@ import 'package:connectivity/connectivity.dart';
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'authentication_view_model.dart';
Helpers helpers = Helpers();
class ProjectViewModel with ChangeNotifier {
@ -24,7 +24,6 @@ class ProjectViewModel with ChangeNotifier {
List<ClinicModel> doctorClinicsList = [];
bool isLoading = false;
bool isError = false;
bool isLogin = false;
String error = '';
BaseAppClient baseAppClient = BaseAppClient();
@ -116,19 +115,9 @@ class ProjectViewModel with ChangeNotifier {
void getProfile() async {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile);
ProfileReqModel docInfo = new ProfileReqModel(
doctorID: doctorProfile.doctorID,
clinicID: doctorProfile.clinicID,
license: true,
projectID: doctorProfile.projectID,
);
Provider.of<AuthViewModel>(AppGlobal.CONTEX, listen: false)
.getDocProfiles(docInfo.toJson())
.then((res) async {
sharedPref.setObj(DOCTOR_PROFILE, res['DoctorProfileList'][0]);
}).catchError((err) {
print(err);
});
ClinicModel clinicModel = ClinicModel(doctorID:doctorProfile.doctorID,clinicID: doctorProfile.clinicID, projectID: doctorProfile.projectID,);
await Provider.of<AuthenticationViewModel>(AppGlobal.CONTEX, listen: false)
.getDoctorProfileBasedOnClinic(clinicModel);
}
}

@ -1,5 +1,6 @@
import 'package:doctor_app_flutter/core/service/authentication_service.dart';
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/imei_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/hospitals_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/medical_file_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart';
@ -7,7 +8,6 @@ import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart';
import 'package:get_it/get_it.dart';
import 'core/service/home/auth_service.dart';
import 'core/service/home/dasboard_service.dart';
import 'core/service/patient/DischargedPatientService.dart';
import 'core/service/patient/patient_service.dart';
@ -22,6 +22,7 @@ import 'core/service/patient_medical_file/procedure/procedure_service.dart';
import 'core/service/patient_medical_file/sick_leave/sickleave_service.dart';
import 'core/service/patient_medical_file/soap/SOAP_service.dart';
import 'core/service/home/doctor_reply_service.dart';
import 'core/service/hospitals/hospitals_service.dart';
import 'core/service/patient_medical_file/lab_order/labs_service.dart';
import 'core/service/patient_medical_file/prescription/medicine_service.dart';
import 'core/service/patient_medical_file/admission_request/patient-admission-request-service.dart';
@ -75,7 +76,7 @@ void setupLocator() {
locator.registerLazySingleton(() => MedicalFileService());
locator.registerLazySingleton(() => AdmissionRequestService());
locator.registerLazySingleton(() => UcafService());
locator.registerLazySingleton(() => AuthService());
locator.registerLazySingleton(() => AuthenticationService());
locator.registerLazySingleton(() => PatientMuseService());
locator.registerLazySingleton(() => LabsService());
locator.registerLazySingleton(() => InsuranceCardService());
@ -86,11 +87,11 @@ void setupLocator() {
locator.registerLazySingleton(() => DischargedPatientService());
locator.registerLazySingleton(() => PatientInPatientService());
locator.registerLazySingleton(() => OutPatientService());
locator.registerLazySingleton(() => HospitalsService());
locator.registerLazySingleton(() => PatientMedicalReportService());
/// View Model
locator.registerFactory(() => DoctorReplayViewModel());
locator.registerFactory(() => IMEIViewModel());
locator.registerFactory(() => ScheduleViewModel());
locator.registerFactory(() => ReferralPatientViewModel());
locator.registerFactory(() => ReferredPatientViewModel());
@ -113,5 +114,6 @@ void setupLocator() {
locator.registerFactory(() => PrescriptionsViewModel());
locator.registerFactory(() => DischargedPatientViewModel());
locator.registerFactory(() => PatientSearchViewModel());
locator.registerFactory(() => HospitalViewModel());
locator.registerFactory(() => PatientMedicalReportViewModel());
}

@ -11,8 +11,7 @@ import 'package:provider/provider.dart';
import './config/size_config.dart';
import './routes.dart';
import 'config/config.dart';
import 'core/viewModel/auth_view_model.dart';
import 'core/viewModel/hospital_view_model.dart';
import 'core/viewModel/authentication_view_model.dart';
import 'locator.dart';
void main() async {
@ -23,7 +22,6 @@ void main() async {
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
AppGlobal.CONTEX = context;
@ -33,10 +31,8 @@ class MyApp extends StatelessWidget {
SizeConfig().init(constraints, orientation);
return MultiProvider(
providers: [
ChangeNotifierProvider<AuthViewModel>(
create: (context) => AuthViewModel()),
ChangeNotifierProvider<HospitalViewModel>(
create: (context) => HospitalViewModel()),
ChangeNotifierProvider<AuthenticationViewModel>(
create: (context) => AuthenticationViewModel()),
ChangeNotifierProvider<ProjectViewModel>(
create: (context) => ProjectViewModel(),
),

@ -1,27 +1,31 @@
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';
import 'package:doctor_app_flutter/screens/auth/login_screen.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'core/viewModel/authentication_view_model.dart';
import 'landing_page.dart';
class RootPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
AuthViewModel authProvider = Provider.of(context);
AuthenticationViewModel authenticationViewModel = Provider.of(context);
Widget buildRoot() {
switch (authProvider.stutas) {
switch (authenticationViewModel.status) {
case APP_STATUS.LOADING:
return Scaffold(
body: Center(
child: DrAppCircularProgressIndeicator(),
),
body: AppLoaderWidget(),
);
break;
case APP_STATUS.UNVERIFIED:
return VerificationMethodsScreen(password: null,);
break;
case APP_STATUS.UNAUTHENTICATED:
return Loginsreen();
return LoginScreen();
break;
case APP_STATUS.AUTHENTICATED:
return LandingPage();

@ -17,9 +17,9 @@ import 'package:doctor_app_flutter/screens/prescription/prescriptions_page.dart'
import 'package:doctor_app_flutter/screens/procedures/procedure_screen.dart';
import 'package:doctor_app_flutter/screens/sick-leave/add-sickleave.dart';
import 'package:doctor_app_flutter/screens/sick-leave/show-sickleave.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import './screens/auth/login_screen.dart';
import './screens/auth/verification_methods_screen.dart';
import 'screens/patients/profile/profile_screen/patient_profile_screen.dart';
import './screens/patients/profile/vital_sign/vital_sign_details_screen.dart';
import 'landing_page.dart';
@ -70,7 +70,7 @@ const String RADIOLOGY_PATIENT = 'radiology-patient';
var routes = {
ROOT: (_) => RootPage(),
HOME: (_) => LandingPage(),
LOGIN: (_) => Loginsreen(),
LOGIN: (_) => LoginScreen(),
VERIFICATION_METHODS: (_) => VerificationMethodsScreen(),
PATIENTS_PROFILE: (_) => PatientProfileScreen(),
LAB_RESULT: (_) => LabsHomePage(),

@ -1,29 +0,0 @@
import 'package:doctor_app_flutter/lookups/auth_lookup.dart';
import 'package:doctor_app_flutter/widgets/auth/auth_header.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import '../../widgets/auth/change_password.dart';
class ChangePasswordScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AppScaffold(
isShowAppBar: false,
body: SafeArea(
child: ListView(children: <Widget>[
Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(loginType.changePassword),
ChangePassword(),
],
),
),
]),
));
}
}

@ -1,132 +1,298 @@
import 'dart:async';
import 'dart:io';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/service/home/auth_service.dart';
import 'package:doctor_app_flutter/core/viewModel/imei_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_response_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../lookups/auth_lookup.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../widgets/auth/auth_header.dart';
import '../../widgets/auth/login_form.dart';
import '../../widgets/shared/app_scaffold_widget.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
class Loginsreen extends StatefulWidget {
class LoginScreen extends StatefulWidget {
@override
_LoginsreenState createState() => _LoginsreenState();
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginsreenState extends State<Loginsreen> {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
class _LoginScreenState extends State<LoginScreen> {
String platformImei;
// Future<String> platformImeiFuture;
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
bool _isLoading = true;
ProjectViewModel projectViewModel;
AuthService authService = AuthService();
bool allowCallApi = true;
//TODO change AppTextFormField to AppTextFormFieldCustom
final loginFormKey = GlobalKey<FormState>();
var projectIdController = TextEditingController();
var userIdController = TextEditingController();
var passwordController = TextEditingController();
List<GetHospitalsResponseModel> projectsList = [];
FocusNode focusPass = FocusNode();
FocusNode focusProject = FocusNode();
AuthenticationViewModel authenticationViewModel;
@override
void initState() {
super.initState();
Widget build(BuildContext context) {
authenticationViewModel = Provider.of<AuthenticationViewModel>(context);
return AppScaffold(
isShowAppBar: false,
backgroundColor: HexColor('#F8F8F8'),
body: SafeArea(
child: ListView(children: <Widget>[
Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 30),
alignment: Alignment.topLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//TODO Use App Text rather than text
Container(
_firebaseMessaging.setAutoInitEnabled(true);
if (Platform.isIOS) {
_firebaseMessaging.requestNotificationPermissions();
}
child: Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment
.start,
children: <Widget>[
SizedBox(
height: 30,
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment
.start, children: [
SizedBox(
height: 10,
),
Text(
TranslationBase
.of(context)
.welcomeTo,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight
.w600,
fontFamily: 'Poppins'),
),
Text(
TranslationBase
.of(context)
.drSulaimanAlHabib,
style: TextStyle(
color:Color(0xFF2B353E),
fontWeight: FontWeight
.bold,
fontSize: SizeConfig
.isMobile
? 24
: SizeConfig
.realScreenWidth *
0.029,
fontFamily: 'Poppins'),
),
Text(
"Doctor App",
style: TextStyle(
fontSize:
SizeConfig.isMobile
? 16
: SizeConfig
.realScreenWidth *
0.030,
fontWeight: FontWeight
.w600,
color: Color(0xFFD02127)),
),
]),
],
)),
SizedBox(
height: 40,
),
Form(
key: loginFormKey,
child: Column(
mainAxisAlignment: MainAxisAlignment
.spaceBetween,
children: <Widget>[
Container(
width: SizeConfig
.realScreenWidth * 0.90,
height: SizeConfig
.realScreenHeight * 0.65,
child:
Column(
crossAxisAlignment: CrossAxisAlignment
.start, children: [
buildSizedBox(),
AppTextFieldCustom(
hintText: TranslationBase.of(context).enterId,
hasBorder: true,
controller: userIdController,
onChanged: (value){
if (value != null)
setState(() {
authenticationViewModel.userInfo
.userID =
value
.trim();
});
},
),
buildSizedBox(),
AppTextFieldCustom(
hintText: TranslationBase.of(context).enterPassword,
hasBorder: true,
isSecure: true,
controller: passwordController,
onChanged: (value){
if (value != null)
setState(() {
authenticationViewModel.userInfo
.password =
value
.trim();
});
if(allowCallApi) {
this.getProjects(
authenticationViewModel.userInfo
.userID);
setState(() {
allowCallApi = false;
});
}
},
onClick: (){
},
),
buildSizedBox(),
AppTextFieldCustom(
hintText: TranslationBase.of(context).selectYourProject,
hasBorder: true,
controller: projectIdController,
isTextFieldHasSuffix: true,
enabled: false,
onClick: (){
Helpers
.showCupertinoPicker(
context,
projectsList,
'facilityName',
onSelectProject,
authenticationViewModel);
},
),
buildSizedBox()
]),
),
],
),
)
],
)
]))
]),
),
bottomSheet: Container(
height: 90,
width: double.infinity,
child: Center(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
AppButton(
title: TranslationBase
.of(context)
.login,
color: Color(0xFFD02127),
fontWeight: FontWeight.w700,
disabled: authenticationViewModel.userInfo
.userID == null ||
authenticationViewModel.userInfo
.password ==
null,
onPressed: () {
login(context);
},
),
SizedBox(height: 25,)
],
),
),
),),
);
}
SizedBox buildSizedBox() {
return SizedBox(
height: 20,
);
}
_firebaseMessaging.getToken().then((String token) async {
if (DEVICE_TOKEN == "" && projectViewModel.isLogin == false) {
DEVICE_TOKEN = token;
changeLoadingStata(true);
authService.selectDeviceImei(DEVICE_TOKEN).then((value) {
print(authService.dashboardItemsList);
if (authService.dashboardItemsList.length > 0) {
sharedPref.setObj(
LAST_LOGIN_USER, authService.dashboardItemsList[0]);
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (BuildContext context) => VerificationMethodsScreen(
password: null,
)));
} else {
changeLoadingStata(false);
}
//changeLoadingStata(false);
});
login(context,) async {
if (loginFormKey.currentState.validate()) {
loginFormKey.currentState.save();
GifLoaderDialogUtils.showMyDialog(context);
await authenticationViewModel.login(authenticationViewModel.userInfo);
if (authenticationViewModel.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context);
Helpers.showErrorToast(authenticationViewModel.error);
} else {
changeLoadingStata(false);
}
GifLoaderDialogUtils.hideDialog(context);
// else if (projectViewModel.isLogin) {
// getNotificationCount(token);
// }
}).catchError((err) {
print(err);
});
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (BuildContext context) =>
VerificationMethodsScreen(
password: authenticationViewModel.userInfo.password,
),
),
);
}
}
}
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param: isLoading
*@return:
*@desc: Change Isloading attribute in order to show or hide loader
*/
void changeLoadingStata(isLoading) {
onSelectProject(index) {
setState(() {
_isLoading = isLoading;
authenticationViewModel.userInfo.projectID = projectsList[index].facilityId;
projectIdController.text = projectsList[index].facilityName;
});
primaryFocus.unfocus();
}
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of<ProjectViewModel>(context);
return BaseView<IMEIViewModel>(
onModelReady: (model) => {},
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: false,
backgroundColor: HexColor('#F8F8F8'),
body: SafeArea(
child: (_isLoading == false)
? ListView(children: <Widget>[
Container(
margin:
EdgeInsetsDirectional.fromSTEB(30, 0, 30, 30),
alignment: Alignment.topLeft,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(loginType.knownUser),
SizedBox(
height: 40,
),
LoginForm(
model: model,
),
],
)
]))
])
: Center(child: AppLoaderWidget()),
),
));
getProjects(memberID)async {
if (memberID != null && memberID != '') {
if (projectsList.length == 0) {
await authenticationViewModel.getHospitalsList(memberID);
if(authenticationViewModel.state == ViewState.Idle) {
projectsList = authenticationViewModel.hospitals;
setState(() {
authenticationViewModel.userInfo.projectID = projectsList[0].facilityId;
projectIdController.text = projectsList[0].facilityName;
});
}
}
}
}
}

@ -1,66 +1,567 @@
import 'dart:io' show Platform;
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/auth_method_types.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/auth/sms-popup.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import '../../widgets/auth/verification_methods.dart';
import '../../config/size_config.dart';
import '../../landing_page.dart';
import '../../root_page.dart';
import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../util/helpers.dart';
import '../../widgets/auth/verification_methods_list.dart';
import 'login_screen.dart';
/*
*@author: Elham Rababah
*@Date:4/7/2020
*@param:
*@return:
*@desc: Verification Methods screen
*/
class VerificationMethodsScreen extends StatefulWidget {
const VerificationMethodsScreen({Key key, this.password}) : super(key: key);
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers();
@override
_VerificationMethodsScreenState createState() =>
_VerificationMethodsScreenState();
class VerificationMethodsScreen extends StatefulWidget {
VerificationMethodsScreen({this.password});
final password;
@override
_VerificationMethodsScreenState createState() => _VerificationMethodsScreenState();
}
class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
bool _isLoading = false;
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param: isLoading
*@return:
*@desc: Change Isloading attribute in order to show or hide loader
*/
void changeLoadingStata(isLoading) {
setState(() {
_isLoading = isLoading;
});
}
ProjectViewModel projectsProvider;
bool isMoreOption = false;
bool onlySMSBox = false;
AuthMethodTypes fingerPrintBefore;
AuthMethodTypes selectedOption;
AuthenticationViewModel authenticationViewModel;
@override
Widget build(BuildContext context) {
projectsProvider = Provider.of<ProjectViewModel>(context);
authenticationViewModel = Provider.of<AuthenticationViewModel>(context);
return AppScaffold(
isLoading: _isLoading,
isShowAppBar: false,
isHomeIcon: false,
backgroundColor: HexColor('#F8F8F8'),
body: ListView(children: <Widget>[
Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
isShowAppBar: false,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
// baseViewModel: model,
body: SingleChildScrollView(
child: Center(
child: FractionallySizedBox(
child: Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
height: SizeConfig.realScreenHeight * .95,
width: SizeConfig.realScreenWidth,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SizedBox(
height: 80,
),
InkWell(
onTap: (){
Navigator.of(context).pop();
},
child: Icon(Icons.arrow_back_ios,color: Color(0xFF2B353E),)
),
Container(
child: Column(
children: <Widget>[
SizedBox(
height: 20,
),
authenticationViewModel.user != null && isMoreOption == false
? Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AppText(
TranslationBase.of(context).welcomeBack,
fontSize:12,
fontWeight: FontWeight.w700,
color: Color(0xFF2B353E),
),
AppText(
Helpers.capitalize(authenticationViewModel.user.doctorName),
fontSize: 24,
color: Color(0xFF2B353E),
fontWeight: FontWeight.bold,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).accountInfo ,
fontSize: 16,
color: Color(0xFF2E303A),
fontWeight: FontWeight.w600,
),
SizedBox(
height: 20,
),
Container(
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(10),
),
border: Border.all(
color: HexColor('#707070'),
width: 0.1),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
children: [
Text(
TranslationBase.of(context)
.lastLoginAt,
overflow:
TextOverflow.ellipsis,
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 16,
color: Color(0xFF2E303A),
fontWeight: FontWeight.w700,),
),
Row(
children: [
AppText(
TranslationBase
.of(context)
.verifyWith,
fontSize: 14,
color: Color(0xFF575757),
fontWeight: FontWeight.w600,
),
AppText(
authenticationViewModel.getType(
authenticationViewModel.user
.logInTypeID,
context),
fontSize: 14,
color: Color(0xFF2B353E),
fontWeight: FontWeight.w700,
),
],
)
],
crossAxisAlignment: CrossAxisAlignment.start,),
Column(children: [
AppText(
authenticationViewModel.user.editedOn !=
null
? AppDateUtils.getDayMonthYearDateFormatted(
AppDateUtils.convertStringToDate(
authenticationViewModel.user
.editedOn))
: authenticationViewModel.user.createdOn !=
null
? AppDateUtils.getDayMonthYearDateFormatted(
AppDateUtils.convertStringToDate(authenticationViewModel.user
.createdOn))
: '--',
textAlign:
TextAlign.right,
fontSize: 13,
color: Color(0xFF2E303A),
fontWeight: FontWeight.w700,
),
AppText(
authenticationViewModel.user.editedOn !=
null
? AppDateUtils.getHour(
AppDateUtils.convertStringToDate(
authenticationViewModel.user
.editedOn))
: authenticationViewModel.user.createdOn !=
null
? AppDateUtils.getHour(
AppDateUtils.convertStringToDate(authenticationViewModel.user
.createdOn))
: '--',
textAlign:
TextAlign.right,
fontSize: 14,
fontWeight: FontWeight.w600,
color: Color(0xFF575757),
)
],
crossAxisAlignment: CrossAxisAlignment.start,
)
],
),
),
SizedBox(
height: 20,
),
Row(
children: [
AppText(
"Please Verify",
fontSize: 16,
color: Color(0xFF2B353E),
fontWeight: FontWeight.w700,
),
],
)
],
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
this.onlySMSBox == false
? Container(
margin: EdgeInsets.only(bottom: 20, top: 30),
child: AppText(
TranslationBase.of(context)
.verifyLoginWith,
fontSize: 18,
color: Color(0xFF2E303A),
fontWeight: FontWeight.bold,
textAlign: TextAlign.left,
),
)
: AppText(
TranslationBase.of(context)
.verifyFingerprint2,
fontSize:
SizeConfig.textMultiplier * 2.5,
textAlign: TextAlign.start,
),
]),
authenticationViewModel.user != null && isMoreOption == false
? Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: InkWell(
onTap: () =>
{
// TODO check this logic it seem it will create bug to us
authenticateUser(
AuthMethodTypes
.Fingerprint, true)
},
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType: SelectedAuthMethodTypesService
.getMethodsTypeService(
authenticationViewModel.user
.logInTypeID),
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
)),
),
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType:
AuthMethodTypes.MoreOptions,
onShowMore: () {
setState(() {
isMoreOption = true;
});
},
))
]),
])
: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
onlySMSBox == false
? Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType:
AuthMethodTypes.Fingerprint,
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
)),
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType:
AuthMethodTypes.FaceID,
authenticateUser:
(AuthMethodTypes
authMethodType,
isActive) =>
authenticateUser(
authMethodType,
isActive),
))
],
)
: SizedBox(),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType: AuthMethodTypes
.SMS,
authenticateUser:
(
AuthMethodTypes authMethodType,
isActive) =>
authenticateUser(
authMethodType, isActive),
)),
Expanded(
child: VerificationMethodsList(
authenticationViewModel:authenticationViewModel,
authMethodType:
AuthMethodTypes.WhatsApp,
authenticateUser:
(
AuthMethodTypes authMethodType,
isActive) =>
authenticateUser(
authMethodType, isActive),
))
],
),
]),
// )
],
),
),
],
),
),
),
),
),
bottomSheet: authenticationViewModel.user == null ? SizedBox(height: 0,) : Container(
height: 90,
width: double.infinity,
child: Center(
child: FractionallySizedBox(
widthFactor: 0.9,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
// AuthHeader(loginType.verificationMethods),
SizedBox(
height: 50,
),
VerificationMethods(
password: widget.password,
changeLoadingStata: changeLoadingStata,
AppButton(
title: TranslationBase
.of(context)
.useAnotherAccount,
color: Color(0xFFD02127),fontWeight: FontWeight.w700,
onPressed: () {
authenticationViewModel.deleteUser();
Navigator.pushAndRemoveUntil(
AppGlobal.CONTEX,
FadePage(
page: RootPage(),
),
(r) => false);
// Navigator.of(context).pushNamed(LOGIN);
},
),
SizedBox(height: 25,)
],
),
),
]));
),),
);
}
sendActivationCodeByOtpNotificationType(
AuthMethodTypes authMethodType) async {
if (authMethodType == AuthMethodTypes.SMS ||
authMethodType == AuthMethodTypes.WhatsApp) {
GifLoaderDialogUtils.showMyDialog(context);
await authenticationViewModel.sendActivationCodeForDoctorApp(authMethodType:authMethodType, password: widget.password );
if (authenticationViewModel.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(authenticationViewModel.error);
GifLoaderDialogUtils.hideDialog(context);
} else {
authenticationViewModel.setDataAfterSendActivationSuccess(authenticationViewModel.activationCodeForDoctorAppRes);
sharedPref.setString(PASSWORD, widget.password);
GifLoaderDialogUtils.hideDialog(context);
this.startSMSService(authMethodType);
}
} else {
// TODO route to this page with parameters to inicate we should present 2 option
if (Platform.isAndroid && authMethodType == AuthMethodTypes.Fingerprint) {
Helpers.showErrorToast('Your device not support this feature');
} else {}
}
}
sendActivationCodeVerificationScreen(AuthMethodTypes authMethodType) async {
GifLoaderDialogUtils.showMyDialog(context);
await authenticationViewModel
.sendActivationCodeVerificationScreen(authMethodType);
if (authenticationViewModel.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context);
Helpers.showErrorToast(authenticationViewModel.error);
} else {
authenticationViewModel.setDataAfterSendActivationSuccess(authenticationViewModel.activationCodeVerificationScreenRes);
if (authMethodType == AuthMethodTypes.SMS ||
authMethodType == AuthMethodTypes.WhatsApp) {
GifLoaderDialogUtils.hideDialog(context);
this.startSMSService(authMethodType);
} else {
checkActivationCode();
}
}
}
authenticateUser(AuthMethodTypes authMethodType, isActive) {
if (authMethodType == AuthMethodTypes.Fingerprint ||
authMethodType == AuthMethodTypes.FaceID) {
fingerPrintBefore = authMethodType;
}
this.selectedOption =
fingerPrintBefore != null ? fingerPrintBefore : authMethodType;
switch (authMethodType) {
case AuthMethodTypes.SMS:
sendActivationCode(authMethodType);
break;
case AuthMethodTypes.WhatsApp:
sendActivationCode(authMethodType);
break;
case AuthMethodTypes.Fingerprint:
this.loginWithFingerPrintOrFaceID(
AuthMethodTypes.Fingerprint, isActive);
break;
case AuthMethodTypes.FaceID:
this.loginWithFingerPrintOrFaceID(AuthMethodTypes.FaceID, isActive);
break;
default:
break;
}
sharedPref.setInt(OTP_TYPE, selectedOption.getTypeIdService());
}
sendActivationCode(AuthMethodTypes authMethodType) async {
if (authenticationViewModel.user != null) {
sendActivationCodeVerificationScreen(authMethodType);
} else {
sendActivationCodeByOtpNotificationType(authMethodType);
}
}
startSMSService(AuthMethodTypes type) {
new SMSOTP(
context,
type,
authenticationViewModel.loggedUser != null ? authenticationViewModel.loggedUser.mobileNumber : authenticationViewModel.user.mobile,
(value) {
showDialog(
context: context,
builder: (BuildContext context) {
return AppLoaderWidget();
});
this.checkActivationCode(value: value);
},
() =>
{
print('Faild..'),
},
).displayDialog(context);
}
loginWithFingerPrintOrFaceID(AuthMethodTypes authMethodTypes,
isActive) async {
if (isActive) {
await authenticationViewModel.showIOSAuthMessages();
if (!mounted) return;
if (authenticationViewModel.user != null &&
(SelectedAuthMethodTypesService.getMethodsTypeService(
authenticationViewModel.user.logInTypeID) ==
AuthMethodTypes.Fingerprint ||
SelectedAuthMethodTypesService.getMethodsTypeService(
authenticationViewModel.user.logInTypeID) == AuthMethodTypes.FaceID)) {
this.sendActivationCode(authMethodTypes);
} else {
setState(() {
this.onlySMSBox = true;
});
}
}
}
checkActivationCode({value}) async {
await authenticationViewModel.checkActivationCodeForDoctorApp(activationCode: value);
if (authenticationViewModel.state == ViewState.ErrorLocal) {
Navigator.pop(context);
Helpers.showErrorToast(authenticationViewModel.error);
} else {
await authenticationViewModel.onCheckActivationCodeSuccess();
navigateToLandingPage();
}
}
navigateToLandingPage() {
if (authenticationViewModel.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(authenticationViewModel.error);
} else {
Navigator.pushAndRemoveUntil(
context,
FadePage(
page: LandingPage(),
), (r) => false);
}
}
}

@ -1,9 +1,13 @@
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/dashboard/dashboard_model.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/patient/patient_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/home/dashboard_slider-item-widget.dart';
import 'package:doctor_app_flutter/screens/home/dashboard_swipe_widget.dart';
@ -40,15 +44,21 @@ class HomeScreen extends StatefulWidget {
}
class _HomeScreenState extends State<HomeScreen> {
bool isLoading = false;
ProjectViewModel projectsProvider;
var _isInit = true;
DoctorProfileModel profile;
bool isExpanded = false;
bool isInpatient = false;
int sliderActiveIndex = 0;
var clinicId;
AuthenticationViewModel authenticationViewModel;
@override
Widget build(BuildContext context) {
ProjectViewModel projectsProvider = Provider.of<ProjectViewModel>(context);
AuthViewModel authProvider = Provider.of<AuthViewModel>(context);
authenticationViewModel = Provider.of<AuthenticationViewModel>(context);
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
@ -56,7 +66,7 @@ class _HomeScreenState extends State<HomeScreen> {
return BaseView<DashboardViewModel>(
onModelReady: (model) async {
await model.setFirebaseNotification(projectsProvider, authProvider);
await model.setFirebaseNotification(projectsProvider, authenticationViewModel);
await model.getDashboard();
},
builder: (_, model, w) => AppScaffold(
@ -167,7 +177,7 @@ class _HomeScreenState extends State<HomeScreen> {
GifLoaderDialogUtils.showMyDialog(
context);
await model.changeClinic(
newValue, authProvider);
newValue, authenticationViewModel);
GifLoaderDialogUtils.hideDialog(
context);
if (model.state ==
@ -195,7 +205,7 @@ class _HomeScreenState extends State<HomeScreen> {
),
],
),
isClilic: true,
isClinic: true,
height: 50,
),
])
@ -318,7 +328,7 @@ class _HomeScreenState extends State<HomeScreen> {
PatientSearchRequestModel(
from: date,
to: date,
doctorID: authProvider
doctorID: authenticationViewModel
.doctorProfile
.doctorID)),
));

@ -29,9 +29,9 @@ import '../../util/extenstions.dart';
DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
class MedicineSearchScreen extends StatefulWidget with DrAppToastMsg {
MedicineSearchScreen({this.changeLoadingStata});
MedicineSearchScreen({this.changeLoadingState});
final Function changeLoadingStata;
final Function changeLoadingState;
@override
_MedicineSearchState createState() => _MedicineSearchState();

@ -6,7 +6,7 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/patient/patient_model.dart';
@ -63,9 +63,9 @@ class OutPatientsScreen extends StatefulWidget {
class _OutPatientsScreenState extends State<OutPatientsScreen> {
int clinicId;
AuthViewModel authProvider;
AuthenticationViewModel authenticationViewModel;
List<String> _times = []; //['All', 'Today', 'Tomorrow', 'Next Week'];
List<String> _times = [];
int _activeLocation = 1;
String patientType;
@ -82,7 +82,7 @@ class _OutPatientsScreenState extends State<OutPatientsScreen> {
@override
Widget build(BuildContext context) {
authProvider = Provider.of(context);
authenticationViewModel = Provider.of(context);
_times = [
TranslationBase.of(context).previous,
TranslationBase.of(context).today,

@ -2,7 +2,7 @@ import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/patient_type.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/patient/patient_model.dart';
@ -48,7 +48,7 @@ class PatientsSearchResultScreen extends StatefulWidget {
class _PatientsSearchResultScreenState
extends State<PatientsSearchResultScreen> {
int clinicId;
AuthViewModel authProvider;
AuthenticationViewModel authenticationViewModel;
String patientType;
String patientTypeTitle;
@ -62,7 +62,7 @@ class _PatientsSearchResultScreenState
@override
Widget build(BuildContext context) {
authProvider = Provider.of(context);
authenticationViewModel = Provider.of(context);
return BaseView<PatientSearchViewModel>(
onModelReady: (model) async {
if (!widget.isSearchWithKeyInfo &&

@ -2,7 +2,7 @@ import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/patient_type.dart';
import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_result_screen.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart';
@ -29,11 +29,11 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
TextEditingController middleNameInfoController = TextEditingController();
TextEditingController lastNameFileInfoController = TextEditingController();
PatientType selectedPatientType = PatientType.inPatient;
AuthViewModel authProvider;
AuthenticationViewModel authenticationViewModel;
@override
Widget build(BuildContext context) {
authProvider = Provider.of(context);
authenticationViewModel = Provider.of(context);
return BaseView<PatientSearchViewModel>(
onModelReady: (model) async {},
builder: (_, model, w) => AppScaffold(
@ -148,7 +148,7 @@ class _PatientSearchScreenState extends State<PatientSearchScreen> {
});
PatientSearchRequestModel patientSearchRequestModel =
PatientSearchRequestModel(
doctorID: authProvider.doctorProfile.doctorID);
doctorID: authenticationViewModel.doctorProfile.doctorID);
if (showOther) {
patientSearchRequestModel.firstName =
firstNameInfoController.text.trim().isEmpty

@ -1,6 +1,6 @@
import 'package:doctor_app_flutter/core/model/note/note_model.dart';
import 'package:doctor_app_flutter/core/model/note/update_note_model.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
@ -39,10 +39,8 @@ class ProgressNoteScreen extends StatefulWidget {
class _ProgressNoteState extends State<ProgressNoteScreen> {
List<NoteModel> notesList;
var filteredNotesList;
final _controller = TextEditingController();
var _isInit = true;
bool isDischargedPatient = false;
AuthViewModel authProvider;
AuthenticationViewModel authenticationViewModel;
ProjectViewModel projectViewModel;
getProgressNoteList(BuildContext context, PatientViewModel model,
@ -71,7 +69,7 @@ class _ProgressNoteState extends State<ProgressNoteScreen> {
@override
Widget build(BuildContext context) {
authProvider = Provider.of(context);
authenticationViewModel = Provider.of(context);
projectViewModel = Provider.of(context);
final routeArgs = ModalRoute
.of(context)
@ -141,7 +139,7 @@ class _ProgressNoteState extends State<ProgressNoteScreen> {
bgColor: model.patientProgressNoteList[index]
.status ==
1 &&
authProvider.doctorProfile.doctorID !=
authenticationViewModel.doctorProfile.doctorID !=
model
.patientProgressNoteList[
index]
@ -167,7 +165,7 @@ class _ProgressNoteState extends State<ProgressNoteScreen> {
index]
.status ==
1 &&
authProvider
authenticationViewModel
.doctorProfile.doctorID !=
model
.patientProgressNoteList[
@ -213,7 +211,7 @@ class _ProgressNoteState extends State<ProgressNoteScreen> {
index]
.status !=
4 &&
authProvider
authenticationViewModel
.doctorProfile.doctorID ==
model
.patientProgressNoteList[

@ -1,6 +1,5 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/patient/my_referral/PendingReferral.dart';
@ -15,16 +14,13 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
// ignore: must_be_immutable
class MyReferralDetailScreen extends StatelessWidget {
PendingReferral pendingReferral;
@override
Widget build(BuildContext context) {
final gridHeight = (MediaQuery.of(context).size.width * 0.3) * 1.8;
AuthViewModel authProvider = Provider.of(context);
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
pendingReferral = routeArgs['referral'];

@ -1,4 +1,3 @@
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/patient-referral-viewmodel.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
@ -7,15 +6,12 @@ import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../../../../routes.dart';
class MyReferralPatientScreen extends StatelessWidget {
// previous design page is: MyReferralPatient
@override
Widget build(BuildContext context) {
AuthViewModel authProvider = Provider.of(context);
return BaseView<PatientReferralViewModel>(
onModelReady: (model) => model.getPendingReferralPatients(),

@ -3,7 +3,6 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
// import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/models/SOAP/PatchAssessmentReqModel.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';

@ -1,6 +1,8 @@
import 'package:connectivity/connectivity.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_response_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/models/doctor/list_doctor_working_hours_table_model.dart';
import 'package:doctor_app_flutter/screens/auth/login_screen.dart';
@ -22,7 +24,7 @@ class Helpers {
static int cupertinoPickerIndex = 0;
get currentLanguage => null;
static showCupertinoPicker(context, items, decKey, onSelectFun) {
static showCupertinoPicker(context, List<GetHospitalsResponseModel> items, decKey, onSelectFun, AuthenticationViewModel model) {
showModalBottomSheet(
isDismissible: false,
context: context,
@ -63,7 +65,7 @@ class Helpers {
height: SizeConfig.realScreenHeight * 0.3,
color: Color(0xfff7f7f7),
child:
buildPickerItems(context, items, decKey, onSelectFun))
buildPickerItems(context, items, decKey, onSelectFun, model))
],
),
);
@ -73,14 +75,14 @@ class Helpers {
static TextStyle textStyle(context) =>
TextStyle(color: Theme.of(context).primaryColor);
static buildPickerItems(context, List items, decKey, onSelectFun) {
static buildPickerItems(context, List<GetHospitalsResponseModel> items, decKey, onSelectFun, model) {
return CupertinoPicker(
magnification: 1.5,
scrollController:
FixedExtentScrollController(initialItem: cupertinoPickerIndex),
children: items.map((item) {
return Text(
'${item["$decKey"]}',
'${item.facilityName}',
style: TextStyle(fontSize: SizeConfig.textMultiplier * 2),
);
}).toList(),
@ -130,6 +132,7 @@ class Helpers {
}
static generateContactAdminMsg([err = null]) {
//TODO: Add translation
String localMsg = 'Something wrong happened, please contact the admin';
if (err != null) {
localMsg = localMsg + '\n \n' + err.toString();
@ -141,20 +144,6 @@ class Helpers {
await sharedPref.clear();
}
static logout() async {
DEVICE_TOKEN = "";
String lang = await sharedPref.getString(APP_Language);
await clearSharedPref();
sharedPref.setString(APP_Language, lang);
ProjectViewModel().isLogin = false;
Navigator.pushAndRemoveUntil(
AppGlobal.CONTEX,
FadePage(
page: Loginsreen(),
),
(r) => false);
}
navigateToUpdatePage(String message, String androidLink, iosLink) {
Navigator.pushAndRemoveUntil(
AppGlobal.CONTEX,

@ -941,6 +941,8 @@ class TranslationBase {
String get verifySMS =>
localizedValues['verify-with-sms'][locale.languageCode];
String get verifyWith =>
localizedValues['verify-with'][locale.languageCode];
String get verifyWhatsApp =>
localizedValues['verify-with-whatsapp'][locale.languageCode];

@ -1,198 +0,0 @@
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:hexcolor/hexcolor.dart';
import '../../config/size_config.dart';
import '../../lookups/auth_lookup.dart';
class AuthHeader extends StatelessWidget {
var userType;
AuthHeader(this.userType);
@override
Widget build(BuildContext context) {
var screen = Container(
margin: SizeConfig.isMobile
? null
: EdgeInsetsDirectional.fromSTEB(SizeConfig.realScreenWidth * 0.30,
SizeConfig.realScreenWidth * 0.1, 0, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Container(
// margin: SizeConfig.isMobile
// ? EdgeInsetsDirectional.fromSTEB(
// 0, SizeConfig.realScreenHeight * 0.03, 0, 0)
// : EdgeInsetsDirectional.fromSTEB(
// SizeConfig.realScreenWidth * 0.13, 0, 0, 0),
// child: buildImageLogo(),
// ),
SizedBox(
height: 30,
),
//buildTextUnderLogo(context),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: SizeConfig.isMobile
? <Widget>[
SizedBox(
height: 10,
),
buildWelText(context),
buildDrSulText(context),
]
: <Widget>[
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
buildWelText(context),
buildDrSulText(context),
],
),
],
),
buildDrAppContainer(context)
],
));
return screen;
}
Image buildImageLogo() {
String img = 'assets/images/dr_app_logo.png';
return Image.asset(
img,
fit: BoxFit.cover,
height: SizeConfig.isMobile ? null : SizeConfig.realScreenWidth * 0.09,
);
}
Widget buildTextUnderLogo(context) {
Widget finalWid;
double textFontSize =
SizeConfig.isMobile ? 30 : SizeConfig.textMultiplier * 3;
EdgeInsetsDirectional containerMargin;
if (userType == loginType.knownUser || userType == loginType.unknownUser) {
finalWid = Text(
TranslationBase.of(context).login,
style: TextStyle(fontSize: textFontSize, fontWeight: FontWeight.w800),
);
} else {
String text1;
String text2;
if (userType == loginType.changePassword) {
text1 = 'Change ';
text2 = 'Password!';
}
if (userType == loginType.verifyPassword) {
text1 = TranslationBase.of(context).verify1;
text2 = TranslationBase.of(context).yourAccount;
}
if (userType == loginType.verificationMethods) {
text1 = TranslationBase.of(context).choose;
text2 = TranslationBase.of(context).verification;
}
List<Widget> childrens = <Widget>[
Text(
text1,
style: TextStyle(fontSize: textFontSize, fontWeight: FontWeight.w800),
),
Text(
text2,
style: TextStyle(
color: HexColor('#B8382C'),
fontSize: textFontSize,
fontWeight: FontWeight.w800),
)
];
if (!SizeConfig.isMobile) {
finalWid = Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: childrens,
);
} else {
finalWid = Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: childrens,
);
}
}
if (!SizeConfig.isMobile) {
double start = SizeConfig.realScreenWidth * 0.13;
if (loginType.verifyPassword == userType ||
loginType.changePassword == userType ||
userType == loginType.verificationMethods) {
start = 0;
}
containerMargin = EdgeInsetsDirectional.fromSTEB(start, 0, 0, 0);
}
return Container(margin: containerMargin, child: finalWid);
}
Container buildDrAppContainer(BuildContext context) {
if (userType == loginType.changePassword ||
userType == loginType.verifyPassword ||
userType == loginType.verificationMethods) {
return Container();
}
return Container(
// margin: SizeConfig.isMobile
// ? null
// : EdgeInsetsDirectional.fromSTEB(
// SizeConfig.realScreenWidth * 0.13, 0, 0, 0),
child: Text(
"Doctor App",
style: TextStyle(
fontSize:
SizeConfig.isMobile ? 16 : SizeConfig.realScreenWidth * 0.030,
fontWeight: FontWeight.w800,
color: HexColor('#B8382C')),
),
);
}
Text buildDrSulText(BuildContext context) {
if (userType == loginType.changePassword ||
userType == loginType.verifyPassword ||
userType == loginType.verificationMethods) {
return Text('');
}
return Text(
TranslationBase.of(context).drSulaimanAlHabib,
style: TextStyle(
fontWeight: FontWeight.w800,
fontSize:
SizeConfig.isMobile ? 24 : SizeConfig.realScreenWidth * 0.029,
fontFamily: 'Poppins'),
);
}
Widget buildWelText(BuildContext context) {
String text = TranslationBase.of(context).welcomeTo;
if (userType == loginType.unknownUser) {
text = TranslationBase.of(context).welcomeBackTo;
}
if (userType == loginType.changePassword ||
userType == loginType.verifyPassword ||
userType == loginType.verificationMethods) {
return Text('');
}
return AppText(
text,
// style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
);
}
}

@ -1,159 +0,0 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
class ChangePassword extends StatelessWidget {
final changePassFormKey = GlobalKey<FormState>();
var changePassFormValues = {
'currentPass': null,
'newPass': null,
'repeatedPass': null
};
@override
Widget build(BuildContext context) {
return Form(
key: changePassFormKey,
child: Container(
width: SizeConfig.realScreenWidth * 0.90,
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: <
Widget>[
buildSizedBox(),
TextFormField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
// ts/images/password_icon.png
prefixIcon: Image.asset('assets/images/password_icon.png'),
hintText: 'Current Password',
hintStyle:
TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: HexColor('#CCCCCC')),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide:
BorderSide(color: Theme.of(context).primaryColor),
)
//BorderRadius.all(Radius.circular(20));
),
validator: (value) {
if (value.isEmpty) {
return 'Please enter your Current Password';
}
return null;
},
onSaved: (value) {
// changePassFormValues. = value;
},
),
buildSizedBox(40),
// buildSizedBox(),
Text(
"New Password",
style: TextStyle(
fontSize: 2.8 * SizeConfig.textMultiplier,
fontWeight: FontWeight.w800),
),
buildSizedBox(10.0),
// Text()
TextFormField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
// ts/images/password_icon.png
prefixIcon: Image.asset('assets/images/password_icon.png'),
hintText: 'New Password',
hintStyle:
TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: HexColor('#CCCCCC')),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide:
BorderSide(color: Theme.of(context).primaryColor),
)
//BorderRadius.all(Radius.circular(20));
),
validator: (value) {
if (value.isEmpty) {
return 'Please enter your New Password';
}
return null;
},
onSaved: (value) {
// userInfo.UserID = value;
},
),
buildSizedBox(),
TextFormField(
keyboardType: TextInputType.number,
decoration: InputDecoration(
prefixIcon: Image.asset('assets/images/password_icon.png'),
hintText: 'Repeat Password',
hintStyle:
TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20)),
borderSide: BorderSide(color: HexColor('#CCCCCC')),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide:
BorderSide(color: Theme.of(context).primaryColor),
)
//BorderRadius.all(Radius.circular(20));
),
validator: (value) {
if (value.isEmpty) {
return 'Please enter your Repeat Password';
}
return null;
},
onSaved: (value) {
// userInfo.UserID = value;
},
),
buildSizedBox(),
RaisedButton(
onPressed:changePass,
elevation: 0.0,
child: Container(
width: double.infinity,
height: 50,
child: Center(
child: Text(
'Change Password'
.toUpperCase(),
// textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 2.5 * SizeConfig.textMultiplier),
),
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))),
),
SizedBox(
height: 10,
),
])));
}
SizedBox buildSizedBox([double height = 20]) {
return SizedBox(
height: height,
);
}
changePass(){
if(changePassFormKey.currentState.validate()){
changePassFormKey.currentState.save();
// call Api
}
}
}

@ -1,328 +0,0 @@
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:local_auth/error_codes.dart' as auth_error;
import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../config/size_config.dart';
import '../../core/viewModel/auth_view_model.dart';
import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../util/dr_app_toast_msg.dart';
import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
class KnownUserLogin extends StatefulWidget {
@override
_KnownUserLoginState createState() => _KnownUserLoginState();
}
class _KnownUserLoginState extends State<KnownUserLogin> {
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
final LocalAuthentication auth = LocalAuthentication();
String _authorized = "not Authorized";
bool _isAuthenticating = false;
Future _loggedUserFuture;
var _loggedUser;
int _loginType = 1;
String _platformImei;
Future _loginTypeFuture;
Map _loginTypeMap = {
1: {
"name": "SMS",
'imageUrl': 'assets/images/verification_sms_lg_icon.png',
},
2: {
"name": "FingerPrint",
'imageUrl': 'assets/images/verification_fingerprint_lg_icon.png'
},
3: {
"name": "Face",
'imageUrl': 'assets/images/verification_faceid_lg_icon.png'
},
4: {
"name": "WhatsApp",
'imageUrl': 'assets/images/verification_whatsapp_lg_icon.png'
}
};
Future<void> getSharedPref() async {
sharedPref.getObj(LOGGED_IN_USER).then((userInfo) {
_loggedUser = userInfo;
});
sharedPref.getString('platformImei').then((imei) {
_platformImei = imei;
});
}
@override
void initState() {
super.initState();
_loggedUserFuture = getSharedPref();
}
@override
Widget build(BuildContext context) {
AuthViewModel authProv = Provider.of<AuthViewModel>(context);
// var imeiModel = {'IMEI': _platformImei};
// _loginTypeFuture = authProv.selectDeviceImei(imeiModel);
return FutureBuilder(
future: Future.wait([_loggedUserFuture, _loginTypeFuture]),
builder: (BuildContext context, AsyncSnapshot snapshot) {
_loginTypeFuture.then((res) {
_loginType =
2; //res['SELECTDeviceIMEIbyIMEI_List'][0]['LogInType'];
}).catchError((err) {
print('${err}');
DrAppToastMsg.showErrorToast(err);
});
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return DrAppCircularProgressIndeicator();
default:
if (snapshot.hasError) {
DrAppToastMsg.showErrorToast('Error: ${snapshot.error}');
return Text('Error: ${snapshot.error}');
} else {
return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Stack(children: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: HexColor('#CCCCCC'),
),
borderRadius: BorderRadius.circular(50)),
margin: const EdgeInsets.fromLTRB(0, 20.0, 30, 0),
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
height: 100,
width: 100,
decoration: new BoxDecoration(
// color: Colors.green, // border color
shape: BoxShape.circle,
border:
Border.all(color: HexColor('#CCCCCC'))),
child: CircleAvatar(
child: Image.asset(
'assets/images/dr_avatar.png',
fit: BoxFit.cover,
),
)),
Container(
margin: EdgeInsets.symmetric(
vertical: 3, horizontal: 15),
child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
_loggedUser['List_MemberInformation'][0]
['MemberName'],
style: TextStyle(
color: HexColor('515A5D'),
fontSize:
2.5 * SizeConfig.textMultiplier,
fontWeight: FontWeight.w800),
),
Text(
'ENT Spec',
style: TextStyle(
color: HexColor('515A5D'),
fontSize:
1.5 * SizeConfig.textMultiplier),
)
],
),
)
],
),
),
Positioned(
top: 7,
right: 70,
child: Image.asset(
'assets/images/close_icon.png',
fit: BoxFit.cover,
))
]),
buildVerificationTypeImageContainer(),
buildButtonsContainer(context)
],
);
}
}
});
}
Container buildVerificationTypeImageContainer() {
print('${_loginTypeMap[_loginType]}');
return Container(
height: 200,
width: 200,
child: Center(
child: Image.asset(
_loginTypeMap[_loginType]['imageUrl'],
fit: BoxFit.cover,
),
));
}
//
Container buildButtonsContainer(BuildContext context) {
return Container(
margin: EdgeInsetsDirectional.fromSTEB(0, 0, 30, 0),
width: double.infinity,
child: Column(
children: <Widget>[
RaisedButton(
onPressed: _authenticate,
elevation: 0.0,
child: Container(
width: double.infinity,
height: 50,
child: Center(
child: Text(
"Verify using ${_loginTypeMap[_loginType]['name']}"
.toUpperCase(),
// textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 2.5 * SizeConfig.textMultiplier),
),
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(width: 0.5, color: HexColor('#CCCCCC'))),
),
SizedBox(
height: 10,
),
Container(
width: double.infinity,
height: 50,
child: FlatButton(
onPressed: () {
navigateToMoreOption();
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(
width: 1, color: Theme.of(context).primaryColor)),
child: Text(
"More verification Options".toUpperCase(),
style: TextStyle(
color: Theme.of(context).primaryColor,
fontSize: 2.5 * SizeConfig.textMultiplier),
)),
),
SizedBox(
height: 20,
),
],
),
);
}
navigateToMoreOption() {
Navigator.of(context).pushNamed(VERIFICATION_METHODS);
}
_authenticate() {
if (_loginType == 1) {
_authenticateBySMS();
}
if (_loginType == 2) {
_authenticateByFingerPrint();
}
if (_loginType == 3) {
_authenticateByFace();
}
if (_loginType == 4) {
_authenticateByWhatsApp();
}
}
Future<void> _authenticateByFingerPrint() async {
_getAvailableBiometrics();
bool authenticated = false;
try {
setState(() {
_isAuthenticating = true;
_authorized = 'Authenticating';
});
authenticated = await auth.authenticateWithBiometrics(
localizedReason: 'Scan your fingerprint to authenticate',
useErrorDialogs: true,
stickyAuth: false);
setState(() {
_isAuthenticating = false;
_authorized = 'Authenticating';
});
} on PlatformException catch (e) {
print(e);
}
if (!mounted) return;
final String message = authenticated ? 'Authorized' : 'Not Authorized';
if (message == 'Authorized') {
navigateToHome();
}
setState(() {
print('_authorized' + _authorized);
_authorized = message;
print('_authorized' + _authorized);
});
}
Future<void> _authenticateBySMS() {
print('_authenticateBySMS');
}
Future<void> _authenticateByFace() {
print('_authenticateByFace');
}
Future<void> _authenticateByWhatsApp() {
print('_authenticateByWhatsApp');
}
Future<void> _getAvailableBiometrics() async {
List<BiometricType> availableBiometrics;
try {
availableBiometrics = await auth.getAvailableBiometrics();
} on PlatformException catch (e) {
print(e);
if (e.code == auth_error.notAvailable) {
showErorrMsg("Auth Methods Not Available");
} else if (e.code == auth_error.passcodeNotSet) {
showErorrMsg("Auth Methods Not passcodeNotSet");
} else if (e.code == auth_error.permanentlyLockedOut) {
showErorrMsg("Auth Methods Not permanentlyLockedOut");
}
}
if (!mounted) return;
setState(() {
print('availableBiometrics $availableBiometrics');
});
}
navigateToHome() {
Navigator.of(context).pushReplacementNamed(HOME);
}
showErorrMsg(localMsg) {
DrAppToastMsg.showErrorToast(localMsg);
}
}

@ -1,312 +0,0 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/viewModel/imei_view_model.dart';
import 'package:doctor_app_flutter/screens/auth/verification_methods_screen.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import '../../config/shared_pref_kay.dart';
import '../../config/size_config.dart';
import '../../core/viewModel/hospital_view_model.dart';
import '../../models/doctor/user_model.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../util/dr_app_toast_msg.dart';
import '../../util/helpers.dart';
DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
DrAppToastMsg toastMsg = DrAppToastMsg();
Helpers helpers = Helpers();
class LoginForm extends StatefulWidget with DrAppToastMsg {
LoginForm({this.model});
final IMEIViewModel model;
@override
_LoginFormState createState() => _LoginFormState();
}
class _LoginFormState extends State<LoginForm> {
final loginFormKey = GlobalKey<FormState>();
var projectIdController = TextEditingController();
var projectsList = [];
FocusNode focusPass = FocusNode();
FocusNode focusProject = FocusNode();
HospitalViewModel projectsProv;
var userInfo = UserModel();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
projectsProv = Provider.of<HospitalViewModel>(context);
return Form(
key: loginFormKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: SizeConfig.realScreenWidth * 0.90,
height: SizeConfig.realScreenHeight * 0.65,
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
buildSizedBox(),
Padding(
child: AppText(
TranslationBase.of(context).enterCredentials,
fontSize: 18,
fontWeight: FontWeight.bold,
),
padding: EdgeInsets.only(top: 10, bottom: 10)),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color: HexColor("#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 10, top: 10),
child: AppText(
TranslationBase.of(context).enterId,
fontWeight: FontWeight.w800,
fontSize: 14,
)),
AppTextFormField(
labelText: '',
borderColor: Colors.white,
// keyboardType: TextInputType.number,
textInputAction: TextInputAction.next,
validator: (value) {
if (value != null && value.isEmpty) {
return TranslationBase.of(context)
.pleaseEnterYourID;
}
return null;
},
onSaved: (value) {
if (value != null) userInfo.userID = value.trim();
},
onChanged: (value) {
if (value != null) userInfo.userID = value.trim();
},
onFieldSubmitted: (_) {
focusPass.nextFocus();
},
)
])),
buildSizedBox(),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color: HexColor("#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 10, top: 10),
child: AppText(
TranslationBase.of(context).enterPassword,
fontWeight: FontWeight.w800,
fontSize: 14,
)),
AppTextFormField(
focusNode: focusPass,
obscureText: true,
borderColor: Colors.white,
textInputAction: TextInputAction.next,
validator: (value) {
if (value != null && value.isEmpty) {
return TranslationBase.of(context)
.pleaseEnterPassword;
}
return null;
},
onSaved: (value) {
userInfo.password = value;
},
onFieldSubmitted: (_) {
focusPass.nextFocus();
Helpers.showCupertinoPicker(context, projectsList,
'facilityName', onSelectProject);
},
onTap: () {
this.getProjects(userInfo.userID);
},
)
])),
buildSizedBox(),
projectsList.length > 0
? Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color: HexColor("#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 10, top: 10),
child: AppText(
TranslationBase.of(context).selectYourProject,
fontWeight: FontWeight.w600,
)),
AppTextFormField(
focusNode: focusProject,
controller: projectIdController,
borderColor: Colors.white,
suffixIcon: Icons.arrow_drop_down,
onTap: () {
Helpers.showCupertinoPicker(
context,
projectsList,
'facilityName',
onSelectProject);
},
validator: (value) {
if (value != null && value.isEmpty) {
return TranslationBase.of(context)
.pleaseEnterYourProject;
}
return null;
})
]))
: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color: HexColor("#CCCCCC"),
),
color: Colors.white),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 10, top: 10),
child: AppText(
TranslationBase.of(context).selectYourProject,
fontWeight: FontWeight.w800,
fontSize: 14,
)),
AppTextFormField(
readOnly: true,
borderColor: Colors.white,
prefix: IconButton(
icon: Icon(Icons.arrow_drop_down),
iconSize: 30,
padding: EdgeInsets.only(bottom: 30),
),
)
])),
]),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Expanded(
child: AppButton(
title: TranslationBase.of(context).login,
color: HexColor('#D02127'),
fontWeight: FontWeight.bold,
onPressed: () {
login(context, this.widget.model);
},
)),
],
)
],
),
);
//));
}
SizedBox buildSizedBox() {
return SizedBox(
height: 20,
);
}
login(
context,
model,
) {
if (loginFormKey.currentState.validate()) {
loginFormKey.currentState.save();
sharedPref.setInt(PROJECT_ID, userInfo.projectID);
model.login(userInfo).then((res) {
if (model.loginInfo['MessageStatus'] == 1) {
saveObjToString(LOGGED_IN_USER, model.loginInfo);
sharedPref.remove(LAST_LOGIN_USER);
sharedPref.setString(TOKEN, model.loginInfo['LogInTokenID']);
Navigator.of(AppGlobal.CONTEX).pushReplacement(MaterialPageRoute(
builder: (BuildContext context) => VerificationMethodsScreen(
password: userInfo.password,
)));
}
});
}
}
Future<void> setSharedPref(key, value) async {
sharedPref.setString(key, value).then((success) {
print("sharedPref.setString" + success.toString());
});
}
getProjectsList(memberID) {
projectsProv.getProjectsList(memberID).then((res) {
if (res['MessageStatus'] == 1) {
projectsList = res['ProjectInfo'];
setState(() {
userInfo.projectID = projectsList[0]["facilityId"];
projectIdController.text = projectsList[0]['facilityName'];
});
} else {
print(res);
}
});
}
saveObjToString(String key, value) async {
sharedPref.setObj(key, value);
}
onSelectProject(index) {
setState(() {
userInfo.projectID = projectsList[index]["facilityId"];
projectIdController.text = projectsList[index]['facilityName'];
});
primaryFocus.unfocus();
}
getProjects(value) {
if (value != null && value != '') {
if (projectsList.length == 0) {
getProjectsList(value);
}
}
}
}

@ -0,0 +1,62 @@
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
class MethodTypeCard extends StatelessWidget {
const MethodTypeCard({
Key key,
this.assetPath,
this.onTap,
this.label, this.height = 20,
}) : super(key: key);
final String assetPath;
final Function onTap;
final String label;
final double height;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Container(
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(10),
),
border: Border.all(
color: HexColor('#707070'),
width: 0.1),
),
height: 170,
child: Padding(
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
Image.asset(
assetPath,
height: 60,
width: 60,
),
],
),
SizedBox(
height:height ,
),
AppText(
label,
fontSize: 14,
color: Color(0xFF2E303A),
fontWeight: FontWeight.bold,
)
],
),
)),
);
}
}

@ -1,105 +0,0 @@
import 'dart:async';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/routes.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
Helpers helpers = Helpers();
class ShowTimerText extends StatefulWidget {
ShowTimerText({Key key, this.model});
final model;
@override
_ShowTimerTextState createState() => _ShowTimerTextState();
}
class _ShowTimerTextState extends State<ShowTimerText> {
String timerText = (TIMER_MIN - 1).toString() + ':59';
int min = TIMER_MIN - 1;
int sec = 59;
Timer _timer;
AuthViewModel authProv;
resendCode() {
min = TIMER_MIN - 1;
sec = 59;
_timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
if (min <= 0 && sec <= 0) {
timer.cancel();
} else {
setState(() {
sec = sec - 1;
if (sec == 0 && min == 0) {
Navigator.of(context).pushNamed(LOGIN);
min = 0;
sec = 0;
} else if (sec == 0) {
min = min - 1;
sec = 59;
}
timerText = min.toString() + ':' + sec.toString();
});
}
});
}
@override
void initState() {
super.initState();
resendCode();
}
@override
void dispose() {
_timer.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
authProv = Provider.of<AuthViewModel>(context);
return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
onTap: min != 0 || sec != 0
? null
: () {
resendActivatioinCode();
},
child: Text(
timerText,
style: TextStyle(
fontSize: 3.0 * SizeConfig.textMultiplier,
color: HexColor('#B8382C'),
fontWeight: FontWeight.bold),
),
),
],
),
);
}
resendActivatioinCode() {
authProv
.sendActivationCodeByOtpNotificationType(widget.model)
.then((res) => {
// print('$value')
if (res['MessageStatus'] == 1)
{resendCode()}
else
{Helpers.showErrorToast(res['ErrorEndUserMessage'])}
})
.catchError((err) {
Helpers.showErrorToast();
});
}
}

@ -1,15 +1,16 @@
import 'dart:async';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/auth_method_types.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class SMSOTP {
final type;
final AuthMethodTypes type;
final mobileNo;
final Function onSuccess;
final Function onFailure;
@ -17,12 +18,6 @@ class SMSOTP {
int remainingTime = 600;
Future<Null> timer;
static BuildContext _context;
static bool _loading;
SMSOTP(
this.context,
this.type,
@ -60,9 +55,6 @@ class SMSOTP {
projectProvider = Provider.of(context);
return AlertDialog(
contentPadding: EdgeInsets.fromLTRB(24.0, 0.0, 0.0, 24.0),
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.all(Radius.circular(10.0))),
content: StatefulBuilder(builder: (context, setState) {
if (displayTime == '') {
startTimer(setState);
@ -81,7 +73,7 @@ class SMSOTP {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
type == 1
type == AuthMethodTypes.SMS
? Padding(
child: Icon(
DoctorApp.verify_sms_1,
@ -287,8 +279,6 @@ class SMSOTP {
InputDecoration buildInputDecoration(BuildContext context) {
return InputDecoration(
counterText: " ",
// ts/images/password_icon.png
// contentPadding: EdgeInsets.only(top: 20, bottom: 20),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide(color: Colors.grey[300]),
@ -308,6 +298,7 @@ class SMSOTP {
);
}
// ignore: missing_return
String validateCodeDigit(value) {
if (value.isEmpty) {
return ' ';
@ -318,13 +309,14 @@ class SMSOTP {
}
}
checkValue() {
//print(verifyAccountFormValue);
checkValue() async {
if (verifyAccountForm.currentState.validate()) {
onSuccess(digit1.text.toString() +
digit2.text.toString() +
digit3.text.toString() +
digit4.text.toString());
this.isClosed = true;
}
}
@ -349,42 +341,14 @@ class SMSOTP {
displayTime = this.getSecondsAsDigitalClock(this.remainingTime);
});
timer = Future.delayed(Duration(seconds: 1), () {
Future.delayed(Duration(seconds: 1), () {
if (this.remainingTime > 0) {
if (isClosed == false) startTimer(setState);
if (isClosed == false) {
startTimer(setState);
}
} else {
Navigator.pop(context);
}
});
}
static void showLoadingDialog(BuildContext context, bool _loading) async {
_context = context;
if (_loading == false) {
Navigator.of(context).pop();
return;
}
_loading = true;
await showDialog(
context: _context,
barrierDismissible: false,
builder: (BuildContext context) {
return SimpleDialog(
elevation: 0.0,
backgroundColor: Colors.transparent,
children: <Widget>[
Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
),
)
],
);
});
}
static void hideSMSBox(context) {
Navigator.pop(context);
}
}

@ -1,386 +0,0 @@
import 'dart:async';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/models/auth/check_activation_code_request_model.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/auth/show_timer_text.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
import '../../config/size_config.dart';
import '../../core/viewModel/auth_view_model.dart';
import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../util/dr_app_toast_msg.dart';
import '../../util/helpers.dart';
import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers();
class VerifyAccount extends StatefulWidget {
VerifyAccount({this.changeLoadingStata});
final Function changeLoadingStata;
@override
_VerifyAccountState createState() => _VerifyAccountState();
}
class _VerifyAccountState extends State<VerifyAccount> {
final verifyAccountForm = GlobalKey<FormState>();
Map verifyAccountFormValue = {
'digit1': null,
'digit2': null,
'digit3': null,
'digit4': null,
};
Future _loggedUserFuture;
var _loggedUser;
AuthViewModel authProv;
bool _isInit = true;
var model;
TextEditingController digit1 = TextEditingController(text: "");
TextEditingController digit2 = TextEditingController(text: "");
TextEditingController digit3 = TextEditingController(text: "");
TextEditingController digit4 = TextEditingController(text: "");
@override
void initState() {
super.initState();
_loggedUserFuture = getSharedPref();
}
Future<void> getSharedPref() async {
sharedPref.getObj(LOGGED_IN_USER).then((userInfo) {
_loggedUser = userInfo;
});
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (_isInit) {
authProv = Provider.of<AuthViewModel>(context);
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
model = routeArgs['model'];
}
_isInit = false;
}
@override
Widget build(BuildContext context) {
authProv = Provider.of<AuthViewModel>(context);
final focusD1 = FocusNode();
final focusD2 = FocusNode();
final focusD3 = FocusNode();
final focusD4 = FocusNode();
return FutureBuilder(
future: Future.wait([_loggedUserFuture]),
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return DrAppCircularProgressIndeicator();
default:
if (snapshot.hasError) {
DrAppToastMsg.showErrorToast('Error: ${snapshot.error}');
return Text('Error: ${snapshot.error}');
} else {
return Form(
key: verifyAccountForm,
child: Container(
width: SizeConfig.realScreenWidth * 0.95,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
buildSizedBox(30),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: <Widget>[
Container(
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
textInputAction: TextInputAction.next,
style: buildTextStyle(),
autofocus: true,
maxLength: 1,
controller: digit1,
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
decoration: buildInputDecoration(context),
onSaved: (val) {
verifyAccountFormValue['digit1'] = val;
},
validator: validateCodeDigit,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD2);
},
onChanged: (val) {
if (val.length == 1) {
FocusScope.of(context)
.requestFocus(focusD2);
}
},
),
),
Container(
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
focusNode: focusD2,
controller: digit2,
textInputAction: TextInputAction.next,
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration:
buildInputDecoration(context),
onSaved: (val) {
verifyAccountFormValue['digit2'] =
val;
},
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD3);
},
onChanged: (val) {
if (val.length == 1) {
FocusScope.of(context)
.requestFocus(focusD3);
}
},
validator: validateCodeDigit),
),
Container(
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
focusNode: focusD3,
controller: digit3,
textInputAction: TextInputAction.next,
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration:
buildInputDecoration(context),
onSaved: (val) {
verifyAccountFormValue['digit3'] =
val;
},
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(focusD4);
},
onChanged: (val) {
if (val.length == 1) {
FocusScope.of(context)
.requestFocus(focusD4);
}
},
validator: validateCodeDigit)),
Container(
width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField(
focusNode: focusD4,
controller: digit4,
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration:
buildInputDecoration(context),
onSaved: (val) {
verifyAccountFormValue['digit4'] =
val;
},
validator: validateCodeDigit))
],
),
buildSizedBox(20),
buildText(),
buildSizedBox(40),
RaisedButton(
onPressed: () {
verifyAccount(
authProv, widget.changeLoadingStata);
},
elevation: 0.0,
child: Container(
width: double.infinity,
height: 50,
child: Center(
child: Text(
TranslationBase.of(context).verify,
style: TextStyle(
color: Colors.white,
fontSize:
3 * SizeConfig.textMultiplier),
),
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(
width: 0.5,
color: HexColor('#CCCCCC'))),
),
buildSizedBox(20),
ShowTimerText(model: model),
buildSizedBox(10),
])));
}
}
});
}
TextStyle buildTextStyle() {
return TextStyle(
fontSize: SizeConfig.textMultiplier * 3,
);
}
String validateCodeDigit(value) {
if (value.isEmpty) {
return 'Please enter your Password';
}
return null;
}
InputDecoration buildInputDecoration(BuildContext context) {
return InputDecoration(
contentPadding: EdgeInsets.only(top: 30, bottom: 30),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide(color: Colors.black),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Theme.of(context).primaryColor),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Theme.of(context).errorColor),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Theme.of(context).errorColor),
),
);
}
RichText buildText() {
String medthodName;
switch (model['OTP_SendType']) {
case 1:
medthodName = TranslationBase.of(context).smsBy;
break;
case 2:
medthodName = TranslationBase.of(context).whatsAppBy;
break;
default:
}
var text = RichText(
text: new TextSpan(
style: new TextStyle(
fontSize: 3.0 * SizeConfig.textMultiplier, color: Colors.black),
children: <TextSpan>[
new TextSpan(text: TranslationBase.of(context).youWillReceiveA),
new TextSpan(
text: TranslationBase.of(context).loginCode,
style: TextStyle(fontWeight: FontWeight.w700)),
new TextSpan(text: ' ${medthodName},'),
TextSpan(text: TranslationBase.of(context).pleaseEnterTheCode)
]));
return text;
}
SizedBox buildSizedBox([double height = 20]) {
return SizedBox(
height: height,
);
}
verifyAccount(AuthViewModel authProv, Function changeLoadingStata) async {
if (verifyAccountForm.currentState.validate()) {
changeLoadingStata(true);
verifyAccountForm.currentState.save();
final activationCode = verifyAccountFormValue['digit1'] +
verifyAccountFormValue['digit2'] +
verifyAccountFormValue['digit3'] +
verifyAccountFormValue['digit4'];
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp =
new CheckActivationCodeRequestModel(
zipCode: _loggedUser['ZipCode'],
mobileNumber: _loggedUser['MobileNumber'],
projectID: await sharedPref.getInt(PROJECT_ID),
logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID),
activationCode: activationCode,
generalid: "Cs2020@2016\$2958");
authProv
.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp)
.then((res) async {
if (res['MessageStatus'] == 1) {
sharedPref.setString(TOKEN, res['AuthenticationTokenID']);
if (res['List_DoctorProfile'] != null) {
loginProcessCompleted(
res['List_DoctorProfile'][0], changeLoadingStata);
} else {
ClinicModel clinic =
ClinicModel.fromJson(res['List_DoctorsClinic'][0]);
getDocProfiles(clinic, changeLoadingStata);
}
} else {
changeLoadingStata(false);
Helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
changeLoadingStata(false);
Helpers.showErrorToast(err);
});
}
}
loginProcessCompleted(
Map<String, dynamic> profile, Function changeLoadingStata) {
var doctor = DoctorProfileModel.fromJson(profile);
authProv.setDoctorProfile(doctor);
sharedPref.setObj(DOCTOR_PROFILE, profile);
this.getDashboard(doctor, changeLoadingStata);
}
getDashboard(doctor, Function changeLoadingStata) {
changeLoadingStata(false);
Navigator.of(context).pushReplacementNamed(HOME);
}
getDocProfiles(ClinicModel clinicInfo, Function changeLoadingStata) {
ProfileReqModel docInfo = new ProfileReqModel(
doctorID: clinicInfo.doctorID,
clinicID: clinicInfo.clinicID,
license: true,
projectID: clinicInfo.projectID,
tokenID: '',
languageID: 2);
authProv.getDocProfiles(docInfo.toJson()).then((res) {
if (res['MessageStatus'] == 1) {
loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata);
} else {
changeLoadingStata(false);
Helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
changeLoadingStata(false);
Helpers.showErrorToast(err);
});
}
}

@ -1,869 +0,0 @@
import 'dart:io' show Platform;
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/model/auth/imei_details.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/models/auth/activation_Code_req_model.dart';
import 'package:doctor_app_flutter/models/auth/check_activation_code_request_model.dart';
import 'package:doctor_app_flutter/models/auth/send_activation_code_model2.dart';
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/otp/sms-popup.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
import 'package:local_auth/auth_strings.dart';
import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';
import '../../config/size_config.dart';
import '../../core/viewModel/auth_view_model.dart';
import '../../landing_page.dart';
import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../util/helpers.dart';
import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers();
/*
*@author: Elham Rababah
*@Date:4/7/2020
*@param:
*@return:
*@desc: Verification Methods widget
*/
class VerificationMethods extends StatefulWidget {
VerificationMethods({this.changeLoadingStata, this.password});
final password;
final Function changeLoadingStata;
@override
_VerificationMethodsState createState() => _VerificationMethodsState();
}
class _VerificationMethodsState extends State<VerificationMethods> {
MainAxisAlignment spaceBetweenMethods = MainAxisAlignment.spaceBetween;
Future _loggedUserFuture;
var _loggedUser;
var verificationMethod;
GetIMEIDetailsModel user;
final LocalAuthentication auth = LocalAuthentication();
var _availableBiometrics;
ProjectViewModel projectsProvider;
var isMoreOption = false;
var onlySMSBox = false;
static BuildContext _context;
var loginTokenID;
bool authenticated;
var fingrePrintBefore;
var selectedOption;
@override
void initState() {
super.initState();
_loggedUserFuture = getSharedPref();
_getAvailableBiometrics();
}
Future<void> getSharedPref() async {
sharedPref.getObj(LOGGED_IN_USER).then((userInfo) {
_loggedUser = userInfo;
});
sharedPref.getObj(LAST_LOGIN_USER).then((lastLogin) {
if (lastLogin != null) {
user = GetIMEIDetailsModel.fromJson(lastLogin);
}
});
print(user);
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
verificationMethod =
routeArgs != null ? routeArgs['verificationMethod'] : null;
}
@override
Widget build(BuildContext context) {
AuthViewModel authProv = Provider.of<AuthViewModel>(context);
projectsProvider = Provider.of<ProjectViewModel>(context);
return FutureBuilder(
future: Future.wait([_loggedUserFuture]),
builder: (BuildContext context, AsyncSnapshot snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return DrAppCircularProgressIndeicator();
default:
if (snapshot.hasError) {
Helpers.showErrorToast('Error: ${snapshot.error}');
return Text('Error: ${snapshot.error}');
} else {
return SingleChildScrollView(
child: Container(
height: SizeConfig.realScreenHeight * .9,
width: SizeConfig.realScreenWidth,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: Column(
children: <Widget>[
user != null && isMoreOption == false
? Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
AppText(TranslationBase.of(context)
.welcomeBack),
AppText(
Helpers.capitalize(user.doctorName),
fontSize:
SizeConfig.textMultiplier * 3.5,
fontWeight: FontWeight.bold,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).accountInfo,
fontSize:
SizeConfig.textMultiplier * 2.5,
fontWeight: FontWeight.w600,
),
SizedBox(
height: 20,
),
Card(
color: Colors.white,
child: Row(
children: <Widget>[
Flexible(
flex: 3,
child: ListTile(
title: Text(
TranslationBase.of(
context)
.lastLoginAt,
overflow: TextOverflow
.ellipsis,
style: TextStyle(
fontFamily:
'Poppins',
fontWeight:
FontWeight.w800,
fontSize: 14),
),
subtitle: AppText(
getType(
user.logInTypeID,
context),
fontSize: 14,
))),
Flexible(
flex: 2,
child: ListTile(
title: AppText(
user.editedOn != null
? getDate(AppDateUtils
.convertStringToDate(
user
.editedOn))
: user.createdOn !=
null
? getDate(AppDateUtils
.convertStringToDate(
user.createdOn))
: '--',
textAlign:
TextAlign.right,
fontSize: 14,
fontWeight:
FontWeight.w800,
),
subtitle: AppText(
user.editedOn != null
? getTime(AppDateUtils
.convertStringToDate(
user
.editedOn))
: user.createdOn !=
null
? getTime(AppDateUtils
.convertStringToDate(
user.createdOn))
: '--',
textAlign:
TextAlign.right,
fontSize: 14,
),
))
],
)),
],
)
: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
this.onlySMSBox == false
? AppText(
TranslationBase.of(context)
.verifyLoginWith,
fontSize:
SizeConfig.textMultiplier *
3.5,
textAlign: TextAlign.left,
)
: AppText(
TranslationBase.of(context)
.verifyFingerprint2,
fontSize:
SizeConfig.textMultiplier *
2.5,
textAlign: TextAlign.start,
),
]),
user != null && isMoreOption == false
? Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
// Expanded(
// child:
// getButton(3, authProv)),
// Expanded(
// child: getButton(4, authProv))
Expanded(
child: InkWell(
onTap: () => {
authenticateUser(3,
true, authProv)
},
child: getButton(
user.logInTypeID,
authProv))),
Expanded(
child: getButton(5, authProv))
]),
])
: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
onlySMSBox == false
? Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: getButton(
3, authProv)),
Expanded(
child: getButton(
4, authProv))
],
)
: SizedBox(),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: getButton(1, authProv)),
Expanded(
child: getButton(2, authProv))
],
),
]),
// )
],
),
),
Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
user != null
? Row(
children: <Widget>[
Expanded(
child: AppButton(
title: TranslationBase.of(context)
.useAnotherAccount,
color: Colors.red[700],
onPressed: () {
Navigator.of(context).pushNamed(LOGIN);
},
)),
],
)
: SizedBox(),
],
),
],
),
));
}
}
});
}
bool hideSilentMethods() {
return verificationMethod == 4 || verificationMethod == 3 ? true : false;
}
sendActivationCodeByOtpNotificationType(
oTPSendType, AuthViewModel authProv) async {
// TODO : build enum for verfication method
if (oTPSendType == 1 || oTPSendType == 2) {
widget.changeLoadingStata(true);
int projectID = await sharedPref.getInt(PROJECT_ID);
ActivationCodeModel activationCodeModel = ActivationCodeModel(
facilityId: projectID,
memberID: _loggedUser['List_MemberInformation'][0]['MemberID'],
zipCode: _loggedUser['ZipCode'],
mobileNumber: _loggedUser['MobileNumber'],
otpSendType: oTPSendType.toString(),
password: widget.password);
try {
authProv
.sendActivationCodeForDoctorApp(activationCodeModel)
.then((res) {
if (res['MessageStatus'] == 1) {
print("VerificationCode : " + res["VerificationCode"]);
sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]);
sharedPref.setString(
VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]);
sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]);
sharedPref.setString(PASSWORD, widget.password);
this.startSMSService(oTPSendType, authProv);
} else {
print(res['ErrorEndUserMessage']);
Helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
print('$err');
widget.changeLoadingStata(false);
Helpers.showErrorToast();
});
} catch (e) {}
} else {
// TODO route to this page with parameters to inicate we should present 2 option
if (Platform.isAndroid && oTPSendType == 3) {
Helpers.showErrorToast('Your device not support this feature');
} else {
// Navigator.of(context).push(MaterialPageRoute(
// builder: (BuildContext context) =>
// VerificationMethodsScreen(password: widget.password,)));
// Navigator.of(context).pushNamed(VERIFICATION_METHODS,
// arguments: {'verificationMethod': oTPSendType});
}
}
}
sendActivationCodeVerificationScreen(
oTPSendType, AuthViewModel authProv) async {
// TODO : build enum for verfication method
//if (oTPSendType == 1 || oTPSendType == 2) {
widget.changeLoadingStata(true);
ActivationCodeModel2 activationCodeModel = ActivationCodeModel2(
iMEI: user.iMEI,
facilityId: user.projectID,
memberID: user.doctorID,
zipCode: user.outSA == true ? '971' : '966',
mobileNumber: user.mobile,
oTPSendType: oTPSendType,
isMobileFingerPrint: 1,
vidaAuthTokenID: user.vidaAuthTokenID,
vidaRefreshTokenID: user.vidaRefreshTokenID);
try {
authProv
.sendActivationCodeVerificationScreen(activationCodeModel)
.then((res) {
if (res['MessageStatus'] == 1) {
print("VerificationCode : " + res["VerificationCode"]);
sharedPref.setString(VIDA_AUTH_TOKEN_ID, res["VidaAuthTokenID"]);
sharedPref.setString(
VIDA_REFRESH_TOKEN_ID, res["VidaRefreshTokenID"]);
sharedPref.setString(LOGIN_TOKEN_ID, res["LogInTokenID"]);
if (oTPSendType == 1 || oTPSendType == 2) {
widget.changeLoadingStata(false);
this.startSMSService(oTPSendType, authProv);
} else {
checkActivationCode(authProv);
}
} else {
print(res['ErrorEndUserMessage']);
Helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
print('$err');
widget.changeLoadingStata(false);
Helpers.showErrorToast();
});
} catch (e) {}
// }
// else {
// checkActivationCode(authProv);
// }
}
Widget getButton(flag, authProv) {
switch (flag) {
case 2:
return InkWell(
onTap: () => {authenticateUser(2, true, authProv)},
child: Container(
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Padding(
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
Image.asset(
'assets/images/verify-whtsapp.png',
height: 60,
width: 60,
),
],
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).verifyWhatsApp,
fontSize: 14,
fontWeight: FontWeight.w600,
)
],
),
)));
break;
case 1:
return InkWell(
onTap: () => {authenticateUser(1, true, authProv)},
child: Container(
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Padding(
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
'assets/images/verify-sms.png',
height: 60,
width: 60,
),
projectsProvider.isArabic
? SizedBox(
height: 20,
)
: SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).verifySMS,
fontSize: 14,
fontWeight: FontWeight.w600,
)
],
),
)));
break;
case 3:
return InkWell(
onTap: () => {
if (checkIfBiometricAvailable(BiometricType.fingerprint))
{authenticateUser(3, true, authProv)}
},
child: Container(
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Padding(
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
'assets/images/verification_fingerprint_icon.png',
height: 60,
width: 60,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).verifyFingerprint,
fontSize: 14,
fontWeight: FontWeight.w600,
)
],
),
)));
break;
case 4:
return InkWell(
onTap: () {
if (checkIfBiometricAvailable(BiometricType.face)) {
authenticateUser(4, true, authProv);
}
},
child:
// RoundedContainer(
// backgroundColor: checkIfBiometricAvailable(BiometricType.face)
// ? Colors.white
// : Colors.white.withOpacity(.7),
// borderColor: Colors.grey,
// showBorder: false,
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
margin: EdgeInsets.all(10),
child: Padding(
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
'assets/images/verification_faceid_icon.png',
height: 60,
width: 60,
),
SizedBox(
height: 20,
),
AppText(
TranslationBase.of(context).verifyFaceID,
fontSize: 14,
fontWeight: FontWeight.w600,
)
],
),
)));
break;
default:
return InkWell(
onTap: () => {
setState(() {
isMoreOption = true;
})
},
child: Container(
// backgroundColor: Colors.white,
// borderColor: Colors.grey,
// showBorder: false,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Padding(
padding: EdgeInsets.fromLTRB(20, 15, 20, 15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Image.asset(
'assets/images/login/more_icon.png',
height: 60,
width: 60,
),
projectsProvider.isArabic
? SizedBox(
height: 20,
)
: SizedBox(
height: 10,
),
AppText(
TranslationBase.of(context).moreVerification,
fontSize: 14,
fontWeight: FontWeight.w600,
// textAlign: TextAlign.center,
)
],
),
)));
}
}
getType(type, context) {
switch (type) {
case 1:
return TranslationBase.of(context).verifySMS;
break;
case 3:
return TranslationBase.of(context).verifyFingerprint;
break;
case 4:
return TranslationBase.of(context).verifyFaceID;
break;
case 2:
return TranslationBase.of(context).verifyWhatsApp;
break;
default:
return TranslationBase.of(context).verifySMS;
break;
}
}
bool checkIfBiometricAvailable(BiometricType biometricType) {
bool isAvailable = false;
if (_availableBiometrics != null) {
for (var i = 0; i < _availableBiometrics.length; i++) {
if (biometricType == _availableBiometrics[i]) isAvailable = true;
}
}
return isAvailable;
}
formatDate(date) {
return DateFormat('MMM dd, yyy, kk:mm').format(date);
}
authenticateUser(type, isActive, authProv) {
//GifLoaderDialogUtils.showMyDialog(context);
if (type == 3 || type == 4) {
fingrePrintBefore = type;
}
this.selectedOption = fingrePrintBefore != null ? fingrePrintBefore : type;
switch (type) {
case 1:
this.loginWithSMS(1, isActive, authProv);
break;
case 2:
this.loginWithSMS(2, isActive, authProv);
break;
case 3:
this.loginWithFingurePrintFace(3, isActive, authProv);
break;
case 4:
this.loginWithFingurePrintFace(4, isActive, authProv);
break;
default:
break;
}
sharedPref.setInt(OTP_TYPE, selectedOption);
// sharedPref.setInt(LAST_LOGIN),
}
loginWithSMS(type, isActive, authProv) {
this.sendActivationCode(type, authProv);
}
Future<void> _getAvailableBiometrics() async {
var availableBiometrics;
try {
availableBiometrics = await auth.getAvailableBiometrics();
} on PlatformException catch (e) {
print(e);
}
if (!mounted) return;
setState(() {
_availableBiometrics = availableBiometrics;
});
}
sendActivationCode(type, authProv) async {
if (user != null) {
sendActivationCodeVerificationScreen(type, authProv);
} else {
sendActivationCodeByOtpNotificationType(type, authProv);
}
}
startSMSService(type, authProv) {
new SMSOTP(
context,
type,
_loggedUser != null ? _loggedUser['MobileNumber'] : user.mobile,
(value) {
showDialog(
context: context,
builder: (BuildContext context) {
return Center(
child: CircularProgressIndicator(),
);
});
this.checkActivationCode(authProv, value: value);
},
() => {
widget.changeLoadingStata(false),
print('Faild..'),
},
).displayDialog(context);
}
loginWithFingurePrintFace(type, isActive, authProv) async {
if (isActive) {
// this.startBiometricLoginIfAvailable();
const iosStrings = const IOSAuthMessages(
cancelButton: 'cancel',
goToSettingsButton: 'settings',
goToSettingsDescription: 'Please set up your Touch ID.',
lockOut: 'Please reenable your Touch ID');
try {
authenticated = await auth.authenticateWithBiometrics(
localizedReason: 'Scan your fingerprint to authenticate',
useErrorDialogs: true,
stickyAuth: true,
iOSAuthStrings: iosStrings);
} on PlatformException catch (e) {
DrAppToastMsg.showErrorToast(e);
}
if (!mounted) return;
if (user != null && (user.logInTypeID == 3 || user.logInTypeID == 4)) {
this.sendActivationCode(type, authProv);
// this.checkActivationCode(authProv);
} else {
setState(() {
this.onlySMSBox = true;
});
}
}
}
checkActivationCode(AuthViewModel authProv, {value}) async {
CheckActivationCodeRequestModel checkActivationCodeForDoctorApp =
new CheckActivationCodeRequestModel(
zipCode:
_loggedUser != null ? _loggedUser['ZipCode'] : user.zipCode,
mobileNumber:
_loggedUser != null ? _loggedUser['MobileNumber'] : user.mobile,
projectID: await sharedPref.getInt(PROJECT_ID) != null
? await sharedPref.getInt(PROJECT_ID)
: user.projectID,
logInTokenID: await sharedPref.getString(LOGIN_TOKEN_ID),
activationCode: value ?? '0000',
oTPSendType: await sharedPref.getInt(OTP_TYPE),
generalid: "Cs2020@2016\$2958");
authProv
.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp)
.then((res) async {
widget.changeLoadingStata(false);
if (res['MessageStatus'] == 1) {
sharedPref.setString(TOKEN, res['AuthenticationTokenID']);
if (res['List_DoctorProfile'] != null) {
loginProcessCompleted(res['List_DoctorProfile'][0], authProv);
sharedPref.setObj(CLINIC_NAME, res['List_DoctorsClinic']);
} else {
sharedPref.setObj(CLINIC_NAME, res['List_DoctorsClinic']);
ClinicModel clinic =
ClinicModel.fromJson(res['List_DoctorsClinic'][0]);
getDocProfiles(clinic, authProv);
}
} else {
Navigator.pop(context);
Helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
Navigator.pop(context);
Helpers.showErrorToast(err);
});
}
loginProcessCompleted(Map<String, dynamic> profile, authProv) {
var doctor = DoctorProfileModel.fromJson(profile);
authProv.setDoctorProfile(doctor);
sharedPref.setObj(DOCTOR_PROFILE, profile);
projectsProvider.isLogin = true;
Navigator.pushAndRemoveUntil(
context,
FadePage(
page: LandingPage(),
),
(r) => false);
}
getDocProfiles(ClinicModel clinicInfo, authProv) {
ProfileReqModel docInfo = new ProfileReqModel(
doctorID: clinicInfo.doctorID,
clinicID: clinicInfo.clinicID,
license: true,
projectID: clinicInfo.projectID,
tokenID: '',
languageID: 2);
authProv.getDocProfiles(docInfo.toJson()).then((res) {
if (res['MessageStatus'] == 1) {
loginProcessCompleted(res['DoctorProfileList'][0], authProv);
} else {
// changeLoadingStata(false);
Helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
// changeLoadingStata(false);
Helpers.showErrorToast(err);
});
}
getDate(DateTime date) {
final DateFormat formatter = DateFormat('dd MMM yyyy');
return formatter.format(date);
}
getTime(DateTime date) {
final DateFormat formatter = DateFormat('HH:mm a');
return formatter.format(date);
}
}

@ -0,0 +1,96 @@
import 'package:doctor_app_flutter/core/enum/auth_method_types.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/auth/method_type_card.dart';
import 'package:flutter/material.dart';
import 'package:local_auth/local_auth.dart';
import 'package:provider/provider.dart';
class VerificationMethodsList extends StatefulWidget {
final AuthMethodTypes authMethodType;
final Function(AuthMethodTypes type, bool isActive) authenticateUser;
final Function onShowMore;
final AuthenticationViewModel authenticationViewModel;
const VerificationMethodsList(
{Key key,
this.authMethodType,
this.authenticateUser,
this.onShowMore,
this.authenticationViewModel})
: super(key: key);
@override
_VerificationMethodsListState createState() =>
_VerificationMethodsListState();
}
class _VerificationMethodsListState extends State<VerificationMethodsList> {
final LocalAuthentication auth = LocalAuthentication();
ProjectViewModel projectsProvider;
@override
Widget build(BuildContext context) {
projectsProvider = Provider.of<ProjectViewModel>(context);
switch (widget.authMethodType) {
case AuthMethodTypes.WhatsApp:
return MethodTypeCard(
assetPath: 'assets/images/verify-whtsapp.png',
onTap: () =>
{widget.authenticateUser(AuthMethodTypes.WhatsApp, true)},
label: TranslationBase
.of(context)
.verifyWith+ TranslationBase.of(context).verifyWhatsApp,
);
break;
case AuthMethodTypes.SMS:
return MethodTypeCard(
assetPath: "assets/images/verify-sms.png",
onTap: () => {widget.authenticateUser(AuthMethodTypes.SMS, true)},
label:TranslationBase
.of(context)
.verifyWith+ TranslationBase.of(context).verifySMS,
);
break;
case AuthMethodTypes.Fingerprint:
return MethodTypeCard(
assetPath: 'assets/images/verification_fingerprint_icon.png',
onTap: () async {
if (await widget.authenticationViewModel
.checkIfBiometricAvailable(BiometricType.fingerprint)) {
widget.authenticateUser(AuthMethodTypes.Fingerprint, true);
}
},
label: TranslationBase
.of(context)
.verifyWith+TranslationBase.of(context).verifyFingerprint,
);
break;
case AuthMethodTypes.FaceID:
return MethodTypeCard(
assetPath: 'assets/images/verification_faceid_icon.png',
onTap: () async {
if (await widget.authenticationViewModel
.checkIfBiometricAvailable(BiometricType.face)) {
widget.authenticateUser(AuthMethodTypes.FaceID, true);
}
},
label: TranslationBase
.of(context)
.verifyWith+TranslationBase.of(context).verifyFaceID,
);
break;
default:
return MethodTypeCard(
assetPath: 'assets/images/login/more_icon.png',
onTap: widget.onShowMore,
label: TranslationBase.of(context).moreVerification,
height: 0,
);
}
}
}

@ -1,17 +1,17 @@
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ProfileWelcomeWidget extends StatelessWidget {
final Widget clinicWidget;
final double height;
final bool isClilic;
final bool isClinic;
ProfileWelcomeWidget(this.clinicWidget,
{this.height = 150, this.isClilic = false});
{this.height = 150, this.isClinic = false});
@override
Widget build(BuildContext context) {
AuthViewModel authProvider = Provider.of(context);
AuthenticationViewModel authenticationViewModel = Provider.of(context);
return Container(
height: height,
@ -23,39 +23,17 @@ class ProfileWelcomeWidget extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
this.isClilic == true ? clinicWidget : SizedBox(),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.start,
// children: <Widget>[
// Row(
// children: <Widget>[
// AppText(
// TranslationBase.of(context).welcome,
// fontSize: SizeConfig.textMultiplier * 1.7,
// color: Colors.black,
// )
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: <Widget>[
// AppText(
// // TranslationBase.of(context).dr +
// ' ${authProvider.doctorProfile.doctorName}',
// fontWeight: FontWeight.bold,
// fontSize: SizeConfig.textMultiplier * 2.5,
// color: Colors.black,
// ),
this.isClinic == true ? clinicWidget : SizedBox(),
SizedBox(
width: 20,
),
if(authenticationViewModel.doctorProfile!=null)
CircleAvatar(
// radius: (52)
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Image.network(
authProvider.doctorProfile.doctorImageURL,
authenticationViewModel.doctorProfile.doctorImageURL,
fit: BoxFit.fill,
width: 75,
height: 75,
@ -63,23 +41,10 @@ class ProfileWelcomeWidget extends StatelessWidget {
),
backgroundColor: Colors.transparent,
),
// ],
// ),
SizedBox(
height: 20,
),
/// ],
// ),
// Expanded(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.end,
// children: <Widget>[
// ],
// ),
// ),
],
)),
);

@ -1,4 +1,4 @@
import 'package:doctor_app_flutter/core/viewModel/auth_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/screens/reschedule-leaves/add-rescheduleleave.dart';
@ -28,7 +28,7 @@ class _AppDrawerState extends State<AppDrawer> {
@override
Widget build(BuildContext context) {
AuthViewModel authProvider = Provider.of(context);
AuthenticationViewModel authenticationViewModel = Provider.of(context);
projectsProvider = Provider.of(context);
return RoundedContainer(
child: Container(
@ -69,7 +69,7 @@ class _AppDrawerState extends State<AppDrawer> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
),
SizedBox(height: 5),
if (authProvider.doctorProfile != null)
if (authenticationViewModel.doctorProfile != null)
InkWell(
onTap: () {
// TODO: return it back when its needed
@ -85,7 +85,7 @@ class _AppDrawerState extends State<AppDrawer> {
padding: EdgeInsets.only(top: 10),
child: AppText(
TranslationBase.of(context).dr +
authProvider.doctorProfile?.doctorName,
authenticationViewModel.doctorProfile?.doctorName,
fontWeight: FontWeight.bold,
color: Color(0xFF2E303A),
fontFamily: 'Poppins',
@ -95,7 +95,7 @@ class _AppDrawerState extends State<AppDrawer> {
Padding(
padding: EdgeInsets.only(top: 0),
child: AppText(
authProvider.doctorProfile?.clinicDescription,
authenticationViewModel.doctorProfile?.clinicDescription,
fontWeight: FontWeight.w600,
color: Color(0xFF2E303A),
fontSize: 15,
@ -172,8 +172,7 @@ class _AppDrawerState extends State<AppDrawer> {
),
onTap: () async {
Navigator.pop(context);
await Helpers.logout();
projectsProvider.isLogin = false;
await authenticationViewModel.logout();
},
),
],

@ -3,13 +3,6 @@ import 'package:progress_hud_v2/progress_hud.dart';
import 'loader/gif_loader_container.dart';
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param:
*@return: Positioned
*@desc: AppLoaderWidget to create loader
*/
class AppLoaderWidget extends StatefulWidget {
AppLoaderWidget({Key key, this.title, this.containerColor}) : super(key: key);
@ -21,25 +14,7 @@ class AppLoaderWidget extends StatefulWidget {
}
class _AppLoaderWidgetState extends State<AppLoaderWidget> {
ProgressHUD _progressHUD;
@override
void initState() {
super.initState();
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param:
*@return:
*@desc: create loader the desing
*/
_progressHUD = new ProgressHUD(
backgroundColor: widget.containerColor == null ? Colors.black12 : widget.containerColor,
color: Colors.black,
// containerColor: Colors.blue,
borderRadius: 5.0,
// text: 'Loading...',
);
}
@override
Widget build(BuildContext context) {

@ -26,6 +26,7 @@ class AppTextFieldCustom extends StatefulWidget {
final Function(String) onChanged;
final String validationError;
final bool isPrscription;
final bool isSecure;
AppTextFieldCustom({
this.height = 0,
@ -45,6 +46,7 @@ class AppTextFieldCustom extends StatefulWidget {
this.onChanged,
this.validationError,
this.isPrscription = false,
this.isSecure = false,
});
@override
@ -132,6 +134,7 @@ class _AppTextFieldCustomState extends State<AppTextFieldCustom> {
widget.onChanged(value);
}
},
obscureText: widget.isSecure
),
)
: AppText(

Loading…
Cancel
Save