ER Online Check-In implemented
parent
cc1e073f6d
commit
9a48421271
@ -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