From 8d6278a59be2f1f6bc1ac0b40c8b61b03bf3d0b5 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 1 Nov 2021 18:38:23 +0300 Subject: [PATCH] Pharmacy fixes --- .../parmacyModule/order-preview-service.dart | 8 +- .../pharmacyModule/OrderPreviewViewModel.dart | 14 +-- .../ClinicOfferAndPackagesPage.dart | 4 +- .../packages_offers/OfferAndPackagesPage.dart | 2 +- .../screens/cart-page/cart-order-page.dart | 8 +- .../cart-page/payment_bottom_widget.dart | 2 +- .../cart-page/select_address_widget.dart | 8 +- .../screens/pharmacy_module_page.dart | 2 +- .../product-details/product-detail.dart | 95 +++++--------- .../widgets/home/PrescriptionsWidget.dart | 2 +- lib/widgets/others/app_scaffold_widget.dart | 116 ++++++++++-------- .../pharmacy/bottom_nav_pharmacy_bar.dart | 4 - 12 files changed, 123 insertions(+), 142 deletions(-) diff --git a/lib/core/service/parmacyModule/order-preview-service.dart b/lib/core/service/parmacyModule/order-preview-service.dart index 0364d64f..0fc6f79a 100644 --- a/lib/core/service/parmacyModule/order-preview-service.dart +++ b/lib/core/service/parmacyModule/order-preview-service.dart @@ -144,12 +144,12 @@ class OrderPreviewService extends BaseService { return Future.value(localRes); } - Future getLacumAccountInformation() async { + Future getLacumAccountInformation(String identificationNo) async { hasError = false; super.error = ""; Map body = Map(); - body['IdentificationNo'] = user.patientIdentificationNo; + body['IdentificationNo'] = identificationNo; try { await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION, @@ -164,12 +164,12 @@ class OrderPreviewService extends BaseService { } } - Future getLacumGroupInformation() async { + Future getLacumGroupInformation(String identificationNo) async { hasError = false; super.error = ""; Map body = Map(); - body['IdentificationNo'] = user.patientIdentificationNo; + body['IdentificationNo'] = identificationNo; body['AccountNumber'] = "${lacumInformation.yahalaAccountNo}"; try { diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index e9c32f2b..d3f09119 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -161,25 +161,25 @@ class OrderPreviewViewModel extends BaseViewModel { return _orderService.getPaymentOptionName(paymentOption); } - getInformationsByAddress() async { - await getLacumAccountInformation(); + getInformationsByAddress(String identificationNo) async { await getShippingOption(); + await getLacumAccountInformation(identificationNo); } - getLacumAccountInformation() async { + getLacumAccountInformation(String identificationNo) async { setState(ViewState.Busy); - await _orderService.getLacumAccountInformation(); + await _orderService.getLacumAccountInformation(identificationNo); if (_orderService.hasError) { error = _orderService.error; setState(ViewState.Error); } else { - getLacumGroupData(); + getLacumGroupData(identificationNo); } } - Future getLacumGroupData() async { + Future getLacumGroupData(String identificationNo) async { setState(ViewState.Busy); - await _orderService.getLacumGroupInformation(); + await _orderService.getLacumGroupInformation(identificationNo); paymentCheckoutData.lacumInformation = _orderService.lacumGroupInformation; paymentCheckoutData.usedLakumPoints = paymentCheckoutData .lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount; diff --git a/lib/pages/packages_offers/ClinicOfferAndPackagesPage.dart b/lib/pages/packages_offers/ClinicOfferAndPackagesPage.dart index d522d81e..97daf27f 100644 --- a/lib/pages/packages_offers/ClinicOfferAndPackagesPage.dart +++ b/lib/pages/packages_offers/ClinicOfferAndPackagesPage.dart @@ -40,7 +40,7 @@ class _ClinicPackagesPageState extends State with AfterLayo if(viewModel.service.customer != null) { var request = AddProductToCartRequestModel(product_id: product.id, customer_id: viewModel.service.customer.id); await viewModel.service.addProductToCart(request, context: context).then((response){ - appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); + // appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); }).catchError((error) { utils.Utils.showErrorToast(error); }); @@ -50,7 +50,7 @@ class _ClinicPackagesPageState extends State with AfterLayo @override void afterFirstLayout(BuildContext context) async{ - appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); + // appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); } @override diff --git a/lib/pages/packages_offers/OfferAndPackagesPage.dart b/lib/pages/packages_offers/OfferAndPackagesPage.dart index dc5b6584..056e23e1 100644 --- a/lib/pages/packages_offers/OfferAndPackagesPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesPage.dart @@ -96,7 +96,7 @@ class _PackagesHomePageState extends State with AfterLayoutMix if(viewModel.service.customer != null) { var request = AddProductToCartRequestModel(product_id: product.id, customer_id: viewModel.service.customer.id); await viewModel.service.addProductToCart(request, context: context).then((response){ - appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); + // appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); }).catchError((error) { utils.Utils.showErrorToast(error.toString()); }); diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index 4fc5067e..6bfe4fbc 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -105,8 +105,8 @@ class _CartOrderPageState extends State { .shoppingCarts[index]) .then((value) { if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater( - '${value.quantityCount ?? 0}'); + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); } if (model.state == ViewState.ErrorLocal) { @@ -119,8 +119,8 @@ class _CartOrderPageState extends State { .shoppingCarts[index]) .then((value) { if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater( - '${value.quantityCount ?? 0}'); + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); } }); })) diff --git a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart index 44ebd882..389b4331 100644 --- a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -89,7 +89,7 @@ class PaymentBottomWidget extends StatelessWidget { message: "Order has been placed successfully!!"); openPayment( - model.orderListModel[0], model.user); + model.orderListModel[0], model.authenticatedUserObject.user); } else { AppToast.showErrorToast(message: model.error); } diff --git a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart index d6182b9a..ab55002f 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -37,14 +37,14 @@ class SelectAddressWidget extends StatefulWidget { class _SelectAddressWidgetState extends State { AddressInfo address; - _navigateToAddressPage() { + _navigateToAddressPage(String identificationNo) { Navigator.push(context, FadePage(page: PharmacyAddressesPage())) .then((result) { if (result != null) { address = result; widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson()); - widget.model.getInformationsByAddress(); + widget.model.getInformationsByAddress(identificationNo); widget.changeMainState(); } }); @@ -66,7 +66,7 @@ class _SelectAddressWidgetState extends State { color: Colors.white, child: address == null ? InkWell( - onTap: () => {_navigateToAddressPage()}, + onTap: () => {_navigateToAddressPage(model.user.patientIdentificationNo)}, child: Container( margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), child: Row( @@ -125,7 +125,7 @@ class _SelectAddressWidgetState extends State { ), ), InkWell( - onTap: () => {_navigateToAddressPage()}, + onTap: () => {_navigateToAddressPage(model.authenticatedUserObject.user.patientIdentificationNo)}, child: Texts( TranslationBase.of(context).changeAddress, fontSize: 12, diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 77cdaed6..4da64235 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -55,7 +55,7 @@ class _PharmacyPageState extends State { //crossAxisAlignment: CrossAxisAlignment.start, children: [ BannerPager(model), - GridViewButtons(model), + // GridViewButtons(model), PrescriptionsWidget(), ShopByBrandWidget(), RecentlyViewedWidget(), diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 2056c7ab..e34a5dbc 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,12 +1,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart'; @@ -16,7 +11,6 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'availability_info.dart'; @@ -108,8 +102,8 @@ class __ProductDetailPageState extends State { deleteFromWishlistFunction: () async { await deleteFromWishlistFunction(itemID: itemID, model: model); }, - isInWishList:isInWishList, - addToCartFunction:addToCartFunction , + isInWishList: isInWishList, + addToCartFunction: addToCartFunction, ), body: SingleChildScrollView( child: Column( @@ -127,8 +121,7 @@ class __ProductDetailPageState extends State { fit: BoxFit.contain, ), ), - if (widget.product.discountDescription != null) - DiscountDescription(product: widget.product) + if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) ], ), ), @@ -146,15 +139,11 @@ class __ProductDetailPageState extends State { setState(() {}); }, deleteFromWishlistFunction: (item) { - deleteFromWishlistFunction( - itemID: item, model: model); + deleteFromWishlistFunction(itemID: item, model: model); setState(() {}); }, notifyMeWhenAvailable: (context, itemId) { - notifyMeWhenAvailable( - itemId: itemId, - customerId: customerId, - model: model); + notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model); }, isInWishList: isInWishList, ), @@ -169,8 +158,7 @@ class __ProductDetailPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - padding: EdgeInsets.symmetric( - vertical: 15, horizontal: 10), + padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), child: Texts( TranslationBase.of(context).specification, fontSize: 15, @@ -207,16 +195,12 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).details, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), CustomDivider( - color: isDetails - ? Colors.green - : Colors.transparent, + color: isDetails ? Colors.green : Colors.transparent, ) ], ), @@ -227,14 +211,10 @@ class __ProductDetailPageState extends State { children: [ FlatButton( onPressed: () async { - if (widget.product.approvedTotalReviews > - 0) { - GifLoaderDialogUtils.showMyDialog( - context); - await model.getProductReviewsData( - widget.product.id); - GifLoaderDialogUtils.hideDialog( - context); + if (widget.product.approvedTotalReviews > 0) { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductReviewsData(widget.product.id); + GifLoaderDialogUtils.hideDialog(context); } else { model.clearReview(); } @@ -246,16 +226,12 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).reviews, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), CustomDivider( - color: isReviews - ? Colors.green - : Colors.transparent, + color: isReviews ? Colors.green : Colors.transparent, ), ], ), @@ -266,8 +242,7 @@ class __ProductDetailPageState extends State { children: [ FlatButton( onPressed: () async { - GifLoaderDialogUtils.showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getProductLocationData(); GifLoaderDialogUtils.hideDialog(context); @@ -279,16 +254,12 @@ class __ProductDetailPageState extends State { }, child: Text( TranslationBase.of(context).availability, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), ), color: Colors.white, ), CustomDivider( - color: isAvailability - ? Colors.green - : Colors.transparent, + color: isAvailability ? Colors.green : Colors.transparent, ), ], ), @@ -317,12 +288,16 @@ class __ProductDetailPageState extends State { SizedBox( height: 10, ), - RecommendedProducts(product: widget.product,productDetailViewModel: model, + RecommendedProducts( + product: widget.product, + productDetailViewModel: model, addToWishlistFunction: (itemID) async { - await addToWishlistFunction(itemID: itemID, model: model); - }, deleteFromWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, + deleteFromWishlistFunction: (itemID) async { await deleteFromWishlistFunction(itemID: itemID, model: model); - },) + }, + ) ], ), ), @@ -340,9 +315,9 @@ class __ProductDetailPageState extends State { ), )); } - addToShoppingCartFunction({quantity,itemID,ProductDetailViewModel model})async{ - await model.addToCartData(quantity,itemID); + addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { + await model.addToCartData(quantity, itemID); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { @@ -356,20 +331,18 @@ class __ProductDetailPageState extends State { await model.deleteWishlistData(itemID); setState(() {}); } - addToCartFunction( - {quantity, - itemID, - ProductDetailViewModel model, - }) async { + + addToCartFunction({ + quantity, + itemID, + ProductDetailViewModel model, + }) async { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID); GifLoaderDialogUtils.hideDialog(context); } } - - -notifyMeWhenAvailable( - {itemId, customerId, ProductDetailViewModel model}) async { +notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { await model.notifyMe(customerId, itemId); } diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart index 261f4e99..fabab916 100644 --- a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart +++ b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart @@ -36,7 +36,7 @@ class PrescriptionsWidget extends StatelessWidget { ViewAllHomeWidget(TranslationBase.of(context).myPrescription, HomePrescriptionsPage()), Container( margin: EdgeInsets.only(right: 10.0, left: 10.0), - height: MediaQuery.of(context).size.height * 0.28, + height: MediaQuery.of(context).size.height * 0.18, child: ListView.builder( scrollDirection: Axis.horizontal, shrinkWrap: true, diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 75e0a8f9..d071d4d2 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -12,13 +12,8 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreview import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.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/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy_categorise.dart'; import 'package:diplomaticquarterapp/pages/search_products_page.dart'; -import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -27,7 +22,6 @@ import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/others/bottom_bar.dart'; import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -45,8 +39,6 @@ import 'not_auh_page.dart'; VoidCallback _onCartClick; class AppScaffold extends StatefulWidget { - AppBarWidget appBar; - final String appBarTitle; final Widget body; final Widget bottomSheet; @@ -60,11 +52,9 @@ class AppScaffold extends StatefulWidget { final bool isBottomBar; final Widget floatingActionButton; final bool isPharmacy; - final bool isMainPharmacyPages; final bool isOfferPackages; final bool showPharmacyCart; final bool showOfferPackagesCart; - final bool extendBody; final String title; final String description; final bool isShowDecPage; @@ -83,13 +73,12 @@ class AppScaffold extends StatefulWidget { List dropDownList; final Function(int) dropDownIndexChange; Function onTap; + final bool isMainPharmacyPages; + final bool extendBody; final ValueChanged changeCurrentTab; - - AuthenticatedUserObject authenticatedUserObject = locator(); - - final Widget customAppBar; final int currentTab; final bool isShowPharmacyAppbar; + final Widget customAppBar; AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -103,17 +92,17 @@ class AppScaffold extends StatefulWidget { this.isShowAppBar = false, this.showNewAppBar = false, this.showNewAppBarTitle = false, + this.isMainPharmacyPages = false, + this.extendBody = false, this.hasAppBarParam, this.bottomSheet, this.bottomNavigationBar, this.baseViewModel, this.floatingActionButton, this.isPharmacy = false, - this.isMainPharmacyPages = false, this.showPharmacyCart = true, this.isOfferPackages = false, this.showOfferPackagesCart = false, - this.extendBody = false, this.title, this.description, this.isShowDecPage = true, @@ -145,9 +134,11 @@ class AppScaffold extends StatefulWidget { class _AppScaffoldState extends State { AuthenticatedUserObject authenticatedUserObject = locator(); + AppBarWidget appBar; @override void initState() { + // TODO: implement initState super.initState(); } @@ -218,66 +209,87 @@ class _AppScaffoldState extends State { @override Widget build(BuildContext context) { - PharmacyPagesViewModel pagesViewModel = Provider.of(context); AppGlobal.context = context; + PharmacyPagesViewModel pagesViewModel = Provider.of(context); - bool isUserNotLogin = (!Provider.of(context, listen: false).isLogin && isShowDecPage); + bool isUserNotLogin = (!Provider.of(context, listen: false).isLogin && widget.isShowDecPage); return Scaffold( - backgroundColor: backgroundColor ?? CustomColors.appBackgroudGrey2Color, + backgroundColor: widget.backgroundColor ?? CustomColors.appBackgroudGrey2Color, + + // appBar: widget.isShowPharmacyAppbar + // ? pharmacyAppbar() + // : widget.isShowAppBar + // ? widget.customAppBar != null + // ? widget.customAppBar + appBar: isUserNotLogin ? null - : (widget.isShowPharmacyAppbar + : widget.isShowPharmacyAppbar ? pharmacyAppbar() - : showNewAppBar + : (widget.showNewAppBar ? NewAppBarWidget( - title: appBarTitle, - showTitle: showNewAppBarTitle, - showDropDown: showDropDown, - dropdownIndexValue: dropdownIndexValue, - dropDownList: dropDownList ?? [], - dropDownIndexChange: dropDownIndexChange, - appBarIcons: appBarIcons, - onTap: onTap, + title: widget.appBarTitle, + showTitle: widget.showNewAppBarTitle, + showDropDown: widget.showDropDown, + dropdownIndexValue: widget.dropdownIndexValue, + dropDownList: widget.dropDownList ?? [], + dropDownIndexChange: widget.dropDownIndexChange, + appBarIcons: widget.appBarIcons, + onTap: widget.onTap, ) - : (isShowAppBar - ? customAppBar != null - ? customAppBar + : (widget.isShowAppBar + ? widget.customAppBar != null + ? widget.customAppBar : appBar = AppBarWidget( - appBarTitle: appBarTitle, - appBarIcons: appBarIcons, - showHomeAppBarIcon: showHomeAppBarIcon, - isPharmacy: isPharmacy, - showPharmacyCart: showPharmacyCart, - isOfferPackages: isOfferPackages, - showOfferPackagesCart: showOfferPackagesCart, - isShowDecPage: isShowDecPage, - backButtonTab: backButtonTab, + appBarTitle: widget.appBarTitle, + appBarIcons: widget.appBarIcons, + showHomeAppBarIcon: widget.showHomeAppBarIcon, + isPharmacy: widget.isPharmacy, + showPharmacyCart: widget.showPharmacyCart, + isOfferPackages: widget.isOfferPackages, + showOfferPackagesCart: widget.showOfferPackagesCart, + isShowDecPage: widget.isShowDecPage, + backButtonTab: widget.backButtonTab, ) : null)), - bottomSheet: bottomSheet, + bottomSheet: widget.bottomSheet, body: SafeArea( top: true, bottom: true, child: isUserNotLogin ? NotAutPage( - title: title ?? appBarTitle, - description: description, - infoList: infoList, - imagesInfo: imagesInfo, - icon: icon, + title: widget.title ?? widget.appBarTitle, + description: widget.description, + infoList: widget.infoList, + imagesInfo: widget.imagesInfo, + icon: widget.icon, ) - : baseViewModel != null + : widget.baseViewModel != null ? NetworkBaseView( child: buildBodyWidget(context), - baseViewModel: baseViewModel, + baseViewModel: widget.baseViewModel, ) : buildBodyWidget(context), ), - bottomNavigationBar: bottomNavigationBar, - floatingActionButton: floatingActionButton, + bottomNavigationBar: widget.isBottomBar + ? BottomNavPharmacyBar( + changeIndex: changeCurrentTab, + index: widget.currentTab, + ) + : null, + floatingActionButton: widget.floatingActionButton, ); } + void changeCurrentTab(int value) { + if (widget.isMainPharmacyPages) { + widget.changeCurrentTab(value); + } else { + Navigator.pushAndRemoveUntil( + locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: value)), (Route r) => false); + } + } + void _scanQrAndGetProduct() async { try { String result = await BarcodeScanner.scan(); @@ -304,7 +316,7 @@ class _AppScaffoldState extends State { } buildBodyWidget(context) { - return Stack(children: [body, isHelp == true ? RobotIcon() : Container()]); + return Stack(children: [widget.body, widget.isHelp == true ? RobotIcon() : Container()]); } } diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart index 01896117..105d7503 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_bar.dart @@ -7,14 +7,10 @@ import 'bottom_nav_pharmacy_item.dart'; class BottomNavPharmacyBar extends StatefulWidget { final ValueChanged changeIndex; - final int index; BottomNavPharmacyBar({Key key, this.changeIndex, this.index}) : super(key: key); int index = 0; - BottomNavPharmacyBar({Key key, this.changeIndex, this.index}) - : super(key: key); - @override _BottomNavPharmacyBarState createState() => _BottomNavPharmacyBarState(); }