From 05e4e7be45d8a56795db3b783ae5130b7212adc2 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 12:27:50 +0200 Subject: [PATCH] fix bottom bar in cart page --- lib/pages/final_products_page.dart | 7 +- lib/pages/parent_categorise_page.dart | 3 +- .../product-details/product-detail.dart | 6 +- .../shared/product_details_app_bar.dart | 13 +- lib/pages/sub_categorise_page.dart | 4 +- lib/uitl/utils.dart | 252 ++++++++++++++---- lib/widgets/others/app_scaffold_widget.dart | 4 +- lib/widgets/pharmacy/product_tile.dart | 6 +- 8 files changed, 220 insertions(+), 75 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index f65665b5..91e953ad 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/theme/colors.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' as utils ; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -21,6 +22,7 @@ import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; + dynamic languageID; class FinalProductsPage extends StatefulWidget { @@ -487,7 +489,10 @@ class _FinalProductsPageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.finalProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); + // Navigator.push(context, FadePage(page: CartOrderPage())); + utils.Utils.navigateToCartPage(); + + } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 34567267..65d9ea1c 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -12,6 +12,7 @@ import 'package:diplomaticquarterapp/theme/colors.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/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -859,7 +860,7 @@ class _ParentCategorisePageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.parentProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); + Utils.navigateToCartPage(); } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index baa92648..c4c1b26c 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -12,6 +12,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/sh import 'package:diplomaticquarterapp/uitl/app_shared_preferences.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/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; @@ -336,10 +337,7 @@ class __ProductDetailPageState extends State { await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); if(model.state != ViewState.ErrorLocal) - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); + Utils.navigateToCartPage(); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { diff --git a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart index 944e065c..f58438cf 100644 --- a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart @@ -2,9 +2,11 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; @@ -74,10 +76,13 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { icon: Icons.shopping_cart, color: Colors.grey[800], onPress: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => CartOrderPage()), - ); + + Navigator.pushAndRemoveUntil( + locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 3)), (Route r) => false); + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => CartOrderPage()), + // ); }), if (Provider.of(context, listen: false) diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index d5309383..92b20476 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/theme/colors.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/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -845,8 +846,7 @@ class _SubCategorisePageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.subProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); - } else { + Utils.navigateToCartPage(); } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } }), diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index d23b91b2..f20f4243 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -16,6 +16,7 @@ import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_card_screen.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; import 'package:diplomaticquarterapp/pages/medical/active_medications/ActiveMedicationsPage.dart'; import 'package:diplomaticquarterapp/pages/medical/allergies_page.dart'; import 'package:diplomaticquarterapp/pages/medical/ask_doctor/ask_doctor_home_page.dart'; @@ -44,13 +45,14 @@ import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import '../Constants.dart'; +import '../locator.dart'; import 'app_shared_preferences.dart'; import 'app_toast.dart'; import 'gif_loader_dialog_utils.dart'; +import 'navigation_service.dart'; AppSharedPreferences sharedPref = new AppSharedPreferences(); - class Utils { // static ProgressDialog pr; @@ -66,8 +68,10 @@ class Utils { /// Check The Internet Connection static Future checkConnection() async { - ConnectivityResult connectivityResult = await (Connectivity().checkConnectivity()); - if ((connectivityResult == ConnectivityResult.mobile) || (connectivityResult == ConnectivityResult.wifi)) { + ConnectivityResult connectivityResult = + await (Connectivity().checkConnectivity()); + if ((connectivityResult == ConnectivityResult.mobile) || + (connectivityResult == ConnectivityResult.wifi)) { return true; } else { return false; @@ -131,11 +135,19 @@ class Utils { } static String getAppointmentTransID(int projectID, int clinicID, int appoNo) { - return projectID.toString() + '-' + clinicID.toString() + '-' + appoNo.toString(); + return projectID.toString() + + '-' + + clinicID.toString() + + '-' + + appoNo.toString(); } static String getAdvancePaymentTransID(int projectID, int fileNumber) { - return projectID.toString() + '-' + fileNumber.toString() + '-' + DateTime.now().millisecondsSinceEpoch.toString(); + return projectID.toString() + + '-' + + fileNumber.toString() + + '-' + + DateTime.now().millisecondsSinceEpoch.toString(); } bool validateIDBox(String value, type) { @@ -195,14 +207,22 @@ class Utils { } static validEmail(email) { - return RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email); + 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}) { List medical = List(); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(5) ? Navigator.push(context, FadePage(page: MyAppointments())) : null, + onTap: () => projectViewModel.havePrivilege(5) + ? Navigator.push(context, FadePage(page: MyAppointments())) + : null, child: isLogin ? Stack(children: [ Container( @@ -229,7 +249,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -247,7 +271,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -274,7 +302,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(7) ? Navigator.push(context, FadePage(page: RadiologyHomePage())) : null, + onTap: () => projectViewModel.havePrivilege(7) + ? Navigator.push(context, FadePage(page: RadiologyHomePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).radiology, imagePath: 'radiology.svg', @@ -284,7 +314,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(12) ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) : null, + onTap: () => projectViewModel.havePrivilege(12) + ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medicines, imagePath: 'medicine_prescription.svg', @@ -310,7 +342,8 @@ class Utils { medical.add(InkWell( onTap: () { - if (projectViewModel.havePrivilege(48)) Navigator.push(context, FadePage(page: ActiveMedicationsPage())); + if (projectViewModel.havePrivilege(48)) + Navigator.push(context, FadePage(page: ActiveMedicationsPage())); }, child: MedicalProfileItem( title: TranslationBase.of(context).myMedical, @@ -329,12 +362,17 @@ class Utils { ), ) : null, - child: - MedicalProfileItem(title: TranslationBase.of(context).myDoctor, imagePath: 'my_doc.svg', subTitle: TranslationBase.of(context).myDoctorSubtitle, isEnable: projectViewModel.havePrivilege(6)), + child: MedicalProfileItem( + title: TranslationBase.of(context).myDoctor, + imagePath: 'my_doc.svg', + subTitle: TranslationBase.of(context).myDoctorSubtitle, + isEnable: projectViewModel.havePrivilege(6)), )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(14) ? Navigator.push(context, FadePage(page: MyInvoices())) : null, + onTap: () => projectViewModel.havePrivilege(14) + ? Navigator.push(context, FadePage(page: MyInvoices())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).invoicesList, imagePath: 'invoice_list.svg', @@ -344,7 +382,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(14) ? Navigator.push(context, FadePage(page: EyeMeasurementsPage())) : null, + onTap: () => projectViewModel.havePrivilege(14) + ? Navigator.push(context, FadePage(page: EyeMeasurementsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).eye, imagePath: 'eye_measurement.svg', @@ -354,7 +394,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(22) ? Navigator.push(context, FadePage(page: InsuranceCard())) : null, + onTap: () => projectViewModel.havePrivilege(22) + ? Navigator.push(context, FadePage(page: InsuranceCard())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).insurance, imagePath: 'insurance_card.svg', @@ -375,7 +417,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(18) ? Navigator.push(context, FadePage(page: InsuranceApproval())) : null, + onTap: () => projectViewModel.havePrivilege(18) + ? Navigator.push(context, FadePage(page: InsuranceApproval())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).insuranceApproval, imagePath: 'insurance_approval.svg', @@ -385,7 +429,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(23) ? Navigator.push(context, FadePage(page: AllergiesPage())) : null, + onTap: () => projectViewModel.havePrivilege(23) + ? Navigator.push(context, FadePage(page: AllergiesPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).allergies, imagePath: 'allergies_diagnosed.svg', @@ -395,7 +441,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(26) ? Navigator.push(context, FadePage(page: MyVaccines())) : null, + onTap: () => projectViewModel.havePrivilege(26) + ? Navigator.push(context, FadePage(page: MyVaccines())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myVaccines, imagePath: 'vaccine_list.svg', @@ -405,7 +453,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(20) ? Navigator.push(context, FadePage(page: HomeReportPage())) : null, + onTap: () => projectViewModel.havePrivilege(20) + ? Navigator.push(context, FadePage(page: HomeReportPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medical, imagePath: 'medical_report.svg', @@ -415,7 +465,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(19) ? Navigator.push(context, FadePage(page: MonthlyReportsPage())) : null, + onTap: () => projectViewModel.havePrivilege(19) + ? Navigator.push(context, FadePage(page: MonthlyReportsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).monthly, imagePath: 'monthly_report.svg', @@ -425,7 +477,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(16) ? Navigator.push(context, FadePage(page: PatientSickLeavePage())) : null, + onTap: () => projectViewModel.havePrivilege(16) + ? Navigator.push(context, FadePage(page: PatientSickLeavePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).sick, imagePath: 'sick_leave.svg', @@ -435,7 +489,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(47) ? Navigator.push(context, FadePage(page: MyBalancePage())) : null, + onTap: () => projectViewModel.havePrivilege(47) + ? Navigator.push(context, FadePage(page: MyBalancePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myBalance, imagePath: 'balance_credit.svg', @@ -452,7 +508,9 @@ class Utils { // )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(24) ? Navigator.push(context, FadePage(page: MyTrackers())) : null, + onTap: () => projectViewModel.havePrivilege(24) + ? Navigator.push(context, FadePage(page: MyTrackers())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myTrackers, imagePath: 'tracker.svg', @@ -462,7 +520,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(30) ? Navigator.push(context, FadePage(page: SmartWatchInstructions())) : null, + onTap: () => projectViewModel.havePrivilege(30) + ? Navigator.push(context, FadePage(page: SmartWatchInstructions())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).smartWatchesSubtitle, imagePath: 'smart_watch.svg', @@ -472,9 +532,14 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(28) ? Navigator.push(context, FadePage(page: AskDoctorHomPage())) : null, + onTap: () => projectViewModel.havePrivilege(28) + ? Navigator.push(context, FadePage(page: AskDoctorHomPage())) + : null, child: MedicalProfileItem( - title: TranslationBase.of(context).askYourSubtitle, imagePath: 'ask_doctor.svg', subTitle: TranslationBase.of(context).askYour, isEnable: projectViewModel.havePrivilege(28)), + title: TranslationBase.of(context).askYourSubtitle, + imagePath: 'ask_doctor.svg', + subTitle: TranslationBase.of(context).askYour, + isEnable: projectViewModel.havePrivilege(28)), )); if (projectViewModel.havePrivilege(32) || true) { @@ -484,13 +549,18 @@ class Utils { if (projectViewModel.isLogin && userData_ != null) { String patientID = userData_.patientID.toString(); GifLoaderDialogUtils.showMyDialog(context); - projectViewModel.platformBridge().connectHMGInternetWifi(patientID).then((value) => {GifLoaderDialogUtils.hideDialog(context)}).catchError((err) { + projectViewModel + .platformBridge() + .connectHMGInternetWifi(patientID) + .then((value) => {GifLoaderDialogUtils.hideDialog(context)}) + .catchError((err) { print(err.toString()); }); } else { AlertDialogBox( context: context, - confirmMessage: "Please login with your account first to use this feature", + confirmMessage: + "Please login with your account first to use this feature", okText: "OK", okFunction: () { AlertDialogBox.closeAlertDialog(context); @@ -507,7 +577,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(40) ? launch('whatsapp://send?phone=18885521858&text=') : null, + onTap: () => projectViewModel.havePrivilege(40) + ? launch('whatsapp://send?phone=18885521858&text=') + : null, child: MedicalProfileItem( title: TranslationBase.of(context).chatbot, imagePath: 'chatbot.svg', @@ -519,13 +591,17 @@ class Utils { return medical; } - - - static List myMedicalListHomePage({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count}) { + static List myMedicalListHomePage( + {ProjectViewModel projectViewModel, + BuildContext context, + bool isLogin, + count}) { List medical = List(); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(5) ? Navigator.push(context, FadePage(page: MyAppointments())) : null, + onTap: () => projectViewModel.havePrivilege(5) + ? Navigator.push(context, FadePage(page: MyAppointments())) + : null, child: isLogin ? Stack(children: [ MedicalProfileItem( @@ -548,7 +624,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -566,7 +646,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -593,7 +677,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(7) ? Navigator.push(context, FadePage(page: RadiologyHomePage())) : null, + onTap: () => projectViewModel.havePrivilege(7) + ? Navigator.push(context, FadePage(page: RadiologyHomePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).radiology, imagePath: 'radiology.svg', @@ -603,7 +689,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(12) ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) : null, + onTap: () => projectViewModel.havePrivilege(12) + ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medicines, imagePath: 'medicine_prescription.svg', @@ -621,19 +709,24 @@ class Utils { ), ) : null, - child: - MedicalProfileItem(title: TranslationBase.of(context).myDoctor, imagePath: 'my_doc.svg', subTitle: TranslationBase.of(context).myDoctorSubtitle, isEnable: projectViewModel.havePrivilege(6)), + child: MedicalProfileItem( + title: TranslationBase.of(context).myDoctor, + imagePath: 'my_doc.svg', + subTitle: TranslationBase.of(context).myDoctorSubtitle, + isEnable: projectViewModel.havePrivilege(6)), )); return medical; } - static Widget loadNetworkImage({@required String url, BoxFit fitting = BoxFit.cover}) { + static Widget loadNetworkImage( + {@required String url, BoxFit fitting = BoxFit.cover}) { return CachedNetworkImage( placeholderFadeInDuration: Duration(milliseconds: 250), fit: fitting, imageUrl: url, - placeholder: (context, url) => Container(child: Center(child: CircularProgressIndicator())), + placeholder: (context, url) => + Container(child: Center(child: CircularProgressIndicator())), errorWidget: (context, url, error) { return Icon( Icons.error, @@ -650,6 +743,14 @@ class Utils { return route.runtimeType == equalsTo; } + static navigateToCartPage() { + Navigator.pushAndRemoveUntil( + locator().navigatorKey.currentContext, + MaterialPageRoute( + builder: (context) => LandingPagePharmacy(currentTab: 3)), + (Route r) => false); + } + static Widget tableColumnTitle(String text, {bool showDivider = true}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -658,7 +759,12 @@ class Utils { SizedBox(height: 6), Text( text, - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 18 / 12), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.48, + height: 18 / 12), ), SizedBox(height: 5), if (showDivider) @@ -671,16 +777,27 @@ class Utils { ); } - static Widget tableColumnValue(String text, {bool isLast = false, bool isCapitable = true, ProjectViewModel mProjectViewModel}) { - ProjectViewModel projectViewModel = mProjectViewModel ?? Provider.of(AppGlobal.context); + static Widget tableColumnValue(String text, + {bool isLast = false, + bool isCapitable = true, + ProjectViewModel mProjectViewModel}) { + ProjectViewModel projectViewModel = + mProjectViewModel ?? Provider.of(AppGlobal.context); return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ SizedBox(height: 12), Text( - isCapitable && !projectViewModel.isArabic ? text.toLowerCase().capitalizeFirstofEach : text, - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + isCapitable && !projectViewModel.isArabic + ? text.toLowerCase().capitalizeFirstofEach + : text, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff575757), + letterSpacing: -0.4, + height: 16 / 10), ), SizedBox(height: 12), if (!isLast) @@ -693,7 +810,8 @@ class Utils { ); } - static Widget tableColumnValueWithUnderLine(String text, {bool isLast = false, bool isCapitable = true}) { + static Widget tableColumnValueWithUnderLine(String text, + {bool isLast = false, bool isCapitable = true}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, @@ -704,7 +822,13 @@ class Utils { isCapitable ? text.toLowerCase().capitalizeFirstofEach : text, maxLines: 1, minFontSize: 6, - style: TextStyle(decoration: TextDecoration.underline, fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xffD02127), letterSpacing: -0.48, height: 18 / 12), + style: TextStyle( + decoration: TextDecoration.underline, + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xffD02127), + letterSpacing: -0.48, + height: 18 / 12), ), SizedBox(height: 10), if (!isLast) @@ -718,7 +842,13 @@ class Utils { } } -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}) { +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}) { return Container( decoration: BoxDecoration( boxShadow: [ @@ -735,7 +865,8 @@ Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, doubl } Future userData() async { - var userData = AuthenticatedUser.fromJson(await AppSharedPreferences().getObject(MAIN_USER)); + var userData = AuthenticatedUser.fromJson( + await AppSharedPreferences().getObject(MAIN_USER)); return userData; } @@ -749,9 +880,12 @@ extension IndexedIterable on Iterable { openAppStore({String androidPackageName, String iOSAppID}) async { if (Platform.isAndroid) { - assert(!(androidPackageName == null), "Should have valid value in androidPackageName parameter"); - if ((await FlutterHmsGmsAvailability.isGmsAvailable)) launch("market://details?id=com.ejada.hmg"); - if ((await FlutterHmsGmsAvailability.isHmsAvailable)) launch("appmarket://details?id=com.ejada.hmg"); + assert(!(androidPackageName == null), + "Should have valid value in androidPackageName parameter"); + if ((await FlutterHmsGmsAvailability.isGmsAvailable)) + launch("market://details?id=com.ejada.hmg"); + if ((await FlutterHmsGmsAvailability.isHmsAvailable)) + launch("appmarket://details?id=com.ejada.hmg"); } else if (Platform.isIOS) { assert((iOSAppID == null), "Should have valid value in iOSAppID parameter"); launch("https://itunes.apple.com/kr/app/apple-store/$iOSAppID)"); @@ -777,7 +911,11 @@ String labelFrom({@required String className}) { extension StringExtension on String { String capitalize() { - return this.splitMapJoin(RegExp(r'\w+'), onMatch: (m) => '${m.group(0)}'.substring(0, 1).toUpperCase() + '${m.group(0)}'.substring(1).toLowerCase(), onNonMatch: (n) => ' '); + return this.splitMapJoin(RegExp(r'\w+'), + onMatch: (m) => + '${m.group(0)}'.substring(0, 1).toUpperCase() + + '${m.group(0)}'.substring(1).toLowerCase(), + onNonMatch: (n) => ' '); } } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 8772a60e..0dc0f318 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -21,6 +21,7 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.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/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart'; @@ -494,8 +495,7 @@ class AppBarWidgetState extends State { icon: Badge(badgeContent: Text(orderPreviewViewModel.cartResponse.quantityCount.toString()), child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { - // Navigator.of(context).popUntil(ModalRoute.withName('/')); - Navigator.of(context).popAndPushNamed(CART_ORDER_PAGE); + Utils.navigateToCartPage(); }) : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 70a727bf..b7293ce1 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-ord import 'package:diplomaticquarterapp/pages/pharmacy/order/ProductReview.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/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -165,10 +166,7 @@ class productTile extends StatelessWidget { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, productID, context); GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); + Utils.navigateToCartPage(); }, ), ],