From 4eb4d0b37dbd956113515817bc957e6f6eca0f5b Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 3 Jun 2026 16:37:35 +0300 Subject: [PATCH] Parking QR implemented --- assets/langs/ar-SA.json | 4 +- assets/langs/en-US.json | 4 +- lib/core/api_consts.dart | 2 +- lib/core/app_state.dart | 4 +- .../authentication_view_model.dart | 2 + .../emergency_services_view_model.dart | 4 +- .../habib_wallet/habib_wallet_view_model.dart | 7 +- ...appointment_parking_QR_response_model.dart | 3 +- .../my_appointments_view_model.dart | 8 ++ lib/generated/locale_keys.g.dart | 2 + .../appointment_details_page.dart | 99 +++++++++++++------ pubspec.yaml | 4 +- 12 files changed, 103 insertions(+), 40 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 8b82ba9f..3010ecd9 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -1908,5 +1908,7 @@ "amountOnly": "المبلغ", "invoiceHistory": "سجل الفواتير", "thisInvoiceIsNotEligibleForRefund": "هذه الفاتورة غير مؤهلة للاسترداد", - "refund": "استرداد" + "refund": "استرداد", + "parkingQR": "رمز الاستجابة السريعة لوقوف السيارات", + "parkingQRDesc": "امسح رمز الاستجابة السريعة (QR Code) أدناه عند بوابة الخروج من موقف السيارات:" } diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index ce4f869a..94de68ed 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -1899,7 +1899,9 @@ "refund": "Refund", "advanceNumber": "Advance Number", "amountOnly": "Amount", - "invoiceHistory": "Invoice History" + "invoiceHistory": "Invoice History", + "parkingQR": "Parking QR Code", + "parkingQRDesc": "Scan the below QR Code at the exit parking gate:" } diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index 9f3bb907..bd4b0d5b 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -4,7 +4,7 @@ import 'package:hmg_patient_app_new/core/enums.dart'; class ApiConsts { static const maxSmallScreen = 660; - static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; + static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat; // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT diff --git a/lib/core/app_state.dart b/lib/core/app_state.dart index aae2d03b..65b44d7d 100644 --- a/lib/core/app_state.dart +++ b/lib/core/app_state.dart @@ -49,8 +49,8 @@ class AppState { bool isPaytabsEnabled = false; void setIsPaytabsEnabled(bool value) { - isPaytabsEnabled = value; - // isPaytabsEnabled = false; + // isPaytabsEnabled = value; + isPaytabsEnabled = false; } int? _superUserID; diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 8685a947..540383a3 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -26,6 +26,7 @@ import 'package:hmg_patient_app_new/features/authentication/models/resp_models/a import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_activation_code_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'; +import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; import 'package:hmg_patient_app_new/features/hmg_services/hmg_services_view_model.dart'; import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart'; import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart'; @@ -1252,6 +1253,7 @@ class AuthenticationViewModel extends ChangeNotifier { } await clearDefaultInputValues(); myAppointmentsVM.setIsAppointmentDataToBeLoaded(true); + getIt.get().setIsWalletAmountToBeLoaded(true); getIt.get().setIsInsuranceDataToBeLoaded(true); getIt.get().setHasVitalSignDataLoaded(false); if (isUserAgreedBefore) { diff --git a/lib/features/emergency_services/emergency_services_view_model.dart b/lib/features/emergency_services/emergency_services_view_model.dart index d581d0f5..133aa795 100644 --- a/lib/features/emergency_services/emergency_services_view_model.dart +++ b/lib/features/emergency_services/emergency_services_view_model.dart @@ -347,7 +347,7 @@ class EmergencyServicesViewModel extends ChangeNotifier { (failure) { patientHasAdvanceERBalance = false; isERBookAppointment = true; - isAdvanceERBalanceNeedToBeLoaded = true; + isAdvanceERBalanceNeedToBeLoaded = false; if (onSuccess != null) { onSuccess(failure.message); } @@ -357,7 +357,7 @@ class EmergencyServicesViewModel extends ChangeNotifier { // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); patientHasAdvanceERBalance = false; isERBookAppointment = true; - isAdvanceERBalanceNeedToBeLoaded = true; + isAdvanceERBalanceNeedToBeLoaded = false; } else if (apiResponse.messageStatus == 1) { patientHasAdvanceERBalance = apiResponse.data; isERBookAppointment = !patientHasAdvanceERBalance; diff --git a/lib/features/habib_wallet/habib_wallet_view_model.dart b/lib/features/habib_wallet/habib_wallet_view_model.dart index f7fafa20..3bee29de 100644 --- a/lib/features/habib_wallet/habib_wallet_view_model.dart +++ b/lib/features/habib_wallet/habib_wallet_view_model.dart @@ -551,7 +551,12 @@ class HabibWalletViewModel extends ChangeNotifier { final result = await habibWalletRepo.getLakumAccountInformation(identificationNumber: getIt.get().getAuthenticatedUser()!.patientIdentificationNo ?? ""); result.fold( - (failure) async => await errorHandlerService.handleError(failure: failure), + // (failure) async => await errorHandlerService.handleError(failure: failure), + (failure) async { + yahalaAccountNumber = "0"; + isLakumAccountInfoLoading = false; + notifyListeners(); // 675534 + }, (apiResponse) async { if (apiResponse.messageStatus == 2) { yahalaAccountNumber = "0"; diff --git a/lib/features/my_appointments/models/resp_models/appointment_parking_QR_response_model.dart b/lib/features/my_appointments/models/resp_models/appointment_parking_QR_response_model.dart index a0a2c4d9..67be0815 100644 --- a/lib/features/my_appointments/models/resp_models/appointment_parking_QR_response_model.dart +++ b/lib/features/my_appointments/models/resp_models/appointment_parking_QR_response_model.dart @@ -54,7 +54,8 @@ class AppointmentParkingQRResponseModel { isUsed = json['IsUsed']; patientID = json['PatientID']; projectID = json['ProjectID']; - ticketBase64 = json['TicketBase64'].cast(); + // ticketBase64 = json['TicketBase64'].cast(); + ticketBase64 = json['TicketBase64String']; ticketID = json['TicketID']; ticketURL = json['TicketURL']; } diff --git a/lib/features/my_appointments/my_appointments_view_model.dart b/lib/features/my_appointments/my_appointments_view_model.dart index 5aae8211..90f504d2 100644 --- a/lib/features/my_appointments/my_appointments_view_model.dart +++ b/lib/features/my_appointments/my_appointments_view_model.dart @@ -1,3 +1,6 @@ +import 'dart:convert'; +import 'dart:typed_data'; + import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; @@ -103,6 +106,8 @@ class MyAppointmentsViewModel extends ChangeNotifier { AppointmentParkingQRResponseModel? appointmentParkingQRResponseModel; + Uint8List? parkingQRImageBytes; + MyAppointmentsViewModel({required this.myAppointmentsRepo, required this.errorHandlerService, required this.appState}); void onTabChange(int index) { @@ -736,6 +741,9 @@ class MyAppointmentsViewModel extends ChangeNotifier { }, (apiResponse) { appointmentParkingQRResponseModel = apiResponse.data!; + parkingQRImageBytes = base64Decode( + appointmentParkingQRResponseModel!.ticketBase64.contains(',') ? appointmentParkingQRResponseModel!.ticketBase64.split(',').last : appointmentParkingQRResponseModel!.ticketBase64); + // parkingQRImageBytes = appointmentParkingQRResponseModel!.ticketBase64; notifyListeners(); if (onSuccess != null) { onSuccess(apiResponse); diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index b5d3cae7..edba3bd0 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -1894,5 +1894,7 @@ abstract class LocaleKeys { static const invoiceHistory = 'invoiceHistory'; static const thisInvoiceIsNotEligibleForRefund = 'thisInvoiceIsNotEligibleForRefund'; static const refund = 'refund'; + static const parkingQR = 'parkingQR'; + static const parkingQRDesc = 'parkingQRDesc'; } diff --git a/lib/presentation/appointments/appointment_details_page.dart b/lib/presentation/appointments/appointment_details_page.dart index ddf9ec86..47ddef09 100644 --- a/lib/presentation/appointments/appointment_details_page.dart +++ b/lib/presentation/appointments/appointment_details_page.dart @@ -874,35 +874,76 @@ class _AppointmentDetailsPageState extends State { } }) : SizedBox.shrink(), - // (widget.patientAppointmentHistoryResponseModel.isParkingAvailable ?? false) - // ? MedicalFileCard( - // label: LocaleKeys.getParkingQR.tr(context: context), - // textColor: AppColors.blackColor, - // backgroundColor: AppColors.whiteColor, - // svgIcon: AppAssets.appointment_parking_icon, - // isLargeText: true, - // iconSize: 36.w, - // ).onPress(() { - // LoaderBottomSheet.showLoader(loadingText: LocaleKeys.loadingText.tr(context: context)); - // myAppointmentsViewModel.getParkingQR( - // widget.patientAppointmentHistoryResponseModel.appointmentNo, - // widget.patientAppointmentHistoryResponseModel.projectID, - // onSuccess: (val) { - // LoaderBottomSheet.hideLoader(); - // }, - // onError: (err) { - // LoaderBottomSheet.hideLoader(); - // showCommonBottomSheetWithoutHeight( - // context, - // child: Utils.getErrorWidget(loadingText: err), - // callBackFunc: () {}, - // isFullScreen: false, - // isCloseButtonVisible: true, - // ); - // }, - // ); - // }) - // : SizedBox.shrink(), + (widget.patientAppointmentHistoryResponseModel.isParkingAvailable ?? false) + ? MedicalFileCard( + label: LocaleKeys.getParkingQR.tr(context: context), + textColor: AppColors.blackColor, + backgroundColor: AppColors.whiteColor, + svgIcon: AppAssets.appointment_parking_icon, + isLargeText: true, + iconSize: 36.w, + ).onPress(() { + LoaderBottomSheet.showLoader(loadingText: LocaleKeys.loadingText.tr(context: context)); + myAppointmentsViewModel.getParkingQR( + widget.patientAppointmentHistoryResponseModel.appointmentNo, + widget.patientAppointmentHistoryResponseModel.projectID, + onSuccess: (val) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + title: LocaleKeys.parkingQR.tr(context: context), + context, + child: SizedBox( + // height: 150.h, + child: Column( + children: [ + LocaleKeys.parkingQRDesc.tr(context: context).toText16(), + SizedBox(height: 16.h), + Image.memory( + myAppointmentsViewModel.parkingQRImageBytes!, + width: 156.w, + height: 156.h, + fit: BoxFit.cover, + gaplessPlayback: true, // Prevents blink during image rebuild + ), + SizedBox(height: 16.h), + CustomButton( + text: LocaleKeys.done.tr(context: context), + onPressed: () { + openDoctorScheduleCalendar(); + }, + backgroundColor: AppColors.primaryRedColor, + borderColor: AppColors.primaryRedColor, + textColor: Colors.white, + fontSize: 16.f, + fontWeight: FontWeight.w600, + borderRadius: 12.r, + padding: EdgeInsets.symmetric(horizontal: 10.w), + height: 50.h, + icon: AppAssets.checkmark_icon, + iconColor: Colors.white, + iconSize: 18.h, + ).paddingSymmetrical(0.h, 0.h), + ], + ), + ), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }, + onError: (err) { + LoaderBottomSheet.hideLoader(); + showCommonBottomSheetWithoutHeight( + context, + child: Utils.getErrorWidget(loadingText: err), + callBackFunc: () {}, + isFullScreen: false, + isCloseButtonVisible: true, + ); + }, + ); + }) + : SizedBox.shrink(), ], ); }), diff --git a/pubspec.yaml b/pubspec.yaml index 59e906b0..4531e800 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,8 +2,8 @@ name: hmg_patient_app_new description: "New HMG Patient App" publish_to: 'none' # Remove this line if you wish to publish to pub.dev -#version: 0.0.32+31 -version: 0.0.5+2 +version: 0.0.35+34 +#version: 0.0.6+3 environment: sdk: ">=3.6.0 <4.0.0"