commit
43d64b761c
@ -0,0 +1,108 @@
|
||||
class EROnlineCheckInPaymentDetailsResponse {
|
||||
num? cashPrice;
|
||||
num? cashPriceTax;
|
||||
num? cashPriceWithTax;
|
||||
int? companyId;
|
||||
String? companyName;
|
||||
num? companyShareWithTax;
|
||||
dynamic errCode;
|
||||
int? groupID;
|
||||
String? insurancePolicyNo;
|
||||
String? message;
|
||||
String? patientCardID;
|
||||
num? patientShare;
|
||||
num? patientShareWithTax;
|
||||
num? patientTaxAmount;
|
||||
int? policyId;
|
||||
String? policyName;
|
||||
String? procedureId;
|
||||
String? procedureName;
|
||||
dynamic setupID;
|
||||
int? statusCode;
|
||||
String? subPolicyNo;
|
||||
bool? isCash;
|
||||
bool? isEligible;
|
||||
bool? isInsured;
|
||||
|
||||
EROnlineCheckInPaymentDetailsResponse(
|
||||
{this.cashPrice,
|
||||
this.cashPriceTax,
|
||||
this.cashPriceWithTax,
|
||||
this.companyId,
|
||||
this.companyName,
|
||||
this.companyShareWithTax,
|
||||
this.errCode,
|
||||
this.groupID,
|
||||
this.insurancePolicyNo,
|
||||
this.message,
|
||||
this.patientCardID,
|
||||
this.patientShare,
|
||||
this.patientShareWithTax,
|
||||
this.patientTaxAmount,
|
||||
this.policyId,
|
||||
this.policyName,
|
||||
this.procedureId,
|
||||
this.procedureName,
|
||||
this.setupID,
|
||||
this.statusCode,
|
||||
this.subPolicyNo,
|
||||
this.isCash,
|
||||
this.isEligible,
|
||||
this.isInsured});
|
||||
|
||||
EROnlineCheckInPaymentDetailsResponse.fromJson(Map<String, dynamic> json) {
|
||||
cashPrice = json['CashPrice'];
|
||||
cashPriceTax = json['CashPriceTax'];
|
||||
cashPriceWithTax = json['CashPriceWithTax'];
|
||||
companyId = json['CompanyId'];
|
||||
companyName = json['CompanyName'];
|
||||
companyShareWithTax = json['CompanyShareWithTax'];
|
||||
errCode = json['ErrCode'];
|
||||
groupID = json['GroupID'];
|
||||
insurancePolicyNo = json['InsurancePolicyNo'];
|
||||
message = json['Message'];
|
||||
patientCardID = json['PatientCardID'];
|
||||
patientShare = json['PatientShare'];
|
||||
patientShareWithTax = json['PatientShareWithTax'];
|
||||
patientTaxAmount = json['PatientTaxAmount'];
|
||||
policyId = json['PolicyId'];
|
||||
policyName = json['PolicyName'];
|
||||
procedureId = json['ProcedureId'];
|
||||
procedureName = json['ProcedureName'];
|
||||
setupID = json['SetupID'];
|
||||
statusCode = json['StatusCode'];
|
||||
subPolicyNo = json['SubPolicyNo'];
|
||||
isCash = json['IsCash'];
|
||||
isEligible = json['IsEligible'];
|
||||
isInsured = json['IsInsured'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['CashPrice'] = this.cashPrice;
|
||||
data['CashPriceTax'] = this.cashPriceTax;
|
||||
data['CashPriceWithTax'] = this.cashPriceWithTax;
|
||||
data['CompanyId'] = this.companyId;
|
||||
data['CompanyName'] = this.companyName;
|
||||
data['CompanyShareWithTax'] = this.companyShareWithTax;
|
||||
data['ErrCode'] = this.errCode;
|
||||
data['GroupID'] = this.groupID;
|
||||
data['InsurancePolicyNo'] = this.insurancePolicyNo;
|
||||
data['Message'] = this.message;
|
||||
data['PatientCardID'] = this.patientCardID;
|
||||
data['PatientShare'] = this.patientShare;
|
||||
data['PatientShareWithTax'] = this.patientShareWithTax;
|
||||
data['PatientTaxAmount'] = this.patientTaxAmount;
|
||||
data['PolicyId'] = this.policyId;
|
||||
data['PolicyName'] = this.policyName;
|
||||
data['ProcedureId'] = this.procedureId;
|
||||
data['ProcedureName'] = this.procedureName;
|
||||
data['SetupID'] = this.setupID;
|
||||
data['StatusCode'] = this.statusCode;
|
||||
data['SubPolicyNo'] = this.subPolicyNo;
|
||||
data['IsCash'] = this.isCash;
|
||||
data['IsEligible'] = this.isEligible;
|
||||
data['IsInsured'] = this.isInsured;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,180 @@
|
||||
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/utils/size_utils.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart';
|
||||
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/emergency_services/er_online_checkin/er_online_checkin_select_checkin_bottom_sheet.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
|
||||
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/nfc/nfc_reader_sheet.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../call_ambulance/widgets/HospitalBottomSheetBody.dart';
|
||||
|
||||
class ErOnlineCheckinHome extends StatelessWidget {
|
||||
ErOnlineCheckinHome({super.key});
|
||||
|
||||
late EmergencyServicesViewModel emergencyServicesViewModel;
|
||||
bool _supportsNFC = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
emergencyServicesViewModel = Provider.of<EmergencyServicesViewModel>(context, listen: false);
|
||||
FlutterNfcKit.nfcAvailability.then((value) {
|
||||
_supportsNFC = (value == NFCAvailability.available);
|
||||
});
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.bgScaffoldColor,
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CollapsingListView(
|
||||
title: "Emergency Check-In".needTranslation,
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(24.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Utils.buildSvgWithAssets(icon: AppAssets.immediate_service_icon, width: 58.h, height: 58.h),
|
||||
SizedBox(width: 18.h),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
"Online Check-In".needTranslation.toText18(color: AppColors.textColor, isBold: true),
|
||||
"This service lets patients to register their ER appointment prior to arrival.".needTranslation.toText14(color: AppColors.greyTextColor, weight: FontWeight.w500),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
CustomButton(
|
||||
text: emergencyServicesViewModel.patientHasAdvanceERBalance ? LocaleKeys.checkinOption.tr() : LocaleKeys.bookAppo.tr(),
|
||||
onPressed: () async {
|
||||
if (emergencyServicesViewModel.patientHasAdvanceERBalance) {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
showNfcReader(context, onNcfScan: (String nfcId) {
|
||||
Future.delayed(const Duration(milliseconds: 100), () async {
|
||||
print(nfcId);
|
||||
LoaderBottomSheet.showLoader(loadingText: "Processing check-in...".needTranslation);
|
||||
await emergencyServicesViewModel.getProjectIDFromNFC(
|
||||
nfcCode: nfcId,
|
||||
onSuccess: (value) async {
|
||||
await emergencyServicesViewModel.autoGenerateInvoiceERClinic(
|
||||
projectID: value,
|
||||
onSuccess: (value) {
|
||||
LoaderBottomSheet.hideLoader();
|
||||
showCommonBottomSheetWithoutHeight(context,
|
||||
title: LocaleKeys.onlineCheckIn.tr(),
|
||||
child: Utils.getSuccessWidget(loadingText: "Your ER Online Check-In has been successfully done. Please proceed to the waiting area.".needTranslation),
|
||||
callBackFunc: () {
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
CustomPageRoute(
|
||||
page: LandingNavigation(),
|
||||
),
|
||||
(r) => false);
|
||||
}, isFullScreen: false);
|
||||
},
|
||||
onError: (errMessage) {
|
||||
LoaderBottomSheet.hideLoader();
|
||||
showCommonBottomSheetWithoutHeight(
|
||||
context,
|
||||
child: Utils.getErrorWidget(loadingText: "Unexpected error occurred during check-in. Please contact support.".needTranslation),
|
||||
callBackFunc: () {},
|
||||
isFullScreen: false,
|
||||
isCloseButtonVisible: true,
|
||||
);
|
||||
});
|
||||
},
|
||||
onError: (err) {});
|
||||
});
|
||||
}, onCancel: () {});
|
||||
});
|
||||
// showCommonBottomSheetWithoutHeight(context,
|
||||
// title: LocaleKeys.onlineCheckIn.tr(),
|
||||
// child: ErOnlineCheckinSelectCheckinBottomSheet(
|
||||
// projectID: 15,
|
||||
// ),
|
||||
// callBackFunc: () {},
|
||||
// isFullScreen: false);
|
||||
} else {
|
||||
LoaderBottomSheet.showLoader(loadingText: "Fetching hospitals list...".needTranslation);
|
||||
await context.read<EmergencyServicesViewModel>().getProjects();
|
||||
LoaderBottomSheet.hideLoader();
|
||||
//Project Selection Dropdown
|
||||
showHospitalBottomSheet(context);
|
||||
}
|
||||
},
|
||||
backgroundColor: emergencyServicesViewModel.patientHasAdvanceERBalance ? AppColors.alertColor : AppColors.primaryRedColor,
|
||||
borderColor: emergencyServicesViewModel.patientHasAdvanceERBalance ? AppColors.alertColor : AppColors.primaryRedColor,
|
||||
textColor: AppColors.whiteColor,
|
||||
fontSize: 16.f,
|
||||
fontWeight: FontWeight.w500,
|
||||
borderRadius: 10.r,
|
||||
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
height: 50.h,
|
||||
icon: emergencyServicesViewModel.patientHasAdvanceERBalance ? AppAssets.appointment_checkin_icon : AppAssets.bookAppoBottom,
|
||||
iconColor: AppColors.whiteColor,
|
||||
iconSize: 18.h,
|
||||
).paddingSymmetrical(24.h, 24.h),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
showHospitalBottomSheet(BuildContext context) {
|
||||
showCommonBottomSheetWithoutHeight(
|
||||
title: LocaleKeys.selectHospital.tr(),
|
||||
context,
|
||||
child: Consumer<EmergencyServicesViewModel>(
|
||||
builder: (_, vm, __) => HospitalBottomSheetBody(
|
||||
displayList: vm.displayList,
|
||||
onFacilityClicked: (value) {
|
||||
vm.setSelectedFacility(value);
|
||||
vm.getDisplayList();
|
||||
},
|
||||
onHospitalClicked: (hospital) async {
|
||||
Navigator.pop(context);
|
||||
vm.setSelectedHospital(hospital);
|
||||
LoaderBottomSheet.showLoader(loadingText: "Fetching payment information...".needTranslation);
|
||||
await vm.getPatientERPaymentInformation(onSuccess: (response) {
|
||||
LoaderBottomSheet.hideLoader();
|
||||
vm.navigateToEROnlineCheckInPaymentPage();
|
||||
});
|
||||
},
|
||||
onHospitalSearch: (value) {
|
||||
vm.searchHospitals(value ?? "");
|
||||
},
|
||||
selectedFacility: vm.selectedFacility,
|
||||
hmcCount: vm.hmcCount,
|
||||
hmgCount: vm.hmgCount,
|
||||
),
|
||||
),
|
||||
isFullScreen: false,
|
||||
isCloseButtonVisible: true,
|
||||
hasBottomPadding: false,
|
||||
backgroundColor: AppColors.bottomSheetBgColor,
|
||||
callBackFunc: () {},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,177 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.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/dependencies.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/date_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';
|
||||
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart';
|
||||
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/appointments/my_appointments_page.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/emergency_services/er_online_checkin/er_online_checkin_payment_page.dart';
|
||||
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ErOnlineCheckinPaymentDetailsPage extends StatelessWidget {
|
||||
ErOnlineCheckinPaymentDetailsPage({super.key});
|
||||
|
||||
late AppState appState;
|
||||
late EmergencyServicesViewModel emergencyServicesViewModel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
appState = getIt.get<AppState>();
|
||||
emergencyServicesViewModel = Provider.of<EmergencyServicesViewModel>(context, listen: false);
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.bgScaffoldColor,
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CollapsingListView(
|
||||
title: "Emergency Check-In".needTranslation,
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(24.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 20.h,
|
||||
hasShadow: true,
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(14.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
"ER Visit Details".needTranslation.toText18(color: AppColors.textColor, isBold: true),
|
||||
SizedBox(height: 24.h),
|
||||
Row(
|
||||
children: [
|
||||
"${appState.getAuthenticatedUser()!.firstName!} ${appState.getAuthenticatedUser()!.lastName!}".toText14(color: AppColors.textColor, isBold: true),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 12.h),
|
||||
Wrap(
|
||||
direction: Axis.horizontal,
|
||||
spacing: 6.w,
|
||||
runSpacing: 6.h,
|
||||
children: [
|
||||
AppCustomChipWidget(
|
||||
labelText: "File No.: ${appState.getAuthenticatedUser()!.patientId!.toString()}",
|
||||
labelPadding: EdgeInsetsDirectional.only(start: 4.w, end: 4.w),
|
||||
),
|
||||
AppCustomChipWidget(
|
||||
labelText: "ER Clinic".needTranslation,
|
||||
labelPadding: EdgeInsetsDirectional.only(start: 4.w, end: 4.w),
|
||||
),
|
||||
AppCustomChipWidget(
|
||||
labelText: emergencyServicesViewModel.selectedHospital!.name,
|
||||
labelPadding: EdgeInsetsDirectional.only(start: 4.w, end: 4.w),
|
||||
),
|
||||
AppCustomChipWidget(
|
||||
icon: AppAssets.calendar,
|
||||
labelText: DateUtil.formatDateToDate(DateTime.now(), false),
|
||||
labelPadding: EdgeInsetsDirectional.only(start: 4.w, end: 4.w),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 12.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 24.r,
|
||||
hasShadow: true,
|
||||
),
|
||||
child: SizedBox(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
"Amount before tax".needTranslation.toText18(isBold: true),
|
||||
Utils.getPaymentAmountWithSymbol(emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShare.toString().toText16(isBold: true), AppColors.blackColor, 13,
|
||||
isSaudiCurrency: true),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 4.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: "".toText12(fontWeight: FontWeight.w500, color: AppColors.greyTextColor)),
|
||||
"VAT 15% (${emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientTaxAmount})"
|
||||
.needTranslation
|
||||
.toText14(isBold: true, color: AppColors.greyTextColor, letterSpacing: -1),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 18.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 150.h,
|
||||
child: Utils.getPaymentMethods(),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Utils.getPaymentAmountWithSymbol(
|
||||
emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax.toString().toText24(isBold: true), AppColors.blackColor, 17,
|
||||
isSaudiCurrency: true),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
).paddingOnly(left: 16.h, top: 24.h, right: 16.h, bottom: 0.h),
|
||||
CustomButton(
|
||||
text: LocaleKeys.payNow.tr(),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
CustomPageRoute(page: ErOnlineCheckinPaymentPage()),
|
||||
);
|
||||
},
|
||||
backgroundColor: AppColors.infoColor,
|
||||
borderColor: AppColors.infoColor.withOpacity(0.01),
|
||||
textColor: AppColors.whiteColor,
|
||||
fontSize: 16.f,
|
||||
fontWeight: FontWeight.w500,
|
||||
borderRadius: 12.r,
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
height: 56.h,
|
||||
icon: AppAssets.appointment_pay_icon,
|
||||
iconColor: AppColors.whiteColor,
|
||||
iconSize: 18.h,
|
||||
).paddingSymmetrical(16.h, 24.h),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,510 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.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/cache_consts.dart';
|
||||
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
||||
import 'package:hmg_patient_app_new/core/enums.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';
|
||||
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart';
|
||||
import 'package:hmg_patient_app_new/features/payfort/models/apple_pay_request_insert_model.dart';
|
||||
import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart';
|
||||
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/insurance/insurance_home_page.dart';
|
||||
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/in_app_browser/InAppBrowser.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:smooth_corner/smooth_corner.dart';
|
||||
|
||||
class ErOnlineCheckinPaymentPage extends StatefulWidget {
|
||||
ErOnlineCheckinPaymentPage({super.key});
|
||||
|
||||
@override
|
||||
State<ErOnlineCheckinPaymentPage> createState() => _ErOnlineCheckinPaymentPageState();
|
||||
}
|
||||
|
||||
class _ErOnlineCheckinPaymentPageState extends State<ErOnlineCheckinPaymentPage> {
|
||||
late PayfortViewModel payfortViewModel;
|
||||
late EmergencyServicesViewModel emergencyServicesViewModel;
|
||||
|
||||
late AppState appState;
|
||||
|
||||
MyInAppBrowser? browser;
|
||||
|
||||
String selectedPaymentMethod = "";
|
||||
|
||||
String transID = "";
|
||||
|
||||
bool isShowTamara = false;
|
||||
|
||||
String tamaraPaymentStatus = "";
|
||||
|
||||
String tamaraOrderID = "";
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
scheduleMicrotask(() {
|
||||
payfortViewModel.initPayfortViewModel();
|
||||
// payfortViewModel.getTamaraInstallmentsDetails().then((val) {
|
||||
// if (emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax! >= payfortViewModel.getTamaraInstallmentsDetailsResponseModel!.minLimit!.amount! &&
|
||||
// emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax! <= payfortViewModel.getTamaraInstallmentsDetailsResponseModel!.maxLimit!.amount!) {
|
||||
// setState(() {
|
||||
// isShowTamara = true;
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
appState = getIt.get<AppState>();
|
||||
payfortViewModel = Provider.of<PayfortViewModel>(context, listen: false);
|
||||
emergencyServicesViewModel = Provider.of<EmergencyServicesViewModel>(context, listen: false);
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.bgScaffoldColor,
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CollapsingListView(
|
||||
title: "Emergency Check-In".needTranslation,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 24.h),
|
||||
Container(
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 20.h,
|
||||
hasShadow: false,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Image.asset(AppAssets.mada, width: 72.h, height: 25.h),
|
||||
SizedBox(height: 16.h),
|
||||
"Mada".needTranslation.toText16(isBold: true),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 8.h),
|
||||
const Spacer(),
|
||||
Transform.flip(
|
||||
flipX: appState.isArabic(),
|
||||
child: Utils.buildSvgWithAssets(
|
||||
icon: AppAssets.forward_arrow_icon,
|
||||
iconColor: AppColors.blackColor,
|
||||
width: 40.h,
|
||||
height: 40.h,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingSymmetrical(16.h, 16.h),
|
||||
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
||||
selectedPaymentMethod = "MADA";
|
||||
openPaymentURL("mada");
|
||||
}),
|
||||
SizedBox(height: 16.h),
|
||||
Container(
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 20.h,
|
||||
hasShadow: false,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(AppAssets.visa, width: 50.h, height: 50.h),
|
||||
SizedBox(width: 8.h),
|
||||
Image.asset(AppAssets.Mastercard, width: 40.h, height: 40.h),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16.h),
|
||||
"Visa or Mastercard".needTranslation.toText16(isBold: true),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 8.h),
|
||||
const Spacer(),
|
||||
Transform.flip(
|
||||
flipX: appState.isArabic(),
|
||||
child: Utils.buildSvgWithAssets(
|
||||
icon: AppAssets.forward_arrow_icon,
|
||||
iconColor: AppColors.blackColor,
|
||||
width: 40.h,
|
||||
height: 40.h,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingSymmetrical(16.h, 16.h),
|
||||
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
||||
selectedPaymentMethod = "VISA";
|
||||
openPaymentURL("visa");
|
||||
}),
|
||||
SizedBox(height: 16.h),
|
||||
isShowTamara
|
||||
? Container(
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 20.h,
|
||||
hasShadow: false,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Image.asset(AppAssets.tamara_en, width: 72.h, height: 25.h),
|
||||
SizedBox(height: 16.h),
|
||||
"Tamara".needTranslation.toText16(isBold: true),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 8.h),
|
||||
const Spacer(),
|
||||
Transform.flip(
|
||||
flipX: appState.isArabic(),
|
||||
child: Utils.buildSvgWithAssets(
|
||||
icon: AppAssets.forward_arrow_icon,
|
||||
iconColor: AppColors.blackColor,
|
||||
width: 40.h,
|
||||
height: 40.h,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingSymmetrical(16.h, 16.h),
|
||||
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
||||
selectedPaymentMethod = "TAMARA";
|
||||
openPaymentURL("tamara");
|
||||
})
|
||||
: SizedBox.shrink(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 24.h,
|
||||
hasShadow: false,
|
||||
),
|
||||
child: Consumer<PayfortViewModel>(builder: (context, payfortVM, child) {
|
||||
//TODO: Need to add loading state & animation for Apple Pay Configuration
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
(emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.isCash ?? true)
|
||||
? Container(
|
||||
height: 50.h,
|
||||
decoration: ShapeDecoration(
|
||||
color: AppColors.secondaryLightRedBorderColor,
|
||||
shape: SmoothRectangleBorder(
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)),
|
||||
smoothness: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
"Insurance expired or inactive".needTranslation.toText14(color: AppColors.primaryRedColor, weight: FontWeight.w500).paddingSymmetrical(24.h, 0.h),
|
||||
CustomButton(
|
||||
text: LocaleKeys.updateInsurance.tr(context: context),
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
CustomPageRoute(
|
||||
page: InsuranceHomePage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
backgroundColor: AppColors.primaryRedColor,
|
||||
borderColor: AppColors.secondaryLightRedBorderColor,
|
||||
textColor: AppColors.whiteColor,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w500,
|
||||
borderRadius: 8,
|
||||
padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||||
height: 30.h,
|
||||
).paddingSymmetrical(24.h, 0.h),
|
||||
],
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
SizedBox(height: 24.h),
|
||||
"Total amount to pay".needTranslation.toText18(isBold: true).paddingSymmetrical(24.h, 0.h),
|
||||
SizedBox(height: 17.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
"Amount before tax".needTranslation.toText14(isBold: true),
|
||||
Utils.getPaymentAmountWithSymbol(emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShare.toString().toText16(isBold: true), AppColors.blackColor, 13,
|
||||
isSaudiCurrency: true),
|
||||
],
|
||||
).paddingSymmetrical(24.h, 0.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
"VAT 15%".needTranslation.toText14(isBold: true, color: AppColors.greyTextColor),
|
||||
Utils.getPaymentAmountWithSymbol(
|
||||
emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientTaxAmount.toString().toText14(isBold: true, color: AppColors.greyTextColor), AppColors.greyTextColor, 13,
|
||||
isSaudiCurrency: true),
|
||||
],
|
||||
).paddingSymmetrical(24.h, 0.h),
|
||||
SizedBox(height: 17.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
"".needTranslation.toText14(isBold: true),
|
||||
Utils.getPaymentAmountWithSymbol(emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax.toString().toText24(isBold: true), AppColors.blackColor, 17,
|
||||
isSaudiCurrency: true),
|
||||
],
|
||||
).paddingSymmetrical(24.h, 0.h),
|
||||
Platform.isIOS
|
||||
? Utils.buildSvgWithAssets(
|
||||
icon: AppAssets.apple_pay_button,
|
||||
width: 200.h,
|
||||
height: 80.h,
|
||||
fit: BoxFit.contain,
|
||||
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
||||
if (Utils.havePrivilege(103)) {
|
||||
startApplePay();
|
||||
} else {
|
||||
openPaymentURL("ApplePay");
|
||||
}
|
||||
})
|
||||
: SizedBox(height: 12.h),
|
||||
SizedBox(height: 12.h),
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
openPaymentURL(String paymentMethod) {
|
||||
browser = MyInAppBrowser(onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart, context: context);
|
||||
transID = Utils.getAdvancePaymentTransID(
|
||||
emergencyServicesViewModel.selectedHospital!.iD,
|
||||
appState.getAuthenticatedUser()!.patientId!,
|
||||
);
|
||||
|
||||
//TODO: Need to pass dynamic params to the payment request instead of static values
|
||||
browser?.openPaymentBrowser(
|
||||
emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!,
|
||||
"ER Online Check-In Payment",
|
||||
transID,
|
||||
emergencyServicesViewModel.selectedHospital!.iD.toString(),
|
||||
"CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com",
|
||||
selectedPaymentMethod,
|
||||
appState.getAuthenticatedUser()!.patientType.toString(),
|
||||
"${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
|
||||
appState.getAuthenticatedUser()!.patientId.toString(),
|
||||
appState.getAuthenticatedUser()!,
|
||||
browser!,
|
||||
false,
|
||||
"3",
|
||||
"",
|
||||
context,
|
||||
null,
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
"3");
|
||||
}
|
||||
|
||||
startApplePay() async {
|
||||
// showCommonBottomSheet(context,
|
||||
// child: Utils.getLoadingWidget(), callBackFunc: (str) {}, title: "", height: ResponsiveExtension.screenHeight * 0.3, isCloseButtonVisible: false, isDismissible: false, isFullScreen: false);
|
||||
LoaderBottomSheet.showLoader();
|
||||
transID = Utils.getAdvancePaymentTransID(
|
||||
emergencyServicesViewModel.selectedHospital!.iD,
|
||||
appState.getAuthenticatedUser()!.patientId!,
|
||||
);
|
||||
|
||||
ApplePayInsertRequest applePayInsertRequest = ApplePayInsertRequest();
|
||||
|
||||
await payfortViewModel.getPayfortConfigurations(serviceId: ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum(), projectId: emergencyServicesViewModel.selectedHospital!.iD);
|
||||
|
||||
applePayInsertRequest.clientRequestID = transID;
|
||||
applePayInsertRequest.clinicID = 10;
|
||||
|
||||
applePayInsertRequest.currency = appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED";
|
||||
applePayInsertRequest.customerEmail = "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com";
|
||||
applePayInsertRequest.customerID = appState.getAuthenticatedUser()!.patientId.toString();
|
||||
applePayInsertRequest.customerName = "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}";
|
||||
|
||||
applePayInsertRequest.deviceToken = await Utils.getStringFromPrefs(CacheConst.pushToken);
|
||||
applePayInsertRequest.voipToken = await Utils.getStringFromPrefs(CacheConst.voipToken);
|
||||
applePayInsertRequest.doctorID = 0;
|
||||
applePayInsertRequest.projectID = emergencyServicesViewModel.selectedHospital!.iD.toString();
|
||||
applePayInsertRequest.serviceID = ServiceTypeEnum.erOnlineCheckIn.getIdFromServiceEnum().toString();
|
||||
applePayInsertRequest.channelID = 3;
|
||||
applePayInsertRequest.patientID = appState.getAuthenticatedUser()!.patientId.toString();
|
||||
applePayInsertRequest.patientTypeID = appState.getAuthenticatedUser()!.patientType;
|
||||
applePayInsertRequest.patientOutSA = appState.getAuthenticatedUser()!.outSa;
|
||||
applePayInsertRequest.appointmentDate = null;
|
||||
applePayInsertRequest.appointmentNo = 0;
|
||||
applePayInsertRequest.orderDescription = "ER Online Check-In Payment";
|
||||
applePayInsertRequest.liveServiceID = "0";
|
||||
applePayInsertRequest.latitude = "0.0";
|
||||
applePayInsertRequest.longitude = "0.0";
|
||||
applePayInsertRequest.amount = emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!.toString();
|
||||
applePayInsertRequest.isSchedule = "0";
|
||||
applePayInsertRequest.language = appState.isArabic() ? 'ar' : 'en';
|
||||
applePayInsertRequest.languageID = appState.isArabic() ? 1 : 2;
|
||||
applePayInsertRequest.userName = appState.getAuthenticatedUser()!.patientId;
|
||||
applePayInsertRequest.responseContinueURL = "http://hmg.com/Documents/success.html";
|
||||
applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html";
|
||||
applePayInsertRequest.paymentOption = "ApplePay";
|
||||
|
||||
applePayInsertRequest.isMobSDK = true;
|
||||
applePayInsertRequest.merchantReference = transID;
|
||||
applePayInsertRequest.merchantIdentifier = payfortViewModel.payfortProjectDetailsRespModel!.merchantIdentifier;
|
||||
applePayInsertRequest.commandType = "PURCHASE";
|
||||
applePayInsertRequest.signature = payfortViewModel.payfortProjectDetailsRespModel!.signature;
|
||||
applePayInsertRequest.accessCode = payfortViewModel.payfortProjectDetailsRespModel!.accessCode;
|
||||
applePayInsertRequest.shaRequestPhrase = payfortViewModel.payfortProjectDetailsRespModel!.shaRequest;
|
||||
applePayInsertRequest.shaResponsePhrase = payfortViewModel.payfortProjectDetailsRespModel!.shaResponse;
|
||||
applePayInsertRequest.returnURL = "";
|
||||
|
||||
//TODO: Need to pass dynamic params to the Apple Pay instead of static values
|
||||
await payfortViewModel.applePayRequestInsert(applePayInsertRequest: applePayInsertRequest).then((value) {
|
||||
payfortViewModel.paymentWithApplePay(
|
||||
customerName: "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
|
||||
// customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
|
||||
customerEmail: "CustID_${appState.getAuthenticatedUser()!.patientId.toString()}@HMG.com",
|
||||
orderDescription: "Appointment Payment",
|
||||
orderAmount: double.parse(emergencyServicesViewModel.erOnlineCheckInPaymentDetailsResponse.patientShareWithTax!.toString()),
|
||||
merchantReference: transID,
|
||||
merchantIdentifier: payfortViewModel.payfortProjectDetailsRespModel!.merchantIdentifier,
|
||||
applePayAccessCode: payfortViewModel.payfortProjectDetailsRespModel!.accessCode,
|
||||
applePayShaRequestPhrase: payfortViewModel.payfortProjectDetailsRespModel!.shaRequest,
|
||||
currency: appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED",
|
||||
onFailed: (failureResult) async {
|
||||
log("failureResult: ${failureResult.message.toString()}");
|
||||
Navigator.of(context).pop();
|
||||
showCommonBottomSheetWithoutHeight(
|
||||
context,
|
||||
child: Utils.getErrorWidget(loadingText: failureResult.message.toString()),
|
||||
callBackFunc: () {},
|
||||
isFullScreen: false,
|
||||
isCloseButtonVisible: true,
|
||||
);
|
||||
},
|
||||
onSucceeded: (successResult) async {
|
||||
log("successResult: ${successResult.responseMessage.toString()}");
|
||||
selectedPaymentMethod = successResult.paymentOption ?? "VISA";
|
||||
checkPaymentStatus();
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void checkPaymentStatus() async {
|
||||
LoaderBottomSheet.showLoader(loadingText: "Checking payment status, Please wait...".needTranslation);
|
||||
await payfortViewModel.checkPaymentStatus(
|
||||
transactionID: transID,
|
||||
onSuccess: (apiResponse) async {
|
||||
print(apiResponse.data);
|
||||
if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") {
|
||||
if (emergencyServicesViewModel.isERBookAppointment) {
|
||||
await emergencyServicesViewModel.ER_CreateAdvancePayment(
|
||||
paymentMethodName: selectedPaymentMethod,
|
||||
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!,
|
||||
onSuccess: (value) async {
|
||||
await emergencyServicesViewModel.addAdvanceNumberRequest(
|
||||
advanceNumber: value,
|
||||
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!,
|
||||
appointmentNo: "0",
|
||||
onSuccess: (val) {
|
||||
LoaderBottomSheet.hideLoader();
|
||||
if (emergencyServicesViewModel.isERBookAppointment) {
|
||||
showCommonBottomSheetWithoutHeight(
|
||||
context,
|
||||
child: Utils.getSuccessWidget(loadingText: "Your appointment has been booked successfully. Please perform Check-In once you arrive at the hospital.".needTranslation),
|
||||
callBackFunc: () {},
|
||||
isFullScreen: false,
|
||||
isCloseButtonVisible: true,
|
||||
);
|
||||
} else {}
|
||||
});
|
||||
});
|
||||
} else {}
|
||||
} else {
|
||||
LoaderBottomSheet.hideLoader();
|
||||
showCommonBottomSheetWithoutHeight(
|
||||
context,
|
||||
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
|
||||
callBackFunc: () {},
|
||||
isFullScreen: false,
|
||||
isCloseButtonVisible: true,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onBrowserLoadStart(String url) {
|
||||
print("onBrowserLoadStart");
|
||||
print(url);
|
||||
|
||||
if (selectedPaymentMethod == "tamara") {
|
||||
if (Platform.isAndroid) {
|
||||
Uri uri = new Uri.dataFromString(url);
|
||||
tamaraPaymentStatus = uri.queryParameters['status']!;
|
||||
tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!;
|
||||
} else {
|
||||
Uri uri = new Uri.dataFromString(url);
|
||||
tamaraPaymentStatus = uri.queryParameters['paymentStatus']!;
|
||||
tamaraOrderID = uri.queryParameters['orderId']!;
|
||||
}
|
||||
}
|
||||
|
||||
// if(selectedPaymentMethod != "TAMARA") {
|
||||
MyInAppBrowser.successURLS.forEach((element) {
|
||||
if (url.contains(element)) {
|
||||
browser?.close();
|
||||
MyInAppBrowser.isPaymentDone = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
// }
|
||||
|
||||
// if(selectedPaymentMethod != "TAMARA") {
|
||||
MyInAppBrowser.errorURLS.forEach((element) {
|
||||
if (url.contains(element)) {
|
||||
browser?.close();
|
||||
MyInAppBrowser.isPaymentDone = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
onBrowserExit(bool isPaymentMade) async {
|
||||
checkPaymentStatus();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,169 @@
|
||||
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';
|
||||
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
|
||||
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
|
||||
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/appointments/my_appointments_page.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
|
||||
import 'package:hmg_patient_app_new/theme/colors.dart';
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/nfc/nfc_reader_sheet.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
||||
import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';
|
||||
|
||||
class ErOnlineCheckinSelectCheckinBottomSheet extends StatelessWidget {
|
||||
ErOnlineCheckinSelectCheckinBottomSheet({super.key, required this.projectID});
|
||||
|
||||
bool _supportsNFC = false;
|
||||
int projectID = 0;
|
||||
|
||||
late LocationUtils locationUtils;
|
||||
late AppState appState;
|
||||
ProjectDetailListModel projectDetailListModel = ProjectDetailListModel();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
appState = getIt.get<AppState>();
|
||||
FlutterNfcKit.nfcAvailability.then((value) {
|
||||
_supportsNFC = (value == NFCAvailability.available);
|
||||
});
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
checkInOptionCard(
|
||||
AppAssets.checkin_location_icon,
|
||||
"Live Location".needTranslation,
|
||||
"Verify your location to be at hospital to check in".needTranslation,
|
||||
).onPress(() {
|
||||
// locationUtils = LocationUtils(
|
||||
// isShowConfirmDialog: false,
|
||||
// navigationService: myAppointmentsViewModel.navigationService,
|
||||
// appState: myAppointmentsViewModel.appState,
|
||||
// );
|
||||
locationUtils.getCurrentLocation(onSuccess: (value) {
|
||||
projectDetailListModel = Utils.getProjectDetailObj(appState, 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(
|
||||
AppAssets.checkin_nfc_icon,
|
||||
"NFC (Near Field Communication)".needTranslation,
|
||||
"Scan your phone via NFC board to check in".needTranslation,
|
||||
).onPress(() {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
showNfcReader(context, onNcfScan: (String nfcId) {
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
sendCheckInRequest(nfcId, context);
|
||||
});
|
||||
}, onCancel: () {});
|
||||
});
|
||||
}),
|
||||
SizedBox(height: 16.h),
|
||||
checkInOptionCard(
|
||||
AppAssets.checkin_qr_icon,
|
||||
"QR Code".needTranslation,
|
||||
"Scan QR code with your camera to check in".needTranslation,
|
||||
).onPress(() async {
|
||||
String onlineCheckInQRCode = (await BarcodeScanner.scan().then((value) => value.rawContent));
|
||||
if (onlineCheckInQRCode != "") {
|
||||
sendCheckInRequest(onlineCheckInQRCode, context);
|
||||
} else {}
|
||||
}),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget checkInOptionCard(String icon, String title, String subTitle) {
|
||||
return Container(
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 20.h,
|
||||
hasShadow: false,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Utils.buildSvgWithAssets(icon: icon, width: 40.h, height: 40.h, fit: BoxFit.fill),
|
||||
SizedBox(height: 16.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
title.toText16(isBold: true, color: AppColors.textColor),
|
||||
subTitle.toText12(fontWeight: FontWeight.w500, color: AppColors.greyTextColor),
|
||||
],
|
||||
),
|
||||
),
|
||||
Transform.flip(
|
||||
flipX: appState.isArabic(),
|
||||
child: Utils.buildSvgWithAssets(
|
||||
icon: AppAssets.forward_arrow_icon_small,
|
||||
iconColor: AppColors.blackColor,
|
||||
width: 18.h,
|
||||
height: 13.h,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
).paddingAll(16.h),
|
||||
);
|
||||
}
|
||||
|
||||
void sendCheckInRequest(String scannedCode, BuildContext context) async {
|
||||
showCommonBottomSheet(context,
|
||||
child: Utils.getLoadingWidget(), callBackFunc: (str) {}, title: "", height: ResponsiveExtension.screenHeight * 0.3, isCloseButtonVisible: false, isDismissible: false, isFullScreen: false);
|
||||
// await myAppointmentsViewModel.sendCheckInNfcRequest(
|
||||
// patientAppointmentHistoryResponseModel: patientAppointmentHistoryResponseModel,
|
||||
// scannedCode: scannedCode,
|
||||
// checkInType: 2,
|
||||
// onSuccess: (apiResponse) {
|
||||
// Navigator.of(context).pop();
|
||||
// showCommonBottomSheetWithoutHeight(context, title: "Success".needTranslation, child: Utils.getSuccessWidget(loadingText: LocaleKeys.success.tr()), callBackFunc: () {
|
||||
// Navigator.of(context).pop();
|
||||
// Navigator.pushAndRemoveUntil(
|
||||
// context,
|
||||
// CustomPageRoute(
|
||||
// page: LandingNavigation(),
|
||||
// ),
|
||||
// (r) => false);
|
||||
// Navigator.of(context).push(
|
||||
// CustomPageRoute(page: MyAppointmentsPage()),
|
||||
// );
|
||||
// }, isFullScreen: false);
|
||||
// },
|
||||
// onError: (error) {
|
||||
// Navigator.of(context).pop();
|
||||
// showCommonBottomSheetWithoutHeight(context, title: "Error".needTranslation, child: Utils.getErrorWidget(loadingText: error), callBackFunc: () {
|
||||
// Navigator.of(context).pop();
|
||||
// }, isFullScreen: false);
|
||||
// },
|
||||
// );
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue