Merge branch 'development' into medical-profile-services
# Conflicts: # lib/locator.dartmerge-requests/672/head
commit
9e80a1879e
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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,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,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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue