From 6efb3163770bc181a52df7bae3ea2b5e6e73ff6f Mon Sep 17 00:00:00 2001 From: Haroon Amjad <> Date: Wed, 11 Sep 2024 15:27:37 +0300 Subject: [PATCH] homepage updates --- .../fragments/home_page_fragment2.dart | 12 ++--- lib/pages/landing/widgets/services_view.dart | 48 +++++++++++++++++-- lib/uitl/utils.dart | 26 +++++++++- 3 files changed, 75 insertions(+), 11 deletions(-) diff --git a/lib/pages/landing/fragments/home_page_fragment2.dart b/lib/pages/landing/fragments/home_page_fragment2.dart index 1c77020e..a2cf936a 100644 --- a/lib/pages/landing/fragments/home_page_fragment2.dart +++ b/lib/pages/landing/fragments/home_page_fragment2.dart @@ -297,15 +297,16 @@ class _HomePageFragment2State extends State { child: ServicesView( new HmgServices(23, TranslationBase.of(context).InPatient, TranslationBase.of(context).inPatientServices, "assets/images/new/InPatient.svg", false), 23, - true, projectViewModel)), + true, + projectViewModel)), ), ), Expanded( flex: 4, child: AspectRatio( aspectRatio: 1.0, - child: ServicesView( - new HmgServices(5, TranslationBase.of(context).online, TranslationBase.of(context).payment, "assets/images/new/paymentMethods.png", false), 2, true, projectViewModel)), + child: ServicesView(new HmgServices(5, TranslationBase.of(context).online, TranslationBase.of(context).payment, "assets/images/new/paymentMethods.png", false), 2, + true, projectViewModel)), ), ], ), @@ -342,7 +343,7 @@ class _HomePageFragment2State extends State { itemCount: hmgServices.length, padding: EdgeInsets.zero, itemBuilder: (BuildContext context, int index) { - return ServicesView(hmgServices[index], index, true, projectViewModel); + return ServicesView(hmgServices[index], index, true, projectViewModel, isLocked: hmgServices[index].action == 2 ? !projectViewModel.havePrivilege(107) : false); }, ), ), @@ -490,8 +491,7 @@ class _HomePageFragment2State extends State { flex: 1, child: InkWell( onTap: () { - if (projectViewModel.havePrivilege(100)) - widget.onPharmacyClick!(); + if (projectViewModel.havePrivilege(100)) widget.onPharmacyClick!(); }, child: Stack(children: [ Container( diff --git a/lib/pages/landing/widgets/services_view.dart b/lib/pages/landing/widgets/services_view.dart index 7109ad9a..2527d3a0 100644 --- a/lib/pages/landing/widgets/services_view.dart +++ b/lib/pages/landing/widgets/services_view.dart @@ -4,6 +4,7 @@ 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/model/hospitals/hospitals_model.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'; @@ -37,8 +38,10 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/uitl/penguin_method_channel.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/covid_consent_dialog.dart'; +import 'package:diplomaticquarterapp/widgets/dialogs/radio_selection_dialog.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -57,8 +60,9 @@ class ServicesView extends StatelessWidget { late LocationUtils locationUtils; bool isHomePage; late ProjectViewModel projectViewModel; + bool isLocked; - ServicesView(this.hmgServices, this.index, this.isHomePage, this.projectViewModel); + ServicesView(this.hmgServices, this.index, this.isHomePage, this.projectViewModel, {this.isLocked = false}); @override Widget build(BuildContext context) { @@ -164,13 +168,48 @@ class ServicesView extends StatelessWidget { ], ), ), + isLocked + ? Container( + width: double.infinity, + height: double.infinity, + decoration: containerRadiusWithGradientServices(20, lightColor: Colors.grey.withOpacity(0.6), darkColor: Colors.grey.withOpacity(0.6)), + child: Icon( + Icons.lock_outline, + size: 40, + ), + ) + : Container() ], ), ), ); } - initPenguinSDK() async { + openNavigationProjectSelection(BuildContext context) { + int _selectedHospitalIndex = 0; + List projectsListLocal = []; + Utils.navigationProjectsList.forEach((v) { + projectsListLocal.add(new HospitalsModel.fromJson(v)); + }); + List list = [ + for (int i = 0; i < projectsListLocal.length; i++) RadioSelectionDialogModel(projectsListLocal[i].name! + ' ${projectsListLocal[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; + initPenguinSDK(projectsListLocal[index].iD); + }, + ), + ); + } + + initPenguinSDK(int projectID) async { final bool permited = await AppPermission.askPenguinPermissions(); if (!permited) { Map statuses = await [ @@ -182,7 +221,7 @@ class ServicesView extends StatelessWidget { ].request().whenComplete(() { PenguinMethodChannel.launch("penguin", projectViewModel.isArabic ? "ar" : "en", "1231755"); }); - } + } // } handleHomePageServices(HmgServices hmgServices, BuildContext context) { @@ -192,7 +231,8 @@ class ServicesView extends StatelessWidget { } else if (hmgServices.action == 1) { openLiveCare(context); } else if (hmgServices.action == 2) { - initPenguinSDK(); + // initPenguinSDK(); + if (!isLocked) openNavigationProjectSelection(context); // Navigator.push(context, FadePage(page: ErOptions(isAppbar: true))); // locator().hmgServices.logServiceName('emergency service'); } else if (hmgServices.action == 3) { diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index 9b59e200..42b25b55 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -65,6 +65,30 @@ AppSharedPreferences sharedPref = new AppSharedPreferences(); class Utils { // static ProgressDialog pr; + static var navigationProjectsList = [ + { + "Desciption": "Sahafa Hospital", + "DesciptionN": null, + "ID": 130, + "LegalName": "Sahafa Hospital", + "LegalNameN": "مستشفى الصحافة", + "Name": "Sahafa Hospital", + "NameN": null, + "PhoneNumber": "+966115222222", + "SetupID": "013311", + "DistanceInKilometers": 0, + "HasVida3": false, + "IsActive": true, + "IsHmg": true, + "IsVidaPlus": false, + "Latitude": "24.8113774", + "Longitude": "46.6239813", + "MainProjectID": 130, + "ProjectOutSA": false, + "UsingInDoctorApp": false + } + ]; + ///show custom Error Toast /// [message] to show for user static showErrorToast([String? message]) { @@ -908,7 +932,7 @@ class Utils { return projectDetailListModel; } - //static String generateSignature() {} +//static String generateSignature() {} } Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, double spreadRadius = 2, double blurRadius = 7, Offset offset = const Offset(2, 2), required Widget child}) {