From d630c6c45f4c3fa464b2a3c065fa957b856c623d Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Thu, 11 Nov 2021 11:00:35 +0300 Subject: [PATCH] Pharmacy fixes --- lib/config/localized_values.dart | 2 +- .../product_detail_view_model.dart | 4 +- .../product-details/product-detail.dart | 97 +-- lib/pages/sub_categorise_page.dart | 695 +++++------------- .../product_detail_service.dart | 4 +- 5 files changed, 207 insertions(+), 595 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 54a04592..aef5913f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -636,7 +636,7 @@ const Map localizedValues = { "compareListFull": {"en": "Your compare list is full", "ar": "قائمة المقارنة ممتلئه"}, "addQuantity": {"en": "You should add quantity", "ar": "اختر الكمية"}, "addToCartMsg": {"en": "You have added a product to the cart", "ar": "تمت اضافة المنتج بنجاح"}, - "addToWishlistMsg": {"en": "You have added a product to the Wishlist", "ar": "تمت الاضافة لقائمة الرغبات"}, + "addToWishlistMsg": {"en": "You have added a product to the Wishlist", "ar": "تمت الاضافة لقائمة المفضله"}, "notifyMeMsg": {"en": "You will be notified when product available", "ar": "سيتم اخبارك في حال توفر المنتج"}, "removeFromWishlistMsg": {"en": "You have removed a product from the Wishlist", "ar": "تمت ازالة المنتج بنجاح"}, "min": {"en": "Min", "ar": "اقل"}, diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 68483a93..df895e28 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -46,10 +46,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getProductLocationData() async { + Future getProductLocationData(String productSKU) async { hasError = false; setState(ViewState.BusyLocal); - await _productDetailService.getProductAvailabiltyDetail(); + await _productDetailService.getProductAvailabiltyDetail(productSKU); if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 51580c2c..ad802349 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.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'; @@ -15,8 +14,6 @@ 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'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -111,8 +108,7 @@ class __ProductDetailPageState extends State { await addToWishlistFunction(itemID: itemID, model: model); }, deleteFromWishlistFunction: () async { - await deleteFromWishlistFunction( - itemID: itemID, model: model); + await deleteFromWishlistFunction(itemID: itemID, model: model); }, isInWishList: isInWishList, addToCartFunction: addToCartFunction, @@ -133,8 +129,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) ], ), ), @@ -152,21 +147,15 @@ 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, isStockAvailable: model.isStockAvailable, - stockAvailability: projectViewModel.isArabic - ? model.stockAvailabilityn - : model.stockAvailability, + stockAvailability: projectViewModel.isArabic ? model.stockAvailabilityn : model.stockAvailability, ), ), SizedBox( @@ -179,8 +168,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, @@ -217,16 +205,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, ) ], ), @@ -237,14 +221,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(); } @@ -256,16 +236,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, ), ], ), @@ -276,9 +252,8 @@ class __ProductDetailPageState extends State { children: [ FlatButton( onPressed: () async { - GifLoaderDialogUtils.showMyDialog( - context); - await model.getProductLocationData(); + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductLocationData(widget.product.sku); GifLoaderDialogUtils.hideDialog(context); setState(() { @@ -289,16 +264,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, ), ], ), @@ -327,24 +298,22 @@ class __ProductDetailPageState extends State { SizedBox( height: 10, ), - RecommendedProducts( - product: widget.product, - productDetailViewModel: model, - addToWishlistFunction: (itemID) async { - await addToWishlistFunction( - itemID: itemID, model: model); - }, - deleteFromWishlistFunction: (itemID) async { - await deleteFromWishlistFunction( - itemID: itemID, model: model); - }, - ) + if (projectViewModel.isLogin) + RecommendedProducts( + product: widget.product, + productDetailViewModel: model, + addToWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, + deleteFromWishlistFunction: (itemID) async { + await deleteFromWishlistFunction(itemID: itemID, model: model); + }, + ) ], ), ), // : AppCircularProgressIndicator(), - bottomSheet: model.state == ViewState.Idle || - model.state == ViewState.ErrorLocal + bottomSheet: model.state == ViewState.Idle || model.state == ViewState.ErrorLocal ? FooterWidget( model.isStockAvailable, widget.product.orderMaximumQuantity, @@ -361,8 +330,7 @@ class __ProductDetailPageState extends State { )); } - addToShoppingCartFunction( - {quantity, itemID, ProductDetailViewModel model}) async { + addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); @@ -392,7 +360,6 @@ class __ProductDetailPageState extends State { } } -notifyMeWhenAvailable( - {itemId, customerId, ProductDetailViewModel model, context}) async { +notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model, context}) async { await model.notifyMe(customerId, itemId, context); } diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index c82c1063..e4200239 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.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/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -13,7 +12,6 @@ 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'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; @@ -30,14 +28,12 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); SubCategorisePage({this.id, this.parentId, this.title}); @override - _SubCategorisePageState createState() => - _SubCategorisePageState(id: id, title: title, parentId: parentId); + _SubCategorisePageState createState() => _SubCategorisePageState(id: id, title: title, parentId: parentId); } class _SubCategorisePageState extends State { @@ -67,10 +63,9 @@ class _SubCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context); return BaseView( + allowAny: true, onModelReady: (model) => model.getSubCategorise(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( appBarTitle: title, isBottomBar: false, isShowAppBar: true, @@ -102,8 +97,7 @@ class _SubCategorisePageState extends State { ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' : parentId == '9' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : parentId == - '10' + : parentId == '10' ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' : '', fit: BoxFit.fill, @@ -115,14 +109,12 @@ class _SubCategorisePageState extends State { children: [ InkWell( child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(10.0), child: Container( - child: Texts(TranslationBase.of(context) - .viewCategorise), + child: Texts(TranslationBase.of(context).viewCategorise), ), ), Icon(Icons.arrow_forward) @@ -134,37 +126,22 @@ class _SubCategorisePageState extends State { context: context, builder: (BuildContext context) { return Container( - height: - MediaQuery.of(context).size.height * - 0.89, + height: MediaQuery.of(context).size.height * 0.89, color: Colors.white, child: Center( child: ListView.builder( scrollDirection: Axis.vertical, - itemCount: - model.subCategorise.length, - itemBuilder: (BuildContext context, - int index) { + itemCount: model.subCategorise.length, + itemBuilder: (BuildContext context, int index) { return Container( child: Padding( padding: EdgeInsets.all(8.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - projectViewModel - .isArabic - ? model - .subCategorise[ - index] - .namen - : model - .subCategorise[ - index] - .name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, // model.subCategorise[index].name ), Divider( @@ -177,12 +154,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: - FinalProductsPage( - id: model - .subCategorise[ - index] - .id, + page: FinalProductsPage( + id: model.subCategorise[index].id, ), ), ); @@ -215,23 +188,19 @@ class _SubCategorisePageState extends State { itemCount: model.subCategorise.length, itemBuilder: (BuildContext context, int index) { return Padding( - padding: - EdgeInsets.symmetric(horizontal: 8.0), + padding: EdgeInsets.symmetric(horizontal: 8.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( - padding: EdgeInsets.symmetric( - horizontal: 13.0), + padding: EdgeInsets.symmetric(horizontal: 13.0), child: Container( height: 60.0, width: 65.0, decoration: BoxDecoration( shape: BoxShape.circle, - color: Colors.orange.shade200 - .withOpacity(0.45), + color: Colors.orange.shade200.withOpacity(0.45), ), child: Center( child: Icon( @@ -242,21 +211,11 @@ class _SubCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context) - .size - .width * - 0.17, - height: MediaQuery.of(context) - .size - .height * - 0.10, + width: MediaQuery.of(context).size.width * 0.17, + height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( - projectViewModel.isArabic - ? model.subCategorise[index] - .namen - : model.subCategorise[index] - .name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, // model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, @@ -315,21 +274,16 @@ class _SubCategorisePageState extends State { initialChildSize: 0.95, maxChildSize: 0.95, minChildSize: 0.9, - builder: (BuildContext context, - ScrollController scrollController) { + builder: (BuildContext context, ScrollController scrollController) { return SingleChildScrollView( controller: scrollController, child: Container( color: Colors.white, - height: MediaQuery.of(context) - .size - .height * - 1.95, + height: MediaQuery.of(context).size.height * 1.95, child: Column( children: [ Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( children: [ Icon( @@ -339,30 +293,23 @@ class _SubCategorisePageState extends State { width: 10.0, ), Texts( - TranslationBase.of( - context) - .refine, + TranslationBase.of(context).refine, // 'Refine', - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, ), SizedBox( width: 250.0, ), InkWell( child: Texts( - TranslationBase.of( - context) - .closeIt, + TranslationBase.of(context).closeIt, // 'Close', color: Colors.red, - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop( - context); + Navigator.pop(context); }, ), ], @@ -375,39 +322,26 @@ class _SubCategorisePageState extends State { Column( children: [ ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .categorise), + title: Texts(TranslationBase.of(context).categorise), children: [ ProcedureListWidget( model: model, - masterList: model - .subCategorise, - removeHistory: - (item) { + masterList: model.subCategorise, + removeHistory: (item) { setState(() { - entityList - .remove( - item); + entityList.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityList.add( - history); + entityList.add(history); }); }, - addSelectedHistories: - () { + addSelectedHistories: () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: - (master) => - isEntityListSelected( - master), + isEntityListSelected: (master) => isEntityListSelected(master), ) ], ), @@ -416,40 +350,26 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .brands), + title: Texts(TranslationBase.of(context).brands), children: [ ProcedureListWidget( model: model, - masterList: model - .brandsList, - removeHistory: - (item) { + masterList: model.brandsList, + removeHistory: (item) { setState(() { - entityListBrands - .remove( - item); + entityListBrands.remove(item); }); }, - addHistory: - (history) { + addHistory: (history) { setState(() { - entityListBrands - .add( - history); + entityListBrands.add(history); }); }, - addSelectedHistories: - () { + addSelectedHistories: () { //TODO build your fun herr // widget.addSelectedHistories(); }, - isEntityListSelected: - (master) => - isEntityListSelectedBrands( - master), + isEntityListSelected: (master) => isEntityListSelectedBrands(master), ) ], ), @@ -458,71 +378,43 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .price), + title: Texts(TranslationBase.of(context).price), children: [ Container( - color: Color( - 0xffEEEEEE), + color: Color(0xffEEEEEE), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts(TranslationBase.of( - context) - .min), + Texts(TranslationBase.of(context).min), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - minField, + controller: minField, ), ), ], ), Column( - mainAxisAlignment: - MainAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts(TranslationBase.of( - context) - .max), + Texts(TranslationBase.of(context).max), Container( - color: Colors - .white, - width: - 200, - height: - 40, - child: - TextFormField( - decoration: - InputDecoration( - border: - OutlineInputBorder(), + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), ), - controller: - maxField, + controller: maxField, ), ), ], @@ -537,31 +429,20 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, + height: MediaQuery.of(context).size.height * 0.4, ), Padding( - padding: - EdgeInsets.all(8.0), + padding: EdgeInsets.all(8.0), child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Container( width: 100, child: Button( - label: TranslationBase.of( - context) - .reset, + label: TranslationBase.of(context).reset, // 'Reset', - backgroundColor: - Colors - .red, + backgroundColor: Colors.red, ), ), ), @@ -571,66 +452,33 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( - onTap: - () async { - String - categoriesId = - ""; - for (CategoriseParentModel category - in entityList) { - if (categoriesId == - "") { - categoriesId = - category - .id; + onTap: () async { + String categoriesId = ""; + for (CategoriseParentModel category in entityList) { + if (categoriesId == "") { + categoriesId = category.id; } else { - categoriesId = - "$categoriesId,${category.id}"; + categoriesId = "$categoriesId,${category.id}"; } } - String - brandIds = - ""; - for (CategoriseParentModel brand - in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; + String brandIds = ""; + for (CategoriseParentModel brand in entityListBrands) { + if (brandIds == "") { + brandIds = brand.id; } else { - brandIds = - "$brandIds,${brand.id}"; + brandIds = "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils - .showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getFilteredSubProducts( - min: minField - .text - .toString(), - max: maxField - .text - .toString(), - categoryId: - categoriesId, - brandId: - brandIds); - GifLoaderDialogUtils - .hideDialog( - context); - Navigator.pop( - context); + min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); + GifLoaderDialogUtils.hideDialog(context); + Navigator.pop(context); }, - label: TranslationBase.of( - context) - .apply, + label: TranslationBase.of(context).apply, // 'Apply', - backgroundColor: - Colors - .green, + backgroundColor: Colors.green, ), ), ], @@ -697,30 +545,22 @@ class _SubCategorisePageState extends State { model.subProducts.isNotEmpty ? styleOne == true ? Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.15, + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, child: GridView.builder( physics: NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, crossAxisSpacing: 0.5, mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.subProducts[index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, + color: model.subProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, shape: Border( right: BorderSide( @@ -746,94 +586,43 @@ class _SubCategorisePageState extends State { ), child: Container( decoration: BoxDecoration( - borderRadius: - BorderRadius.only( - topLeft: - Radius.circular(110.0), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), ), color: Colors.white, ), - padding: EdgeInsets.symmetric( - horizontal: 0), - width: MediaQuery.of(context) - .size - .width / - 3, + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ Container( - margin: EdgeInsets - .fromLTRB( - 0, 16, 0, 0), - alignment: - Alignment.center, + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, child: Image.network( - model - .subProducts[ - index] - .images - .isNotEmpty - ? model - .subProducts[ - index] - .images[0] - .thumb + model.subProducts[index].images.isNotEmpty + ? model.subProducts[index].images[0].thumb : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', fit: BoxFit.cover, height: 80, ), ), Container( - width: model - .subProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: model - .subProducts[ - index] - .rxMessage != - null + child: model.subProducts[index].rxMessage != null ? Texts( - projectProvider - .isArabic - ? model - .subProducts[ - index] - .rxMessagen - : model - .subProducts[ - index] - .rxMessage, - color: Colors - .white, + projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) : Texts(""), // Texts( @@ -847,39 +636,22 @@ class _SubCategorisePageState extends State { ], ), Container( - margin: - EdgeInsets.symmetric( + margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - projectViewModel - .isArabic - ? model - .subProducts[ - index] - .namen - : model - .subProducts[ - index] - .name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, // model.subProducts[index].name, regular: true, fontSize: 12, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -893,37 +665,21 @@ class _SubCategorisePageState extends State { // ? (model.subProducts[index].approvedRatingSum.toDouble() / model.subProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar - .readOnly( - initialRating: model - .subProducts[ - index] - .approvedRatingSum - .toDouble(), + RatingBar.readOnly( + initialRating: model.subProducts[index].approvedRatingSum.toDouble(), size: 15.0, - filledColor: - Colors.yellow[ - 700], - emptyColor: - Colors.grey[ - 500], - isHalfAllowed: - true, - halfFilledIcon: - Icons - .star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) ], ), @@ -938,9 +694,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[ - index]), + page: ProductDetailPage(model.subProducts[index]), )), }, )); @@ -948,14 +702,11 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.122, + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -965,11 +716,9 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - decoration: - BoxDecoration(), + decoration: BoxDecoration(), child: Padding( - padding: - EdgeInsets.only( + padding: EdgeInsets.only( left: 9.0, top: 8.0, right: 10.0, @@ -977,81 +726,34 @@ class _SubCategorisePageState extends State { ), ), Container( - margin: EdgeInsets - .fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, - child: model - .subProducts[ - index] - .images - .isNotEmpty + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, + child: model.subProducts[index].images.isNotEmpty ? Image.network( - model - .subProducts[ - index] - .images[0] - .thumb, - fit: BoxFit - .contain, + model.subProducts[index].images[0].thumb, + fit: BoxFit.contain, height: 70, ) - : Text(TranslationBase - .of(context) - .noImage), + : Text(TranslationBase.of(context).noImage), ), ], ), Column( children: [ Container( - width: model - .subProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5.3 - : 0, - padding: - EdgeInsets.all(4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5.3 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: model - .subProducts[ - index] - .rxMessage != - null + child: model.subProducts[index].rxMessage != null ? Texts( - projectProvider - .isArabic - ? model - .subProducts[ - index] - .rxMessagen - : model - .subProducts[ - index] - .rxMessage, - color: Colors - .white, + projectProvider.isArabic ? model.subProducts[index].rxMessagen : model.subProducts[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, + fontWeight: FontWeight.w400, ) : Texts(""), // Texts( @@ -1073,38 +775,20 @@ class _SubCategorisePageState extends State { vertical: 0, ), child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment - .start, + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 4.0, ), Container( - width: MediaQuery.of( - context) - .size - .width * - 0.65, + width: MediaQuery.of(context).size.width * 0.65, child: Texts( - projectViewModel - .isArabic - ? model - .subProducts[ - index] - .namen - : model - .subProducts[ - index] - .name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, // model.subProducts[index].name, regular: true, fontSize: 13.2, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, maxLines: 5, ), ), @@ -1112,11 +796,7 @@ class _SubCategorisePageState extends State { height: 8.0, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.subProducts[index].price}", bold: true, @@ -1131,74 +811,42 @@ class _SubCategorisePageState extends State { // : 0, // forceStars: true), RatingBar.readOnly( - initialRating: model - .subProducts[ - index] - .approvedRatingSum - .toDouble(), + initialRating: model.subProducts[index].approvedRatingSum.toDouble(), size: 15.0, - filledColor: Colors - .yellow[700], - emptyColor: Colors - .grey[500], + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], isHalfAllowed: true, - halfFilledIcon: - Icons.star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, ), Texts( "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) ], ), ], ), ), - widget.authenticatedUserObject - .isLogin + widget.authenticatedUserObject.isLogin ? Container( child: IconButton( icon: Icon( - Icons - .shopping_cart, + Icons.shopping_cart, size: 18, - color: - CustomColors - .green, + color: CustomColors.green, ), - onPressed: - () async { - if (model - .subProducts[ - index] - .rxMessage == - null) { - GifLoaderDialogUtils - .showMyDialog( - context); - await addToCartFunction( - 1, - model - .subProducts[ - index] - .id); - GifLoaderDialogUtils - .hideDialog( - context); - Utils - .navigateToCartPage(); + onPressed: () async { + if (model.subProducts[index].rxMessage == null) { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.subProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + Utils.navigateToCartPage(); } else { - AppToast.showErrorToast( - message: TranslationBase.of( - context) - .needPrescription); + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } }), ) @@ -1210,8 +858,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[index]), + page: ProductDetailPage(model.subProducts[index]), )), }, ); @@ -1253,8 +900,7 @@ class _SubCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = - entityList.where((element) => masterKey.id == element.id); + Iterable history = entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -1262,8 +908,7 @@ class _SubCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = - entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 47fefded..e3e0fb7f 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -66,7 +66,7 @@ class ProductDetailService extends BaseService { }); } - Future getProductAvailabiltyDetail() async { + Future getProductAvailabiltyDetail(String productSKU) async { hasError = false; Map request; @@ -76,7 +76,7 @@ class ProductDetailService extends BaseService { // "IPAdress": "10.20.10.20", // "LanguageID": 2, // "PatientOutSA": 0, - // "SKU": "6720020025", + "SKU": productSKU, // "SessionID": null, // "VersionID": 5.6, // "generalid": "Cs2020@2016\$2958",