import 'dart:io'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; import 'package:diplomaticquarterapp/models/hmg_services.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/%E2%80%8B%20health_calculators.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/e_referral_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/h2o_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/health_converter.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/my_web_view.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/parking_page.dart'; import 'package:diplomaticquarterapp/pages/Blood/blood_donation.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart'; import 'package:diplomaticquarterapp/pages/ChildVaccines/new/child_initial_page.dart'; import 'package:diplomaticquarterapp/pages/ContactUs/contact_us_page.dart'; import 'package:diplomaticquarterapp/pages/Covid-DriveThru/covid-drivethru-location.dart'; import 'package:diplomaticquarterapp/pages/DrawerPages/family/my-family.dart'; import 'package:diplomaticquarterapp/pages/ErService/ErOptions.dart'; import 'package:diplomaticquarterapp/pages/InPatientServices/inpatient_home.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/livecare/livecare_home.dart'; import 'package:diplomaticquarterapp/pages/medical/medical_profile_page_new.dart'; import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/smart_watch_instructions.dart'; import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_screen.dart'; import 'package:diplomaticquarterapp/pages/paymentService/payment_service.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/covid_consent_dialog.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../../locator.dart'; import '../../MyAppointments/MyAppointments.dart'; import '../../medical/active_medications/ActiveMedicationsPage.dart'; import '../../medical/doctor/doctor_home_page.dart'; import '../../medical/labs/labs_home_page.dart'; import '../../medical/prescriptions/prescriptions_home_page.dart'; import '../../medical/radiology/radiology_home_page.dart'; import '../landing_page_pharmcy.dart'; class ServicesView extends StatelessWidget { HmgServices hmgServices; int index; AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); PharmacyModuleViewModel pharmacyModuleViewModel = locator(); late LocationUtils locationUtils; bool isHomePage; ProjectViewModel? projectViewModel; ServicesView(this.hmgServices, this.index, this.isHomePage); @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); return InkWell( onTap: () { if (isHomePage) { handleHomePageServices(hmgServices, context); } else { handleAllServices(hmgServices, context); } }, child: Container( width: double.infinity, height: double.infinity, decoration: containerRadiusWithGradientServices(20, lightColor: CustomColors.lightGreyColor, darkColor: CustomColors.darkGreyColor), child: Stack( children: [ Container( width: double.infinity, height: double.infinity, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ mFlex(1), Flexible( flex: 8, child: Column( children: [ Flexible( flex: 5, child: Padding( padding: const EdgeInsets.all(12.0), child: Opacity( opacity: 0.04, child: hmgServices.action == 5 ? Image.asset( hmgServices.icon, width: double.infinity, height: double.infinity, ) : SvgPicture.asset( hmgServices.icon, width: double.infinity, height: double.infinity, ), ), ), ), mFlex(1), ], ), ), ], ), ), Container( width: double.infinity, height: double.infinity, padding: EdgeInsets.only( left: SizeConfig.widthMultiplier! * 3, right: SizeConfig.widthMultiplier! * 3, top: SizeConfig.widthMultiplier! * 3, bottom: SizeConfig.widthMultiplier! * 2), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ mFlex(1), hmgServices.action == (isHomePage ? 5 : 8) ? Image.asset( hmgServices.icon, height: index == 0 ? MediaQuery.of(context).size.width / 18 : MediaQuery.of(context).size.width / 18, ) : Container( // color: Colors.yellow, width: index == 4 ? MediaQuery.of(context).size.width / 12 : MediaQuery.of(context).size.width / 12, height: index == 4 ? MediaQuery.of(context).size.width / 10 : MediaQuery.of(context).size.width / 12, child: SvgPicture.asset( hmgServices.icon, // width: MediaQuery.of(context).size.width / 12, // height: MediaQuery.of(context).size.width / 12, ), ), mFlex(4), AutoSizeText( hmgServices.title, maxLines: 1, minFontSize: 10, style: TextStyle( fontSize: SizeConfig.textMultiplier! * 1.6, fontWeight: FontWeight.bold, letterSpacing: -0.39, height: 0.8, ), ), AutoSizeText( hmgServices.subTitle, maxLines: 1, minFontSize: 8, style: TextStyle( fontSize: SizeConfig.textMultiplier! * 1.4, letterSpacing: -0.27, fontWeight: FontWeight.w600, ), ), mFlex(1), ], ), ), ], ), ), ); } handleHomePageServices(HmgServices hmgServices, BuildContext context) { if (hmgServices.action == 0) { Navigator.push(context, FadePage(page: Search())); locator().hmgServices.logServiceName('book appointment'); } else if (hmgServices.action == 1) { openLiveCare(context); } else if (hmgServices.action == 2) { Navigator.push(context, FadePage(page: ErOptions(isAppbar: true))); locator().hmgServices.logServiceName('emergency service'); } else if (hmgServices.action == 3) { Navigator.push(context, FadePage(page: HomeHealthCarePage())); locator().hmgServices.logServiceName('home health care'); } else if (hmgServices.action == 4) { Navigator.push(context, FadePage(page: CMCPage())); locator() .hmgServices .logServiceName('comprehensive medical checkup'); } else if (hmgServices.action == 5) { Navigator.push(context, FadePage(page: PaymentService())); locator().hmgServices.logServiceName('online payments'); } else if (hmgServices.action == 6) { Navigator.push(context, FadePage(page: EReferralPage())); locator().hmgServices.logServiceName('e-referral service'); } else if (hmgServices.action == 7) { showCovidDialog(context); locator().hmgServices.logServiceName('covid-test drive-thru'); } else if (hmgServices.action == 8) { Navigator.push(context, FadePage(page: ContactUsPage())); locator().hmgServices.logServiceName('find us reach us'); } else if (hmgServices.action == 23) { Navigator.push(context, FadePage(page: InPatientServicesHome())); locator().hmgServices.logServiceName('find us reach us'); } else if (hmgServices.action == 31) { Navigator.push(context, FadePage(page: MedicalProfilePageNew())); locator().hmgServices.logServiceName('my medical file'); } else if (hmgServices.action == 24 && projectViewModel?.havePrivilege(5) == true) { Navigator.push(context, FadePage(page: MyAppointments())); locator().hmgServices.logServiceName('my appointment'); } else if (hmgServices.action == 25) { Navigator.push(context, FadePage(page: LabsHomePage())); locator().hmgServices.logServiceName('lab result'); } else if (hmgServices.action == 26 && projectViewModel?.havePrivilege(7) == true) { Navigator.push(context, FadePage(page: RadiologyHomePage())); locator().hmgServices.logServiceName('radiology result'); } else if (hmgServices.action == 27 && projectViewModel?.havePrivilege(12) == true) { Navigator.push(context, FadePage(page: HomePrescriptionsPage())); locator().hmgServices.logServiceName('medicine prescription'); } else if (hmgServices.action == 28 && projectViewModel?.havePrivilege(25) == true) { Navigator.push( context, FadePage(page: VitalSignDetailsScreen()), ); locator().hmgServices.logServiceName('vital signs'); } else if (hmgServices.action == 29 && projectViewModel?.havePrivilege(48) == true) { Navigator.push(context, FadePage(page: ActiveMedicationsPage())); locator().hmgServices.logServiceName('active medication'); } else if (hmgServices.action == 30 && projectViewModel?.havePrivilege(6) == true) { Navigator.push( context, FadePage( page: DoctorHomePage(), ), ); locator().hmgServices.logServiceName('active medication'); } } handleAllServices(HmgServices hmgServices, BuildContext context) { if (hmgServices.action == 0) { Navigator.push(context, FadePage(page: Search())); locator().hmgServices.logServiceName('book appointment'); } else if (hmgServices.action == 1) { openLiveCare(context); } else if (hmgServices.action == 2) { Navigator.push(context, FadePage(page: ErOptions(isAppbar: true))); locator().hmgServices.logServiceName('emergency service'); } else if (hmgServices.action == 3) { Navigator.push(context, FadePage(page: HomeHealthCarePage())); locator().hmgServices.logServiceName('home health care'); } else if (hmgServices.action == 4) { Navigator.push(context, FadePage(page: CMCPage())); locator() .hmgServices .logServiceName('comprehensive medical checkup'); } else if (hmgServices.action == 5) { // getPharmacyToken(context); Uri uri = Uri.parse(PHARMACY_REDIRECT_URL); launchUrl(uri, mode: LaunchMode.externalApplication); locator().hmgServices.logServiceName('al habib pharmacy'); } else if (hmgServices.action == 6) { Navigator.push(context, FadePage(page: MedicalProfilePageNew())); } else if (hmgServices.action == 7) { Navigator.push(context, FadePage(page: MyFamily())); locator().hmgServices.logServiceName('my family files'); } else if (hmgServices.action == 8) { Navigator.push(context, FadePage(page: PaymentService())); locator().hmgServices.logServiceName('online payments'); } else if (hmgServices.action == 9) { Navigator.push(context, FadePage(page: ChildInitialPage())); locator().hmgServices.logServiceName('my child vaccines'); } else if (hmgServices.action == 10) { Navigator.push(context, FadePage(page: InsuranceUpdate())); locator().hmgServices.logServiceName('update insurance'); } else if (hmgServices.action == 11) { Navigator.push(context, FadePage(page: EReferralPage())); locator().hmgServices.logServiceName('e-referral service'); } else if (hmgServices.action == 12) { Navigator.push(context, FadePage(page: H2OPage())); locator().hmgServices.logServiceName('water consumption'); } else if (hmgServices.action == 13) { Navigator.push(context, FadePage(page: (HealthCalculators()))); locator().hmgServices.logServiceName('health calculator'); } else if (hmgServices.action == 14) { Navigator.push(context, FadePage(page: HealthConverter())); locator().hmgServices.logServiceName('heath converters'); } else if (hmgServices.action == 15) { Navigator.pop(context); LandingPage.shared.switchToDoFromHMGServices(); locator().hmgServices.logServiceName('todo list'); } else if (hmgServices.action == 16) { Navigator.push(context, FadePage(page: BloodDonationPage())); locator().hmgServices.logServiceName('blood donation'); } else if (hmgServices.action == 17) { showCovidDialog(context); locator().hmgServices.logServiceName('covid-test drive-thru'); } else if (hmgServices.action == 18) { launch("https://hmgwebservices.com/vt_mobile/html/index.html"); locator().hmgServices.logServiceName('virtual tour'); } else if (hmgServices.action == 19) { Navigator.push(context, FadePage(page: SmartWatchInstructions())); locator().hmgServices.logServiceName('smart watches'); } else if (hmgServices.action == 20) { Navigator.push(context, FadePage(page: ParkingPage())); locator().hmgServices.logServiceName('car parcking service'); } else if (hmgServices.action == 21) { Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) => MyWebView( title: "HMG News", selectedUrl: "https://twitter.com/hmg" //"https://twitter.com/hashtag/مجموعة_د_سليمان_الحبيب_الطبية?src=hashtag_click&f=live", ), ), ); locator().hmgServices.logServiceName('latest news'); } else if (hmgServices.action == 22) { Navigator.push(context, FadePage(page: ContactUsPage())); locator().hmgServices.logServiceName('find us reach us'); } else if (hmgServices.action == 31) { Navigator.push(context, FadePage(page: MedicalProfilePageNew())); locator().hmgServices.logServiceName('my medical file'); } // if (hmgServices.action == 10) { // openLiveCare(context); // } else if (index == 1) { // showCovidDialog(context); // locator().hmgServices.logServiceName('covid-test drive-thru'); // } else if (index == 2) { // Navigator.push(context, FadePage(page: PaymentService())); // locator().hmgServices.logServiceName('online payments'); // } else if (index == 3) { // Navigator.push(context, FadePage(page: HomeHealthCarePage())); // locator().hmgServices.logServiceName('home health care'); // } else if (index == 4) { // Navigator.push(context, FadePage(page: CMCPage())); // locator().hmgServices.logServiceName('comprehensive medical checkup'); // } else if (index == 5) { // Navigator.push(context, FadePage(page: ErOptions(isAppbar: true))); // locator().hmgServices.logServiceName('emergency service'); // } else if (index == 6) { // Navigator.push(context, FadePage(page: EReferralPage())); // locator().hmgServices.logServiceName('e-referral service'); // } else if (index == 7) { // Navigator.push(context, FadePage(page: H2OPage())); // locator().hmgServices.logServiceName('water consumption'); // } else if (index == 8) { // Navigator.push(context, FadePage(page: ContactUsPage())); // locator().hmgServices.logServiceName('find us reach us'); // } else if (index == 9) { // Navigator.push( // context, // FadePage( // page: MedicalProfilePageNew(), // ), // ); // locator().hmgServices.logServiceName('my medical details'); // } else if (index == 10) { // Navigator.push( // context, // FadePage( // page: Search(), // ), // ); // locator().hmgServices.logServiceName('book appointment'); // } else if (index == 11) { // getPharmacyToken(context); // locator().hmgServices.logServiceName('al habib pharmacy'); // } else if (index == 12) { // Navigator.push( // context, // FadePage( // page: InsuranceUpdate(), // ), // ); // locator().hmgServices.logServiceName('update insurance'); // } else if (index == 13) { // Navigator.push( // context, // FadePage( // page: MyFamily(), // ), // ); // locator().hmgServices.logServiceName('my family files'); // } else if (index == 14) { // Navigator.push( // context, // FadePage(page: ChildInitialPage()), // ); // locator().hmgServices.logServiceName('my child vaccines'); // } else if (index == 15) { // LandingPage.shared.switchToDoFromHMGServices(); // locator().hmgServices.logServiceName('todo list'); // } else if (index == 16) { // Navigator.push( // context, // FadePage(page: BloodDonationPage()), // ); // locator().hmgServices.logServiceName('blood donation'); // } else if (index == 17) { // Navigator.push( // context, // FadePage( // page: (HealthCalculators()), // ), // ); // locator().hmgServices.logServiceName('health calculator'); // } else if (index == 18) { // Navigator.push( // context, // FadePage( // page: HealthConverter(), // ), // ); // locator().hmgServices.logServiceName('heath converters'); // } else if (index == 19) { // Navigator.push( // context, // FadePage(page: SmartWatchInstructions()), // ); // locator().hmgServices.logServiceName('smart watches'); // } else if (index == 20) { // locator().hmgServices.logServiceName('car parcking service'); // Navigator.push( // context, // FadePage( // page: ParkingPage(), // ), // ); // } else if (index == 21) { // launch("https://hmgwebservices.com/vt_mobile/html/index.html"); // locator().hmgServices.logServiceName('virtual tour'); // } else if (index == 22) { // Navigator.of(context).push( // MaterialPageRoute( // builder: (BuildContext context) => MyWebView( // title: "HMG News", // selectedUrl: "https://twitter.com/hashtag/مجموعة_د_سليمان_الحبيب_الطبية?src=hashtag_click&f=live", // ), // ), // ); // locator().hmgServices.logServiceName('latest news'); // } } showCovidDialog(BuildContext context) { if (Platform.isAndroid) { showDialog( context: context, builder: (cxt) => CovidConsentDialog( okTitle: TranslationBase.of(context).acceptLbl, title: TranslationBase.of(context).covidConsentHeader, message: TranslationBase.of(context).covidConsent, onTap: () async { Navigator.push( context, FadePage(page: CovidDrivethruLocation())); }, )); } else { Navigator.push(context, FadePage(page: CovidDrivethruLocation())); } } openLiveCare(BuildContext context) { locator().hmgServices.logServiceName('live care service'); Navigator.push(context, FadePage(page: LiveCareHome())).then((value) { LiveCareHome.isLiveCareTypeSelected = false; }); } getPharmacyToken(BuildContext context) async { if (!authProvider.isLogin) { Navigator.push(context, FadePage(page: LandingPagePharmacy())); } else { GifLoaderDialogUtils.showMyDialog(context); await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { if (pharmacyModuleViewModel.error.isNotEmpty) { await pharmacyModuleViewModel.createUser().then((value) { GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: LandingPagePharmacy())); }); } else { GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: LandingPagePharmacy())); } }); } } }