From 6e30df2a293f19af4217c30bacbe490a032b0d56 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 13 May 2024 12:36:01 +0300 Subject: [PATCH] WeCare service added --- lib/config/config.dart | 2 + lib/config/localized_values.dart | 1 + .../medical/medical_profile_page_new.dart | 70 ++++++++++++++++++- .../clinic_services/get_clinic_service.dart | 12 ++++ lib/uitl/translations_delegate_base.dart | 2 + lib/uitl/utils.dart | 14 +++- .../dialogs/radio_selection_dialog.dart | 7 +- 7 files changed, 103 insertions(+), 5 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index edb81d78..996b3e65 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -629,6 +629,8 @@ var GET_BLOOD_DONATION_PROJECTS_LIST = 'Services/OUTPs.svc/REST/BD_getProjectsHa var GET_BLOOD_DONATION_FREE_SLOTS = 'Services/OUTPs.svc/REST/BD_GetFreeSlots'; +var GET_WE_CARE_TOUR_URL = 'Services/Consent.svc/Rest/Consent_VirtualJurny_Url_GetByProjectID'; + //PAYFORT var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails"; var addPayFortApplePayResponse = "Services/PayFort_Serv.svc/REST/AddResponse"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index b5e1f0d2..6910f8de 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1933,4 +1933,5 @@ const Map localizedValues = { "locationTimeoutError": {"en": "Unable to fetch your location, Please try again.", "ar": "غير قادر على جلب موقعك، يرجى المحاولة مرة أخرى."}, "loadMore": {"en": "Load More", "ar": "تحميل المزيد"}, "selectHospitalBloodDonation": {"en": "Please select the hospital you want to book an appointment with: ", "ar": "يرجى اختيار المستشفى الذي تريد حجز موعد معه:"}, + "wecare": {"en": "We Care", "ar": "نحن نهتم"}, }; diff --git a/lib/pages/medical/medical_profile_page_new.dart b/lib/pages/medical/medical_profile_page_new.dart index f8f6499e..55ba30d4 100644 --- a/lib/pages/medical/medical_profile_page_new.dart +++ b/lib/pages/medical/medical_profile_page_new.dart @@ -1,21 +1,29 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; +import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/time_line_new_widget.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; class MedicalProfilePageNew extends StatefulWidget { Function onTap; String a; + MedicalProfilePageNew({this.onTap}); + @override _MedicalProfilePageState createState() => _MedicalProfilePageState(); } @@ -25,11 +33,15 @@ class _MedicalProfilePageState extends State { List medical = List(); ProjectViewModel projectViewModel; + List projectsList = []; + HospitalsModel _selectedHospital; + @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); var appoCountProvider = Provider.of(context); - List myMedicalList = Utils.myMedicalList(projectViewModel: projectViewModel, context: context, count: appoCountProvider.count, isLogin: projectViewModel.isLogin); + List myMedicalList = + Utils.myMedicalList(projectViewModel: projectViewModel, context: context, count: appoCountProvider.count, isLogin: projectViewModel.isLogin, onWeCareClick: openWeCareProjectSelection); return BaseView( onModelReady: (model) => model.getAppointmentHistory(isForTimeLine: true), builder: (_, model, widget1) => AppScaffold( @@ -99,6 +111,62 @@ class _MedicalProfilePageState extends State { ), ); } + + openWeCareProjectSelection() { + int _selectedHospitalIndex = -1; + int languageID = projectViewModel.isArabic ? 1 : 2; + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService service = new ClinicListService(); + List projectsListLocal = []; + service.getProjectsList(languageID, context).then((res) { + if (res['MessageStatus'] == 1) { + setState(() { + res['ListProject'].forEach((v) { + projectsListLocal.add(new HospitalsModel.fromJson(v)); + }); + projectsList = projectsListLocal; + }); + GifLoaderDialogUtils.hideDialog(context); + List list = [ + for (int i = 0; i < projectsList.length; i++) RadioSelectionDialogModel(projectsList[i].name + ' ${projectsList[i].distanceInKilometers} ' + TranslationBase.of(context).km, i), + ]; + showDialog( + context: context, + builder: (cxt) => RadioSelectionDialog( + buttonText: TranslationBase.of(context).confirm, + listData: list, + selectedIndex: _selectedHospitalIndex, + isScrollable: true, + onValueSelected: (index) { + _selectedHospitalIndex = index; + _selectedHospital = projectsList[index]; + openWeCareURL(_selectedHospital.iD); + // setState(() {}); + }, + ), + ); + } + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + }).catchError((err) { + print(err); + }); + } + + openWeCareURL(int projectID) { + GifLoaderDialogUtils.showMyDialog(context); + ClinicListService service = new ClinicListService(); + service.getWeCareURL(projectID).then((res) { + print(res["Consent_VirtualJurny_Url_GetByProjectIDList"][0]["Url"]); + Uri uri = Uri.parse(res["Consent_VirtualJurny_Url_GetByProjectIDList"][0]["Url"]); + GifLoaderDialogUtils.hideDialog(context); + launchUrl(uri, mode: LaunchMode.inAppWebView); + }).catchError((err) { + GifLoaderDialogUtils.hideDialog(context); + print(err); + AppToast.showErrorToast(message: err.toString()); + }); + } } class Medical { diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 1d848616..41c0b081 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -153,4 +153,16 @@ class ClinicListService extends BaseService { }, body: request); return Future.value(localRes); } + + Future getWeCareURL(int projectID) async { + Map request = {"ProjectID": projectID}; + dynamic localRes; + await baseAppClient.post(GET_WE_CARE_TOUR_URL, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); + } + } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 61009cb4..3d0eb100 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2918,6 +2918,8 @@ class TranslationBase { String get locationTimeoutError => localizedValues["locationTimeoutError"][locale.languageCode]; String get loadMore => localizedValues["loadMore"][locale.languageCode]; String get selectHospitalBloodDonation => localizedValues["selectHospitalBloodDonation"][locale.languageCode]; + String get wecare => localizedValues["wecare"][locale.languageCode]; + } diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index d93cec9b..a77579e2 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -222,7 +222,7 @@ class Utils { return RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email); } - static List myMedicalList({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count}) { + static List myMedicalList({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count, Function onWeCareClick}) { List medical = List(); medical.add(InkWell( @@ -381,6 +381,18 @@ class Utils { ), )); + medical.add(InkWell( + // onTap: () => projectViewModel.havePrivilege(85) ? Navigator.push(context, FadePage(page: AnicllaryOrders())) : null, + onTap: () => onWeCareClick(), + child: MedicalProfileItem( + title: TranslationBase.of(context).wecare, + imagePath: 'assets/images/new-design/virtual_tour_icon.png', + isPngImage: true, + subTitle: TranslationBase.of(context).service, + isEnable: projectViewModel.havePrivilege(85), + ), + )); + medical.add(InkWell( onTap: () => projectViewModel.havePrivilege(14) ? Navigator.push(context, FadePage(page: EyeMeasurementsPage())) : null, child: MedicalProfileItem( diff --git a/lib/widgets/dialogs/radio_selection_dialog.dart b/lib/widgets/dialogs/radio_selection_dialog.dart index dc460009..3a79bf47 100644 --- a/lib/widgets/dialogs/radio_selection_dialog.dart +++ b/lib/widgets/dialogs/radio_selection_dialog.dart @@ -15,11 +15,12 @@ class RadioSelectionDialog extends StatefulWidget { final int selectedIndex; final bool isScrollable; final bool isShowSearch; - - const RadioSelectionDialog({Key key, this.onValueSelected, this.listData, this.selectedIndex, this.isScrollable = false, this.isShowSearch = false}) : super(key: key); + final String buttonText; @override State createState() => new RadioSelectionDialogState(); + + const RadioSelectionDialog({Key key, this.onValueSelected, this.listData, this.selectedIndex, this.isScrollable = false, this.isShowSearch = false, this.buttonText = ""}) : super(key: key); } class RadioSelectionDialogState extends State { @@ -163,7 +164,7 @@ class RadioSelectionDialogState extends State { children: [ Expanded( child: DefaultButton( - TranslationBase.of(context).save, + widget.buttonText.isNotEmpty ? widget.buttonText : TranslationBase.of(context).save, () { Navigator.pop(context); widget.onValueSelected(selectedIndex);