Merge branch 'refs/heads/master' into dev_sikander
# Conflicts: # lib/presentation/habib_wallet/recharge_wallet_page.dart # lib/presentation/lab/lab_orders_page.dart # lib/splashPage.dartpull/57/head
						commit
						005157fe5e
					
				| @ -0,0 +1,4 @@ | ||||
| <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||
|     <path fill-rule="evenodd" clip-rule="evenodd" d="M15.8333 3.99984C15.8333 3.26346 16.4303 2.6665 17.1667 2.6665H29.1667C29.903 2.6665 30.5 3.26346 30.5 3.99984C30.5 4.73622 29.903 5.33317 29.1667 5.33317L29.1667 23.3332C29.1667 26.6469 26.4804 29.3332 23.1667 29.3332C19.853 29.3332 17.1667 26.6469 17.1667 23.3332L17.1667 9.33405C17.1667 9.33376 17.1667 9.33434 17.1667 9.33405C17.1667 9.33376 17.1667 9.33259 17.1667 9.33229V5.33317C16.4303 5.33317 15.8333 4.73622 15.8333 3.99984ZM19.8333 7.99984V5.33317H26.5L26.5 13.0676C26.1378 13.317 25.8055 13.5125 25.4733 13.6324C25.0059 13.8012 24.5708 13.8095 24.0425 13.4925C22.6945 12.6837 21.4241 12.879 20.3715 13.4052C20.1897 13.4961 20.0098 13.5996 19.8333 13.7111V10.6665H22.5C23.2364 10.6665 23.8333 10.0695 23.8333 9.33317C23.8333 8.59679 23.2364 7.99984 22.5 7.99984H19.8333Z" fill="#2E3039"/> | ||||
|     <path d="M7.14104 12.6116C7.52794 12.2404 8.13873 12.2404 8.52562 12.6116L8.53329 12.6193C8.69353 12.7817 9.1478 13.2422 9.40228 13.5185C9.91854 14.0791 10.6087 14.8721 11.3012 15.7994C11.9917 16.7239 12.6985 17.8007 13.2361 18.9287C13.7693 20.0478 14.1667 21.2805 14.1667 22.4998C14.1667 24.7601 13.4124 26.4319 12.1558 27.5235C10.9246 28.5931 9.33325 28.9998 7.83333 28.9998C6.33342 28.9998 4.74203 28.5931 3.51084 27.5235C2.25425 26.4319 1.5 24.7601 1.5 22.4998C1.5 21.2805 1.89732 20.0478 2.4306 18.9287C2.96813 17.8007 3.67498 16.7239 4.36544 15.7994C5.05795 14.8721 5.74813 14.0791 6.26439 13.5185C6.51888 13.2422 6.97318 12.7817 7.1334 12.6193L7.14104 12.6116Z" fill="#2E3039"/> | ||||
| </svg> | ||||
| After Width: | Height: | Size: 1.6 KiB | 
											
												
													File diff suppressed because one or more lines are too long
												
											
										
									
								| After Width: | Height: | Size: 83 KiB | 
| @ -0,0 +1,430 @@ | ||||
| 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/habib_wallet/habib_wallet_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/lab/collapsing_list_view.dart'; | ||||
| import 'package:hmg_patient_app_new/theme/colors.dart'; | ||||
| import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.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:provider/provider.dart'; | ||||
| 
 | ||||
