updates, fixes & service privileges

pull/21/head
Haroon Amjad 2 months ago
parent 255b3c1565
commit 6b2ec5aa2c

@ -803,6 +803,7 @@ class ApiConsts {
static final String insertPatientDeviceIMEIData = 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI';
static final String insertPatientMobileData = 'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo';
static final String getPrivileges = 'Services/Patients.svc/REST/Service_Privilege';
// static values for Api
static final double appVersionID = 18.7;

@ -1,7 +1,10 @@
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:hmg_patient_app_new/core/common_models/VidaPlusProjectListModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/HMCProjectListModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/PrivilegeModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/VidaPlusProjectListModel.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_user_staus_nhic_response_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/select_device_by_imei.dart';
@ -37,7 +40,7 @@ class AppState {
if (isFamily) {
_authenticatedChildUser = authenticatedUser;
} else {
setIsAuthenticated = true;
setIsAuthenticated = true;
_authenticatedRootUser = authenticatedUser;
}
}
@ -93,11 +96,26 @@ class AppState {
set setDeviceTypeID(v) => deviceTypeID = v;
List<VidaPlusProjectListModel> vidaPlusProjectList = [];
List<PrivilegeModel> privilegeModelList = [];
List<HMCProjectListModel> hMCProjectListModel = [];
List<ProjectDetailListModel> projectDetailListModel = [];
setVidaPlusProjectList(List<VidaPlusProjectListModel> vidaPlusProjectListModelInput) {
vidaPlusProjectList = vidaPlusProjectListModelInput;
}
setPrivilegeModelList(List<PrivilegeModel> privilegeModelListInput) {
privilegeModelList = privilegeModelListInput;
}
setHMCProjectList(List<HMCProjectListModel> hMCProjectListModelInput) {
hMCProjectListModel = hMCProjectListModelInput;
}
setProjectsDetailList(List<ProjectDetailListModel> projectDetailListModelInput) {
projectDetailListModel = projectDetailListModelInput;
}
CheckUserStatusResponseNHIC? _nHICUserData;
CheckUserStatusResponseNHIC get getNHICUserData => _nHICUserData!;
@ -106,7 +124,6 @@ class AppState {
_nHICUserData = value;
}
RegistrationDataModelPayload? _userRegistrationPayload;
RegistrationDataModelPayload get getUserRegistrationPayload => _userRegistrationPayload ?? RegistrationDataModelPayload();

@ -0,0 +1,15 @@
class HMCProjectListModel {
int? projectID;
HMCProjectListModel({this.projectID});
HMCProjectListModel.fromJson(Map<String, dynamic> json) {
projectID = json['ProjectID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ProjectID'] = this.projectID;
return data;
}
}

@ -0,0 +1,24 @@
class PrivilegeModel {
int? iD;
String? serviceName;
bool? privilege;
dynamic region;
PrivilegeModel({this.iD, this.serviceName, this.privilege, this.region});
PrivilegeModel.fromJson(Map<String, dynamic> json) {
iD = json['ID'];
serviceName = json['ServiceName'];
privilege = json['Previlege'];
region = json['Region'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ID'] = this.iD;
data['ServiceName'] = this.serviceName;
data['Previlege'] = this.privilege;
data['Region'] = this.region;
return data;
}
}

@ -0,0 +1,32 @@
class ProjectDetailListModel {
int? projectID;
String? latitude;
String? longitude;
int? geofenceRadius;
String? checkInQrCode;
ProjectDetailListModel(
{this.projectID,
this.latitude,
this.longitude,
this.geofenceRadius,
this.checkInQrCode});
ProjectDetailListModel.fromJson(Map<String, dynamic> json) {
projectID = json['ProjectID'];
latitude = json['Latitude'];
longitude = json['Longitude'];
geofenceRadius = json['GeofenceRadius'];
checkInQrCode = json['CheckInQrCode'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ProjectID'] = this.projectID;
data['Latitude'] = this.latitude;
data['Longitude'] = this.longitude;
data['GeofenceRadius'] = this.geofenceRadius;
data['CheckInQrCode'] = this.checkInQrCode;
return data;
}
}

@ -20,6 +20,9 @@ class RequestUtils {
bool fileNo = false;
if (nationId.isNotEmpty) {
fileNo = nationId.length < 10;
if (fileNo) {
patientId = int.tryParse(nationId);
}
}
var request = SendActivationRequest();
if (phoneNumber.isNotEmpty) {
@ -51,18 +54,17 @@ class RequestUtils {
return request;
}
static dynamic getCommonRequestWelcome({
required String phoneNumber,
required OTPTypeEnum otpTypeEnum,
required String? deviceToken,
required bool patientOutSA,
required String? loginTokenID,
required var registeredData,
int? patientId,
required String nationIdText,
required String countryCode,
required int loginType
}) {
static dynamic getCommonRequestWelcome(
{required String phoneNumber,
required OTPTypeEnum otpTypeEnum,
required String? deviceToken,
required bool patientOutSA,
required String? loginTokenID,
required var registeredData,
int? patientId,
required String nationIdText,
required String countryCode,
required int loginType}) {
bool fileNo = false;
if (nationIdText.isNotEmpty) {
fileNo = nationIdText.length < 10;
@ -86,7 +88,7 @@ class RequestUtils {
} else {
if (fileNo) {
request.patientID = patientId ?? int.parse(nationIdText);
request.patientIdentificationID = request.nationalID = "" as int?;
request.patientIdentificationID = request.nationalID = 0;
request.searchType = 2;
} else {
request.patientID = 0;

@ -10,6 +10,7 @@ import 'package:fluttertoast/fluttertoast.dart';
import 'package:google_api_availability/google_api_availability.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
@ -22,6 +23,8 @@ import 'package:hmg_patient_app_new/widgets/loading_dialog.dart';
import 'package:lottie/lottie.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'dart:math' as dartMath;
class Utils {
static AppState appState = getIt.get<AppState>();
static NavigationService navigationService = getIt.get<NavigationService>();
@ -346,6 +349,34 @@ class Utils {
return isVidaPlus;
}
static ProjectDetailListModel getProjectDetailObj(AppState appState, int projectID) {
ProjectDetailListModel projectDetailListModel = ProjectDetailListModel();
for (var element in appState.projectDetailListModel) {
if (element.projectID == projectID) {
projectDetailListModel = element;
}
}
return projectDetailListModel;
}
static double distance(double lat1, double lon1, double lat2, double lon2) {
const r = 6372.8; // Earth radius in kilometers
final dLat = _toRadians(lat2 - lat1);
final dLon = _toRadians(lon2 - lon1);
final lat1Radians = _toRadians(lat1);
final lat2Radians = _toRadians(lat2);
final a = _haversin(dLat) + dartMath.cos(lat1Radians) * dartMath.cos(lat2Radians) * _haversin(dLon);
final c = 2 * dartMath.asin(dartMath.sqrt(a));
return r * c;
}
static double _toRadians(double degrees) => degrees * dartMath.pi / 180;
static num _haversin(double radians) => dartMath.pow(dartMath.sin(radians / 2), 2);
static getPhoneNumberWithoutZero(String number) {
String newNumber = "";
if (number.startsWith('0')) {

@ -4,12 +4,15 @@ import 'package:dartz/dartz.dart';
import 'package:hmg_patient_app_new/core/api/api_client.dart';
import 'package:hmg_patient_app_new/core/api_consts.dart';
import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/PrivilegeModel.dart';
import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart';
import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_activation_code_register_request_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/select_device_by_imei.dart';
import 'package:hmg_patient_app_new/services/logger_service.dart';
abstract class AuthenticationRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> getServicePrivilege();
Future<Either<Failure, GenericApiModel<SelectDeviceByImeiRespModelElement>>> selectDeviceByImei({required String firebaseToken});
Future<Either<Failure, GenericApiModel<dynamic>>> checkPatientAuthentication({required dynamic checkPatientAuthenticationReq});
@ -32,7 +35,6 @@ abstract class AuthenticationRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> insertPatientIMEIData({required dynamic patientIMEIDataRequest});
Future<Either<Failure, GenericApiModel<dynamic>>> insertPatientDeviceData({required dynamic patientDeviceDataRequest});
}
class AuthenticationRepoImp implements AuthenticationRepo {
@ -390,7 +392,6 @@ class AuthenticationRepoImp implements AuthenticationRepo {
@override
Future<Either<Failure, GenericApiModel>> insertPatientDeviceData({required patientDeviceDataRequest}) {
try {
GenericApiModel<dynamic>? apiResponse;
Failure? failure;
@ -421,4 +422,38 @@ class AuthenticationRepoImp implements AuthenticationRepo {
return Future.value(Left(UnknownFailure(e.toString())));
}
}
@override
Future<Either<Failure, GenericApiModel<dynamic>>> getServicePrivilege() {
Map<String, dynamic> mapDevice = {};
try {
GenericApiModel<dynamic>? apiResponse;
Failure? failure;
return apiClient.post(
ApiConsts.getPrivileges,
body: mapDevice,
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
apiResponse = GenericApiModel<dynamic>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: errorMessage,
data: response,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
}
},
).then((_) {
if (failure != null) return Left(failure!);
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
return Right(apiResponse!);
});
} catch (e) {
return Future.value(Left(UnknownFailure(e.toString())));
}
}
}

@ -6,6 +6,10 @@ import 'package:hijri_gregorian_calendar/hijri_gregorian_calendar.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/cache_consts.dart';
import 'package:hmg_patient_app_new/core/common_models/nationality_country_model.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/HMCProjectListModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/PrivilegeModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/VidaPlusProjectListModel.dart';
import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
import 'package:hmg_patient_app_new/core/utils/request_utils.dart';
@ -53,7 +57,11 @@ class AuthenticationViewModel extends ChangeNotifier {
_authenticationRepo = authenticationRepo,
_localAuthService = localAuthService;
final TextEditingController nationalIdController = TextEditingController(), phoneNumberController = TextEditingController(), dobController = TextEditingController(), nameController = TextEditingController(), emailController = TextEditingController();
final TextEditingController nationalIdController = TextEditingController(),
phoneNumberController = TextEditingController(),
dobController = TextEditingController(),
nameController = TextEditingController(),
emailController = TextEditingController();
CountryEnum selectedCountrySignup = CountryEnum.saudiArabia;
MaritalStatusTypeEnum? maritalStatus;
GenderTypeEnum? genderType;
@ -366,18 +374,18 @@ class AuthenticationViewModel extends ChangeNotifier {
required Function(String? message) onWrongActivationCode,
}) async {
final request = RequestUtils.getCommonRequestWelcome(
phoneNumber: phoneNumberController.text,
otpTypeEnum: otpTypeEnum,
deviceToken: _appState.deviceToken,
patientOutSA: true,
loginTokenID: _appState.appAuthToken,
registeredData: null,
nationIdText: nationalIdController.text,
countryCode: selectedCountrySignup.countryCode,
loginType: loginTypeEnum.toInt
).toJson();
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
phoneNumber: phoneNumberController.text,
otpTypeEnum: otpTypeEnum,
deviceToken: _appState.deviceToken,
patientOutSA: true,
loginTokenID: _appState.appAuthToken,
registeredData: null,
nationIdText: nationalIdController.text,
countryCode: selectedCountrySignup.countryCode,
loginType: loginTypeEnum.toInt)
.toJson();
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
if (isForRegister) {
if (_appState.getUserRegistrationPayload.patientOutSa == true) request['DOB'] = _appState.getUserRegistrationPayload.dob;
request['HealthId'] = _appState.getUserRegistrationPayload.healthId;
@ -514,12 +522,12 @@ class AuthenticationViewModel extends ChangeNotifier {
_localAuthService.authenticate().then((value) async {
if (value) {
// we have to handle this if verification true;
if(!_appState.isAuthenticated) {
if (!_appState.isAuthenticated) {
loginTypeEnum = (_appState.deviceTypeID == 1 ? LoginTypeEnum.face : LoginTypeEnum.fingerprint);
print(loginTypeEnum);
checkActivationCode(otpTypeEnum:OTPTypeEnum.faceIDFingerprint , activationCode: null, onWrongActivationCode: (String? message) {});
checkActivationCode(otpTypeEnum: OTPTypeEnum.faceIDFingerprint, activationCode: null, onWrongActivationCode: (String? message) {});
insertPatientIMEIData((_appState.deviceTypeID == 1 ? LoginTypeEnum.face.toInt : LoginTypeEnum.fingerprint.toInt));
}else {
} else {
// authenticated = true;
insertPatientIMEIData((_appState.deviceTypeID == 1 ? LoginTypeEnum.face.toInt : LoginTypeEnum.fingerprint.toInt));
}
@ -535,20 +543,19 @@ class AuthenticationViewModel extends ChangeNotifier {
checkLastLoginStatus(Function() onSuccess) async {
Future.delayed(Duration(seconds: 1), () {
if (_appState.getSelectDeviceByImeiRespModelElement != null &&
(_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) {
phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0")
? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "")
: _appState.getAuthenticatedUser()!.mobileNumber)!;
if (_appState.getSelectDeviceByImeiRespModelElement != null &&
(_appState.getSelectDeviceByImeiRespModelElement!.logInType == 1 || _appState.getSelectDeviceByImeiRespModelElement!.logInType == 4)) {
phoneNumberController.text =
(_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!;
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
onSuccess();
} else if((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) && _appState.getAuthenticatedUser() != null){
phoneNumberController.text = (_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0")
? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "")
: _appState.getAuthenticatedUser()!.mobileNumber)!;
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
onSuccess();
}
} else if ((loginTypeEnum == LoginTypeEnum.sms || loginTypeEnum == LoginTypeEnum.whatsapp && _appState.getSelectDeviceByImeiRespModelElement == null) &&
_appState.getAuthenticatedUser() != null) {
phoneNumberController.text =
(_appState.getAuthenticatedUser()!.mobileNumber!.startsWith("0") ? _appState.getAuthenticatedUser()!.mobileNumber!.replaceFirst("0", "") : _appState.getAuthenticatedUser()!.mobileNumber)!;
nationalIdController.text = _appState.getAuthenticatedUser()!.nationalityId!;
onSuccess();
}
});
}
@ -583,9 +590,7 @@ class AuthenticationViewModel extends ChangeNotifier {
});
}
Future<void> onRegistrationComplete() async{
Future<void> onRegistrationComplete() async {
// if (emailAddress.text.isEmpty) {
// Utils.showErrorToast(TranslationBase.of(context).enterEmailAddress);
// return;
@ -596,7 +601,6 @@ class AuthenticationViewModel extends ChangeNotifier {
//authVM!.clearDefaultInputValues();
}
Future<void> checkUserStatusForRegistration({required dynamic response, required dynamic request}) async {
if (response is Map) {
_appState.setAppAuthToken = response["LogInTokenID"];
@ -703,22 +707,52 @@ class AuthenticationViewModel extends ChangeNotifier {
_appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(request);
}
Future<void> insertPatientIMEIData(int loginType) async{
final resultEither = await _authenticationRepo.insertPatientIMEIData(patientIMEIDataRequest: PatientInsertDeviceImei(imei: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientIdentificationNo:_appState.getAuthenticatedUser()!.nationalityId!, firstName: _appState.getAuthenticatedUser()!.firstName!, lastName: _appState.getAuthenticatedUser()!.lastName!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, mobileNo:_appState.getAuthenticatedUser()!.mobileNumber!, logInTypeId: loginType, patientOutSa:_appState.getAuthenticatedUser()!.outSa!, outSa: _appState.getAuthenticatedUser()!.outSa == 1 ? true :false, biometricEnabled: loginType == 1 || loginType ==2 ? false :true, firstNameN:_appState.getAuthenticatedUser()!.firstNameN , lastNameN:_appState.getAuthenticatedUser()!.lastNameN ).toJson());
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.messageStatus == 1) {
log("Insert IMEI Success");
insertPatientDeviceData( loginType);
} else {
log("Insert IMEI Failed");
}
});
}
Future<void> insertPatientDeviceData(int loginType) async{
Future<void> insertPatientIMEIData(int loginType) async {
final resultEither = await _authenticationRepo.insertPatientIMEIData(
patientIMEIDataRequest: PatientInsertDeviceImei(
imei: _appState.deviceToken,
deviceTypeId: _appState.getDeviceTypeID(),
patientId: _appState.getAuthenticatedUser()!.patientId!,
patientIdentificationNo: _appState.getAuthenticatedUser()!.patientIdentificationNo!,
firstName: _appState.getAuthenticatedUser()!.firstName!,
lastName: _appState.getAuthenticatedUser()!.lastName!,
patientTypeId: _appState.getAuthenticatedUser()!.patientType,
mobileNo: _appState.getAuthenticatedUser()!.mobileNumber!,
logInTypeId: loginType,
patientOutSa: _appState.getAuthenticatedUser()!.outSa!,
outSa: _appState.getAuthenticatedUser()!.outSa == 1 ? true : false,
biometricEnabled: loginType == 1 || loginType == 2 ? false : true,
firstNameN: _appState.getAuthenticatedUser()!.firstNameN,
lastNameN: _appState.getAuthenticatedUser()!.lastNameN,
).toJson());
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.messageStatus == 1) {
log("Insert IMEI Success");
insertPatientDeviceData(loginType);
} else {
log("Insert IMEI Failed");
}
});
}
final resultEither = await _authenticationRepo.insertPatientDeviceData(patientDeviceDataRequest: InsertPatientMobileDeviceInfo(deviceToken: _appState.deviceToken, deviceTypeId: _appState.getDeviceTypeID(), patientId: _appState.getAuthenticatedUser()!.patientId!, patientTypeId: _appState.getAuthenticatedUser()!.patientType, patientOutSa:_appState.getAuthenticatedUser()!.outSa!, loginType: loginType, languageId: _appState.getLanguageID(), latitude: _appState.userLat, longitude:_appState.userLong, voipToken: "", deviceType: _appState.deviceTypeID, patientMobileNumber:_appState.getAuthenticatedUser()!.mobileNumber, nationalId: _appState.getAuthenticatedUser()!.patientIdentificationNo, gender: _appState.getAuthenticatedUser()!.gender ).toJson());
Future<void> insertPatientDeviceData(int loginType) async {
final resultEither = await _authenticationRepo.insertPatientDeviceData(
patientDeviceDataRequest: InsertPatientMobileDeviceInfo(
deviceToken: _appState.deviceToken,
deviceTypeId: _appState.getDeviceTypeID(),
patientId: _appState.getAuthenticatedUser()!.patientId!,
patientTypeId: _appState.getAuthenticatedUser()!.patientType,
patientOutSa: _appState.getAuthenticatedUser()!.outSa!,
loginType: loginType,
languageId: _appState.getLanguageID(),
latitude: _appState.userLat,
longitude: _appState.userLong,
voipToken: "",
deviceType: _appState.deviceTypeID,
patientMobileNumber: _appState.getAuthenticatedUser()!.mobileNumber,
nationalId: _appState.getAuthenticatedUser()!.patientIdentificationNo,
gender: _appState.getAuthenticatedUser()!.gender)
.toJson());
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.messageStatus == 1) {
log("Insert Device Data Success");
@ -726,7 +760,6 @@ class AuthenticationViewModel extends ChangeNotifier {
log("Insert IMEI Failed");
}
});
}
@override
@ -736,4 +769,41 @@ class AuthenticationViewModel extends ChangeNotifier {
myFocusNode.dispose();
super.dispose();
}
Future<void> getServicePrivilege() async {
final resultEither = await _authenticationRepo.getServicePrivilege();
List<PrivilegeModel> privilegeModelList = [];
List<VidaPlusProjectListModel> vidaPlusProjectListModel = [];
List<HMCProjectListModel> hMCProjectListModel = [];
List<ProjectDetailListModel> projectDetailListModel = [];
resultEither.fold(
(failure) async => await _errorHandlerService.handleError(failure: failure),
(apiResponse) async {
if (apiResponse.messageStatus == 2) {
await _dialogService.showErrorBottomSheet(message: apiResponse.errorMessage ?? "ErrorEmpty");
} else {
apiResponse.data["ServicePrivilegeList"].forEach((v) {
privilegeModelList.add(PrivilegeModel.fromJson(v));
});
_appState.setPrivilegeModelList(privilegeModelList);
apiResponse.data["ProjectListVidaPlus"].forEach((v) {
vidaPlusProjectListModel.add(VidaPlusProjectListModel.fromJson(v));
});
_appState.setVidaPlusProjectList(vidaPlusProjectListModel);
apiResponse.data["HMCProjectList"].forEach((v) {
hMCProjectListModel.add(HMCProjectListModel.fromJson(v));
});
_appState.setHMCProjectList(hMCProjectListModel);
apiResponse.data["ProjectDetailList"].forEach((v) {
projectDetailListModel.add(ProjectDetailListModel.fromJson(v));
});
_appState.setProjectsDetailList(projectDetailListModel);
}
},
);
}
}

@ -2,6 +2,10 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_nfc_kit/flutter_nfc_kit.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/location_util.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
@ -25,8 +29,12 @@ class AppointmentCheckinBottomSheet extends StatelessWidget {
bool _supportsNFC = false;
late LocationUtils locationUtils;
ProjectDetailListModel projectDetailListModel = ProjectDetailListModel();
@override
Widget build(BuildContext context) {
AppState _appState = getIt.get<AppState>();
FlutterNfcKit.nfcAvailability.then((value) {
_supportsNFC = (value == NFCAvailability.available);
});
@ -38,7 +46,25 @@ class AppointmentCheckinBottomSheet extends StatelessWidget {
"Live Location".needTranslation,
"Verify your location to be at hospital to check in".needTranslation,
).onPress(() {
Navigator.of(context).pop();
// locationUtils = LocationUtils(
// isShowConfirmDialog: false,
// navigationService: myAppointmentsViewModel.navigationService,
// appState: myAppointmentsViewModel.appState,
// );
locationUtils.getCurrentLocation(callBack: (value) {
projectDetailListModel = Utils.getProjectDetailObj(_appState, patientAppointmentHistoryResponseModel.projectID);
double dist = Utils.distance(value.latitude, value.longitude, double.parse(projectDetailListModel.latitude!), double.parse(projectDetailListModel.longitude!)).ceilToDouble() * 1000;
print(dist);
if (dist <= projectDetailListModel.geofenceRadius!) {
sendCheckInRequest(projectDetailListModel.checkInQrCode!, context);
} else {
showCommonBottomSheetWithoutHeight(context,
title: "Error".needTranslation,
child: Utils.getErrorWidget(loadingText: "Please ensure you're within the hospital location to perform online check-in.".needTranslation), callBackFunc: () {
Navigator.of(context).pop();
}, isFullScreen: false);
}
});
}),
SizedBox(height: 16.h),
checkInOptionCard(

@ -122,7 +122,7 @@ class _QuickLogin extends State<QuickLogin> {
child: CustomButton(
text: LocaleKeys.notNow.tr(),
onPressed: () {
Navigator.pop(context, true);
Navigator.pop(context, "true");
},
backgroundColor: Color(0xffFEE9EA),
borderColor: Color(0xffFEE9EA),

@ -34,13 +34,17 @@ class _SavedLogin extends State<SavedLogin> {
void initState() {
authVm = context.read<AuthenticationViewModel>();
appState = getIt.get<AppState>();
loginType = LoginTypeExtension.fromValue(appState.getSelectDeviceByImeiRespModelElement!.logInType!)!;
loginType = LoginTypeExtension.fromValue(appState.getSelectDeviceByImeiRespModelElement!.logInType!)!;
authVm.phoneNumberController.text = appState.getSelectDeviceByImeiRespModelElement!.mobile!.startsWith("0")
? appState.getSelectDeviceByImeiRespModelElement!.mobile!.replaceFirst("0", "")
: appState.getSelectDeviceByImeiRespModelElement!.mobile!;
authVm.nationalIdController.text = appState.getSelectDeviceByImeiRespModelElement!.identificationNo!;
if (loginType == LoginTypeEnum.fingerprint || loginType == LoginTypeEnum.face) {
authVm.loginWithFingerPrintFace();
}
super.initState();
}
@ -80,8 +84,7 @@ class _SavedLogin extends State<SavedLogin> {
children: [
// Last login info
("${LocaleKeys.lastloginBy.tr()} ${loginType.displayName}")
.toText14(isBold: true, color: AppColors.greyTextColor),
("${LocaleKeys.lastloginBy.tr()} ${loginType.displayName}").toText14(isBold: true, color: AppColors.greyTextColor),
(appState.getSelectDeviceByImeiRespModelElement!.createdOn != null
? DateUtil.getFormattedDate(DateUtil.convertStringToDate(appState.getSelectDeviceByImeiRespModelElement!.createdOn!), "d MMMM, y 'at' HH:mm")
: '--')
@ -89,7 +92,8 @@ class _SavedLogin extends State<SavedLogin> {
Container(
margin: EdgeInsets.all(16.h),
child: Utils.buildSvgWithAssets(icon: getTypeIcons(appState.getSelectDeviceByImeiRespModelElement!.logInType!), height: 54, width: 54, iconColor: loginType.toInt == 4 ? null : AppColors.primaryRedColor)),
child: Utils.buildSvgWithAssets(
icon: getTypeIcons(appState.getSelectDeviceByImeiRespModelElement!.logInType!), height: 54, width: 54, iconColor: loginType.toInt == 4 ? null : AppColors.primaryRedColor)),
// Face ID login button
SizedBox(
height: 45,
@ -232,7 +236,6 @@ class _SavedLogin extends State<SavedLogin> {
textColor: Color(0xFF2E3039),
borderWidth: 2,
padding: EdgeInsets.fromLTRB(0, 14, 0, 14),
),
const Spacer(flex: 2),
// OR divider

@ -42,7 +42,7 @@ class _LandingPageState extends State<LandingPage> {
authVM.savePushTokenToAppState();
if (mounted) {
authVM.checkLastLoginStatus(() {
showQuickLogin(context, false);
showQuickLogin(context, false);
});
}
super.initState();
@ -326,19 +326,17 @@ class _LandingPageState extends State<LandingPage> {
context,
title: "",
child: QuickLogin(
isDone: isDone,
isDone: isDone,
onPressed: () {
// sharedPref.setBool(HAS_ENABLED_QUICK_LOGIN, true);
authVM.loginWithFingerPrintFace();
},
),
height:isDone == false ? ResponsiveExtension.screenHeight * 0.5 : ResponsiveExtension.screenHeight * 0.3,
height: isDone == false ? ResponsiveExtension.screenHeight * 0.5 : ResponsiveExtension.screenHeight * 0.3,
isFullScreen: false,
callBackFunc: (str) {
isDone = true;
setState(() {
});
setState(() {});
},
);
}

@ -9,6 +9,8 @@ import 'package:flutter_zoom_videosdk/native/zoom_videosdk.dart';
import 'package:hmg_patient_app_new/core/api_consts.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
// import 'package:hmg_patient_app_new/presentation/authantication/login.dart';
import 'package:hmg_patient_app_new/presentation/home/landing_page.dart';
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
@ -26,6 +28,8 @@ class SplashPage extends StatefulWidget {
}
class _SplashScreenState extends State<SplashPage> {
late AuthenticationViewModel authVm;
Future<void> initializeStuff() async {
Timer(
Duration(milliseconds: 500),
@ -34,7 +38,8 @@ class _SplashScreenState extends State<SplashPage> {
PushNotificationHandler().init(context); // Asyncronously
},
);
Timer(Duration(seconds: 3, milliseconds: 500), () async {
await authVm.getServicePrivilege();
Timer(Duration(seconds: 2, milliseconds: 500), () async {
LocalNotification.init(onNotificationClick: (payload) {});
Navigator.of(context).pushReplacement(
FadePage(
@ -51,8 +56,6 @@ class _SplashScreenState extends State<SplashPage> {
zoom.initSdk(initConfig);
}
/// load the Privilege from service
Future loadPrivilege() async {
// ProjectViewModel projectProvider = Provider.of<ProjectViewModel>(context, listen: false);
@ -71,9 +74,9 @@ class _SplashScreenState extends State<SplashPage> {
PushNotificationHandler().init(context); // Asyncronously
}
@override
void initState() {
authVm = context.read<AuthenticationViewModel>();
super.initState();
initializeStuff();
}
@ -87,8 +90,7 @@ class _SplashScreenState extends State<SplashPage> {
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 53),
child: Image.asset(AppAssets.hmg_logo,
fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width),
child: Image.asset(AppAssets.hmg_logo, fit: BoxFit.fitWidth, width: MediaQuery.of(context).size.width),
),
Align(
alignment: Alignment.bottomCenter,
@ -97,18 +99,12 @@ class _SplashScreenState extends State<SplashPage> {
children: [
Text(
"Powered by",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: AppColors.textColor,
letterSpacing: -0.56,
height: 16 / 14),
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: AppColors.textColor, letterSpacing: -0.56, height: 16 / 14),
),
SizedBox(
height: 5,
),
Utils.buildSvgWithAssets(
icon: AppAssets.cloud_logo, width: 40, height: 40),
Utils.buildSvgWithAssets(icon: AppAssets.cloud_logo, width: 40, height: 40),
SizedBox(height: 7),
// Text(
// "Version 1.1.0",

Loading…
Cancel
Save