| class WalletPaymentConfirmPage extends StatefulWidget { | ||||
|   const WalletPaymentConfirmPage({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   State<WalletPaymentConfirmPage> createState() => _WalletPaymentConfirmPageState(); | ||||
| } | ||||
| 
 | ||||
| class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> { | ||||
|   late PayfortViewModel payfortViewModel; | ||||
|   late AppState appState; | ||||
|   late HabibWalletViewModel habibWalletVM; | ||||
| 
 | ||||
|   MyInAppBrowser? browser; | ||||
|   String selectedPaymentMethod = ""; | ||||
| 
 | ||||
|   String transID = ""; | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     scheduleMicrotask(() { | ||||
|       payfortViewModel.initPayfortViewModel(); | ||||
|     }); | ||||
|     super.initState(); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     appState = getIt.get<AppState>(); | ||||
|     habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false); | ||||
|     payfortViewModel = Provider.of<PayfortViewModel>(context, listen: false); | ||||
|     return Scaffold( | ||||
|       backgroundColor: AppColors.bgScaffoldColor, | ||||
|       body: Column( | ||||
|         crossAxisAlignment: CrossAxisAlignment.start, | ||||
|         children: [ | ||||
|           Expanded( | ||||
|             child: CollapsingListView( | ||||
|               title: "Select Payment Method", | ||||
|               child: SingleChildScrollView( | ||||
|                 child: Column( | ||||
|                   crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                   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).toShimmer2(isShow: false), | ||||
|                               SizedBox(height: 16.h), | ||||
|                               "Mada".needTranslation.toText16(isBold: true).toShimmer2(isShow: false), | ||||
|                             ], | ||||
|                           ), | ||||
|                           SizedBox(width: 8.h), | ||||
|                           const Spacer(), | ||||
|                           Transform.flip( | ||||
|                             flipX: appState.isArabic() ? true : false, | ||||
|                             child: Utils.buildSvgWithAssets( | ||||
|                               icon: AppAssets.forward_arrow_icon, | ||||
|                               iconColor: AppColors.blackColor, | ||||
|                               width: 18.h, | ||||
|                               height: 13.h, | ||||
|                               fit: BoxFit.contain, | ||||
|                             ).toShimmer2(isShow: false), | ||||
|                           ), | ||||
|                         ], | ||||
|                       ).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: 40.h, height: 40.h), | ||||
|                                   SizedBox(width: 8.h), | ||||
|                                   Image.asset(AppAssets.Mastercard, width: 40.h, height: 40.h), | ||||
|                                 ], | ||||
|                               ).toShimmer2(isShow: false), | ||||
|                               SizedBox(height: 16.h), | ||||
|                               "Visa or Mastercard".needTranslation.toText16(isBold: true).toShimmer2(isShow: false), | ||||
|                             ], | ||||
|                           ), | ||||
|                           SizedBox(width: 8.h), | ||||
|                           const Spacer(), | ||||
|                           Transform.flip( | ||||
|                             flipX: appState.isArabic() ? true : false, | ||||
|                             child: Utils.buildSvgWithAssets( | ||||
|                               icon: AppAssets.forward_arrow_icon, | ||||
|                               iconColor: AppColors.blackColor, | ||||
|                               width: 18.h, | ||||
|                               height: 13.h, | ||||
|                               fit: BoxFit.contain, | ||||
|                             ).toShimmer2(isShow: false), | ||||
|                           ), | ||||
|                         ], | ||||
|                       ).paddingSymmetrical(16.h, 16.h), | ||||
|                     ).paddingSymmetrical(24.h, 0.h).onPress(() { | ||||
|                       selectedPaymentMethod = "VISA"; | ||||
|                       openPaymentURL("visa"); | ||||
|                     }), | ||||
|                   ], | ||||
|                 ), | ||||
|               ), | ||||
|             ), | ||||
|           ), | ||||
|           Container( | ||||
|             // height: 200.h, | ||||
|             width: MediaQuery.of(context).size.width, | ||||
|             decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|               color: AppColors.whiteColor, | ||||
|               borderRadius: 24.h, | ||||
|               hasShadow: true, | ||||
|             ), | ||||
|             child: Column( | ||||
|               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|               children: [ | ||||
|                 SizedBox(height: 24.h), | ||||
|                 habibWalletVM.depositorName.toText18(isBold: true).paddingSymmetrical(24.h, 0.h), | ||||
|                 SizedBox(height: 12.h), | ||||
|                 Wrap( | ||||
|                   direction: Axis.horizontal, | ||||
|                   spacing: 4.h, | ||||
|                   runSpacing: 4.h, | ||||
|                   children: [ | ||||
|                     AppCustomChipWidget(labelText: "${LocaleKeys.fileno.tr(context: context)}.: ${habibWalletVM.fileNumber}"), | ||||
|                     AppCustomChipWidget(labelText: "${LocaleKeys.mobileNumber.tr(context: context)}: ${habibWalletVM.mobileNumber}"), | ||||
|                     AppCustomChipWidget(labelText: "${habibWalletVM.selectedHospital!.name}"), | ||||
|                   ], | ||||
|                 ).paddingSymmetrical(24.h, 0.h), | ||||
|                 SizedBox(height: 16.h), | ||||
|                 Divider(color: AppColors.borderOnlyColor.withValues(alpha: 0.1), height: 1.h).paddingSymmetrical(24.h, 0.h), | ||||
|                 SizedBox(height: 16.h), | ||||
|                 Row( | ||||
|                   mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|                   children: [ | ||||
|                     "Total amount to pay".needTranslation.toText16(isBold: true), | ||||
|                     Utils.getPaymentAmountWithSymbol(habibWalletVM.walletRechargeAmount.toString().toText24(isBold: true), AppColors.blackColor, 15.h, isSaudiCurrency: true), | ||||
|                   ], | ||||
|                 ).paddingSymmetrical(24.h, 0.h), | ||||
|                 SizedBox(height: 12.h), | ||||
|                 Platform.isIOS | ||||
|                     ? Utils.buildSvgWithAssets( | ||||
|                         icon: AppAssets.apple_pay_button, | ||||
|                         width: 200.h, | ||||
|                         height: 56.h, | ||||
|                         fit: BoxFit.contain, | ||||
|                       ).paddingSymmetrical(24.h, 0.h).onPress(() { | ||||
|                         if (Utils.havePrivilege(103)) { | ||||
|                           startApplePay(); | ||||
|                         } else { | ||||
|                           openPaymentURL("ApplePay"); | ||||
|                         } | ||||
|                       }) | ||||
|                     : SizedBox(height: 12.h), | ||||
|                 SizedBox(height: 32.h), | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   startApplePay() async { | ||||
|     LoaderBottomSheet.showLoader(); | ||||
|     ApplePayInsertRequest applePayInsertRequest = ApplePayInsertRequest(); | ||||
| 
 | ||||
|     transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber)); | ||||
| 
 | ||||
|     await payfortViewModel.getPayfortConfigurations(serviceId: ServiceTypeEnum.advancePayment.getIdFromServiceEnum(), projectId: habibWalletVM.selectedHospital!.iD!, integrationId: 2); | ||||
| 
 | ||||
|     applePayInsertRequest.clientRequestID = transID; | ||||
|     applePayInsertRequest.clinicID = 0; | ||||
| 
 | ||||
|     applePayInsertRequest.currency = appState.getAuthenticatedUser()!.outSa! == 0 ? "SAR" : "AED"; | ||||
|     applePayInsertRequest.customerEmail = "CustID_${habibWalletVM.fileNumber.toString()}@HMG.com"; | ||||
|     applePayInsertRequest.customerID = habibWalletVM.fileNumber.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 = habibWalletVM.selectedHospital!.iD!.toString(); | ||||
|     applePayInsertRequest.serviceID = ServiceTypeEnum.appointmentPayment.getIdFromServiceEnum().toString(); | ||||
|     applePayInsertRequest.channelID = 3; | ||||
|     applePayInsertRequest.patientID = habibWalletVM.fileNumber.toString(); | ||||
|     applePayInsertRequest.patientTypeID = appState.getAuthenticatedUser()!.patientType; | ||||
|     applePayInsertRequest.patientOutSA = appState.getAuthenticatedUser()!.outSa; | ||||
|     applePayInsertRequest.appointmentDate = null; | ||||
|     applePayInsertRequest.appointmentNo = 0; | ||||
|     applePayInsertRequest.orderDescription = "Advance Payment"; | ||||
|     applePayInsertRequest.liveServiceID = "0"; | ||||
|     applePayInsertRequest.latitude = "0.0"; | ||||
|     applePayInsertRequest.longitude = "0.0"; | ||||
|     applePayInsertRequest.amount = habibWalletVM.walletRechargeAmount.toString(); | ||||
|     applePayInsertRequest.isSchedule = "0"; | ||||
|     applePayInsertRequest.language = appState.isArabic() ? 'ar' : 'en'; | ||||
|     applePayInsertRequest.languageID = appState.isArabic() ? 1 : 2; | ||||
|     applePayInsertRequest.userName = int.parse(habibWalletVM.fileNumber); | ||||
|     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(habibWalletVM.walletRechargeAmount.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()}"); | ||||
|           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(); | ||||
|     await payfortViewModel.checkPaymentStatus( | ||||
|       transactionID: transID, | ||||
|       onSuccess: (apiResponse) async { | ||||
|         print(apiResponse.data); | ||||
|         if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") { | ||||
|           await habibWalletVM.HISCreateAdvancePayment( | ||||
|               paymentMethodName: selectedPaymentMethod, | ||||
|               paidAmount: habibWalletVM.walletRechargeAmount, | ||||
|               paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!, | ||||
|               patientID: habibWalletVM.fileNumber, | ||||
|               projectID: habibWalletVM.selectedHospital!.iD!, | ||||
|               depositorName: habibWalletVM.depositorName, | ||||
|               onSuccess: (value) async { | ||||
|                 await habibWalletVM.addAdvanceNumberRequest( | ||||
|                     advanceNumber: Utils.isVidaPlusProject(habibWalletVM.selectedHospital!.iD) | ||||
|                         ? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() | ||||
|                         : value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), | ||||
|                     paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!, | ||||
|                     onSuccess: (value) { | ||||
|                       LoaderBottomSheet.hideLoader(); | ||||
|                       showCommonBottomSheetWithoutHeight( | ||||
|                         context, | ||||
|                         child: Utils.getSuccessWidget(loadingText: "Payment Successful!".needTranslation), | ||||
|                         callBackFunc: () { | ||||
|                           Navigator.of(context).pop(); | ||||
|                           Navigator.of(context).pop(); | ||||
|                         }, | ||||
|                         isFullScreen: false, | ||||
|                         isCloseButtonVisible: true, | ||||
|                       ); | ||||
|                     }, | ||||
|                     onError: (err) { | ||||
|                       LoaderBottomSheet.hideLoader(); | ||||
|                       showCommonBottomSheetWithoutHeight( | ||||
|                         context, | ||||
|                         child: Utils.getErrorWidget(loadingText: "Payment Failed - ${err}".needTranslation), | ||||
|                         callBackFunc: () {}, | ||||
|                         isFullScreen: false, | ||||
|                         isCloseButtonVisible: true, | ||||
|                       ); | ||||
|                     }); | ||||
|               }, | ||||
|               onError: (err) {}); | ||||
|         } 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 { | ||||
|     print("onBrowserExit Called!!!!"); | ||||
|     if (selectedPaymentMethod == "TAMARA") { | ||||
|       // checkTamaraPaymentStatus(transID!, appo); | ||||
|       // if (tamaraPaymentStatus != null && tamaraPaymentStatus.toLowerCase() == "approved") { | ||||
|       //   updateTamaraRequestStatus("success", "14", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo); | ||||
|       // } else { | ||||
|       //   updateTamaraRequestStatus("Failed", "00", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo); | ||||
|       // } | ||||
|     } else { | ||||
|       checkPaymentStatus(); | ||||
|       // checkPaymentStatus(appo); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   openPaymentURL(String paymentMethod) { | ||||
|     browser = MyInAppBrowser(onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart, context: context); | ||||
|     transID = Utils.getAdvancePaymentTransID(habibWalletVM.selectedHospital!.iD!, int.parse(habibWalletVM.fileNumber)); | ||||
| 
 | ||||
|     browser?.openPaymentBrowser( | ||||
|         habibWalletVM.walletRechargeAmount, | ||||
|         "Advance Payment", | ||||
|         transID, | ||||
|         habibWalletVM.selectedHospital!.iD!.toString(), | ||||
|         "CustID_${habibWalletVM.fileNumber.toString()}@HMG.com", | ||||
|         selectedPaymentMethod, | ||||
|         appState.getAuthenticatedUser()!.patientType.toString(), | ||||
|         habibWalletVM.depositorName, | ||||
|         habibWalletVM.fileNumber.toString(), | ||||
|         appState.getAuthenticatedUser()!, | ||||
|         browser!, | ||||
|         false, | ||||
|         "3", | ||||
|         "0", | ||||
|         context, | ||||
|         "", | ||||
|         "", | ||||
|         "", | ||||
|         "", | ||||
|         "3"); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,106 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:hmg_patient_app_new/core/app_assets.dart'; | ||||
| import 'package:hmg_patient_app_new/core/app_export.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/utils.dart'; | ||||
| import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; | ||||
| import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart'; | ||||
| import 'package:hmg_patient_app_new/theme/colors.dart'; | ||||
| 
 | ||||
| class HospitalListItemAdvancePayment extends StatelessWidget { | ||||
|   final HospitalsModel hospitalModel; | ||||
|   final bool isLocationEnabled; | ||||
| 
 | ||||
|   late AppState appState; | ||||
| 
 | ||||
|   HospitalListItemAdvancePayment({super.key, required this.hospitalModel, required this.isLocationEnabled}); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     appState = getIt.get<AppState>(); | ||||
|     return DecoratedBox( | ||||
|       decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|         color: AppColors.whiteColor, | ||||
|         borderRadius: 20.h, | ||||
|         hasShadow: false, | ||||
|       ), | ||||
|       child: Row( | ||||
|         mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||
|         children: [ | ||||
|           Expanded( | ||||
|             child: Column( | ||||
|               crossAxisAlignment: CrossAxisAlignment.start, | ||||
|               spacing: 8.h, | ||||
|               children: [hospitalName], | ||||
|             ), | ||||
|           ), | ||||
|           Transform.flip( | ||||
|             flipX: appState.isArabic() ? true : false, | ||||
|             child: Utils.buildSvgWithAssets( | ||||
|               icon: AppAssets.forward_arrow_icon, | ||||
|               iconColor: AppColors.blackColor, | ||||
|               width: 18, | ||||
|               height: 13, | ||||
|               fit: BoxFit.contain, | ||||
|             ), | ||||
|           ), | ||||
|         ], | ||||
|       ).paddingSymmetrical(16.h, 16.h), | ||||
|     ); | ||||
|   } | ||||
| 
 | ||||
|   Widget get hospitalName => Row( | ||||
|         children: [ | ||||
|           Utils.buildSvgWithAssets( | ||||
|             icon: (hospitalModel.isHMC == true) ? AppAssets.hmc : AppAssets.hmg, | ||||
|           ).paddingOnly(right: 10), | ||||
|           Expanded( | ||||
|             child: Text( | ||||
|               hospitalModel.name ?? "", | ||||
|               style: TextStyle( | ||||
|                 fontWeight: FontWeight.w600, | ||||
|                 fontSize: 16, | ||||
|                 color: AppColors.blackColor, | ||||
|               ), | ||||
|             ), | ||||
|           ) | ||||
|         ], | ||||
|       ); | ||||
| 
 | ||||
| // Widget get distanceInfo => Row( | ||||
| //   children: [ | ||||
| //     Visibility( | ||||
| //       visible: (hospitalModel.distanceInKMs != "0"), | ||||
| //       child: AppCustomChipWidget( | ||||
| //         labelText: "${hospitalData?.distanceInKMs ?? ""} km".needTranslation, | ||||
| //         deleteIcon: AppAssets.location_red, | ||||
| //         deleteIconSize: Size(9, 12), | ||||
| //         backgroundColor: AppColors.secondaryLightRedColor, | ||||
| //         textColor: AppColors.errorColor, | ||||
| //       ), | ||||
| //     ), | ||||
| //     Visibility( | ||||
| //         visible: (hospitalData?.distanceInKMs == "0"), | ||||
| //         child: Row( | ||||
| //           children: [ | ||||
| //             AppCustomChipWidget( | ||||
| //               labelText: "Distance not available".needTranslation, | ||||
| //               textColor: AppColors.blackColor, | ||||
| //             ), | ||||
| //             SizedBox( | ||||
| //               width: 8.h, | ||||
| //             ) | ||||
| //           ], | ||||
| //         )), | ||||
| //     Visibility( | ||||
| //         visible: !isLocationEnabled, | ||||
| //         child: AppCustomChipWidget( | ||||
| //           labelText: "Location turned off".needTranslation, | ||||
| //           deleteIcon: AppAssets.location_unavailable, | ||||
| //           deleteIconSize: Size(9, 12), | ||||
| //           textColor: AppColors.blackColor, | ||||
| //         )), | ||||
| //   ], | ||||
| // ); | ||||
| } | ||||
| @ -0,0 +1,96 @@ | ||||
| import 'package:easy_localization/easy_localization.dart' show tr, StringTranslateExtension; | ||||
| import 'package:flutter/material.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/extensions/string_extensions.dart'; | ||||
| import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; | ||||
| import 'package:hmg_patient_app_new/features/book_appointments/book_appointments_view_model.dart'; | ||||
| import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; | ||||
| import 'package:hmg_patient_app_new/features/my_appointments/appointment_via_region_viewmodel.dart'; | ||||
| import 'package:hmg_patient_app_new/features/my_appointments/models/facility_selection.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/widgets/hospital_bottom_sheet/hospital_list_items.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/appointments/widgets/hospital_bottom_sheet/type_selection_widget.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/habib_wallet/widgets/hospital_list_item.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/lab/collapsing_list_view.dart'; | ||||
| import 'package:hmg_patient_app_new/theme/colors.dart' show AppColors; | ||||
| import 'package:hmg_patient_app_new/widgets/input_widget.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| 
 | ||||
| class SelectHospitalBottomSheet extends StatelessWidget { | ||||
|   late HabibWalletViewModel habibWalletVM; | ||||
|   final TextEditingController searchText = TextEditingController(); | ||||
| 
 | ||||
|   SelectHospitalBottomSheet({super.key}); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false); | ||||
|     return Column( | ||||
|       crossAxisAlignment: CrossAxisAlignment.start, | ||||
|       children: [ | ||||
|         // Text( | ||||
|         //   LocaleKeys.selectHospital.tr(), | ||||
|         //   style: TextStyle( | ||||
|         //     fontSize: 21, | ||||
|         //     fontWeight: FontWeight.w600, | ||||
|         //     color: AppColors.blackColor, | ||||
|         //   ), | ||||
|         // ), | ||||
|         Text( | ||||
|           "Please select the hospital you want to make an advance payment for.".needTranslation, | ||||
|           style: TextStyle( | ||||
|             fontSize: 16, | ||||
|             fontWeight: FontWeight.w500, | ||||
|             color: AppColors.greyTextColor, | ||||
|           ), | ||||
|         ), | ||||
|         SizedBox(height: 16.h), | ||||
|         // TextInputWidget( | ||||
|         //   labelText: LocaleKeys.search.tr(), | ||||
|         //   hintText: "Search Hospital".tr(), | ||||
|         //   controller: searchText, | ||||
|         //   onChange: (value) { | ||||
|         //     // appointmentsViewModel.filterHospitalListByString(value, regionalViewModel.selectedRegionId , regionalViewModel.selectedFacilityType == | ||||
|         //     //     FacilitySelection.HMG.name); | ||||
|         //   }, | ||||
|         //   isEnable: true, | ||||
|         //   prefix: null, | ||||
|         //   autoFocus: false, | ||||
|         //   isBorderAllowed: false, | ||||
|         //   keyboardType: TextInputType.text, | ||||
|         //   isAllowLeadingIcon: true, | ||||
|         //   selectionType: SelectionTypeEnum.search, | ||||
|         //   padding: EdgeInsets.symmetric( | ||||
|         //     vertical: ResponsiveExtension(10).h, | ||||
|         //     horizontal: ResponsiveExtension(15).h, | ||||
|         //   ), | ||||
|         // ), | ||||
|         // SizedBox(height: 24.h), | ||||
|         // TypeSelectionWidget( | ||||
|         //   hmcCount: "0", | ||||
|         //   hmgCount: "0", | ||||
|         // ), | ||||
|         // SizedBox(height: 21.h), | ||||
|         SizedBox( | ||||
|           height: MediaQuery.sizeOf(context).height * .4, | ||||
|           child: ListView.separated( | ||||
|               itemBuilder: (_, index) { | ||||
|                 return HospitalListItemAdvancePayment( | ||||
|                   hospitalModel: habibWalletVM.advancePaymentHospitals[index], | ||||
|                   isLocationEnabled: false, | ||||
|                 ).onPress(() { | ||||
|                   habibWalletVM.setSelectedHospital(habibWalletVM.advancePaymentHospitals[index]); | ||||
|                   Navigator.of(context).pop(); | ||||
|                 }); | ||||
|               }, | ||||
|               separatorBuilder: (_, __) => SizedBox( | ||||
|                     height: 16.h, | ||||
|                   ), | ||||
|               itemCount: habibWalletVM.advancePaymentHospitals.length), | ||||
|         ) | ||||
|       ], | ||||
|     ); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,162 @@ | ||||
| import 'dart:async'; | ||||
| 
 | ||||
| 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/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/radiology/models/resp_models/patient_radiology_response_model.dart'; | ||||
| import 'package:hmg_patient_app_new/features/radiology/radiology_view_model.dart'; | ||||
| import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; | ||||
| import 'package:hmg_patient_app_new/presentation/lab/collapsing_list_view.dart'; | ||||
| import 'package:hmg_patient_app_new/theme/colors.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:open_filex/open_filex.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| import 'package:url_launcher/url_launcher.dart'; | ||||
| 
 | ||||
| class RadiologyResultPage extends StatefulWidget { | ||||
|   RadiologyResultPage({super.key, required this.patientRadiologyResponseModel}); | ||||
| 
 | ||||
|   PatientRadiologyResponseModel patientRadiologyResponseModel; | ||||
| 
 | ||||
|   @override | ||||
|   State<RadiologyResultPage> createState() => _RadiologyResultPageState(); | ||||
| } | ||||
| 
 | ||||
| class _RadiologyResultPageState extends State<RadiologyResultPage> { | ||||
|   late RadiologyViewModel radiologyViewModel; | ||||
| 
 | ||||
|   @override | ||||
|   void initState() { | ||||
|     scheduleMicrotask(() { | ||||
|       radiologyViewModel.getRadiologyImage(patientRadiologyResponseModel: widget.patientRadiologyResponseModel); | ||||
|     }); | ||||
|     super.initState(); | ||||
|   } | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     radiologyViewModel = Provider.of<RadiologyViewModel>(context); | ||||
|     AppState _appState = getIt.get<AppState>(); | ||||
|     return Scaffold( | ||||
|       backgroundColor: AppColors.bgScaffoldColor, | ||||
|       body: Column( | ||||
|         children: [ | ||||
|           Expanded( | ||||
|             child: CollapsingListView( | ||||
|               title: "Radiology Result".needTranslation, | ||||
|               child: SingleChildScrollView( | ||||
|                 child: Padding( | ||||
|                   padding: EdgeInsets.symmetric(horizontal: 24.h), | ||||
|                   child: Column( | ||||
|                     crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                     children: [ | ||||
|                       SizedBox(height: 24.h), | ||||
|                       Container( | ||||
|                         decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|                           color: AppColors.whiteColor, | ||||
|                           borderRadius: 20.h, | ||||
|                           hasShadow: true, | ||||
|                         ), | ||||
|                         child: Column( | ||||
|                           crossAxisAlignment: CrossAxisAlignment.start, | ||||
|                           children: [ | ||||
|                             SizedBox(height: 16.h), | ||||
|                             widget.patientRadiologyResponseModel.description!.toText16(isBold: true), | ||||
|                             SizedBox(height: 8.h), | ||||
|                             widget.patientRadiologyResponseModel.reportData!.trim().toText12(isBold: true, color: AppColors.textColorLight), | ||||
|                             SizedBox(height: 16.h), | ||||
|                             CustomButton( | ||||
|                               text: "View Radiology Image".needTranslation, | ||||
|                               onPressed: () async { | ||||
|                                 if (radiologyViewModel.radiologyImageURL.isNotEmpty) { | ||||
|                                   Uri uri = Uri.parse(radiologyViewModel.radiologyImageURL); | ||||
|                                   launchUrl(uri, mode: LaunchMode.platformDefault, webOnlyWindowName: ""); | ||||
|                                 } else { | ||||
|                                   Utils.showToast("Radiology image not available".needTranslation); | ||||
|                                 } | ||||
|                               }, | ||||
|                               backgroundColor: AppColors.primaryRedColor, | ||||
|                               borderColor: AppColors.primaryRedColor, | ||||
|                               textColor: AppColors.whiteColor, | ||||
|                               fontSize: 14, | ||||
|                               fontWeight: FontWeight.w500, | ||||
|                               borderRadius: 12, | ||||
|                               padding: EdgeInsets.fromLTRB(10, 0, 10, 0), | ||||
|                               height: 40.h, | ||||
|                               icon: AppAssets.download, | ||||
|                               iconColor: AppColors.whiteColor, | ||||
|                               iconSize: 20.h, | ||||
|                             ), | ||||
|                             SizedBox(height: 16.h), | ||||
|                           ], | ||||
|                         ).paddingSymmetrical(16.h, 0.h), | ||||
|                       ), | ||||
|                       SizedBox(height: 24.h), | ||||
|                     ], | ||||
|                   ), | ||||
|                 ), | ||||
|               ), | ||||
|             ), | ||||
|           ), | ||||
|           Container( | ||||
|             decoration: RoundedRectangleBorder().toSmoothCornerDecoration( | ||||
|               color: AppColors.whiteColor, | ||||
|               borderRadius: 24.h, | ||||
|               hasShadow: true, | ||||
|             ), | ||||
|             child: CustomButton( | ||||
|               text: "Download report".needTranslation, | ||||
|               onPressed: () async { | ||||
|                 LoaderBottomSheet.showLoader(); | ||||
|                 await radiologyViewModel.getRadiologyPDF(patientRadiologyResponseModel: widget.patientRadiologyResponseModel, authenticatedUser: _appState.getAuthenticatedUser()!, onError: (err) { | ||||
|                   LoaderBottomSheet.hideLoader(); | ||||
|                   showCommonBottomSheetWithoutHeight( | ||||
|                     context, | ||||
|                     child: Utils.getErrorWidget(loadingText: err), | ||||
|                     callBackFunc: () {}, | ||||
|                     isFullScreen: false, | ||||
|                     isCloseButtonVisible: true, | ||||
|                   ); | ||||
|                 }).then((val) async { | ||||
|                   LoaderBottomSheet.hideLoader(); | ||||
|                   if (radiologyViewModel.patientRadiologyReportPDFBase64.isNotEmpty) { | ||||
|                     String path = await Utils.createFileFromString(radiologyViewModel.patientRadiologyReportPDFBase64, "pdf"); | ||||
|                     try { | ||||
|                       OpenFilex.open(path); | ||||
|                     } catch (ex) { | ||||
|                       showCommonBottomSheetWithoutHeight( | ||||
|                         context, | ||||
|                         child: Utils.getErrorWidget(loadingText: "Cannot open file".needTranslation), | ||||
|                         callBackFunc: () {}, | ||||
|                         isFullScreen: false, | ||||
|                         isCloseButtonVisible: true, | ||||
|                       ); | ||||
|                     } | ||||
|                   } | ||||
|                 }); | ||||
|               }, | ||||
|               backgroundColor: AppColors.successColor, | ||||
|               borderColor: AppColors.successColor, | ||||
|               textColor: AppColors.whiteColor, | ||||
|               fontSize: 16, | ||||
|               fontWeight: FontWeight.w500, | ||||
|               borderRadius: 12, | ||||
|               padding: EdgeInsets.fromLTRB(10, 0, 10, 0), | ||||
|               height: 45.h, | ||||
|               icon: AppAssets.download, | ||||
|               iconColor: AppColors.whiteColor, | ||||
|               iconSize: 20.h, | ||||
|             ).paddingSymmetrical(24.h, 24.h), | ||||
|           ), | ||||
|         ], | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue