From 6d72be2a73eb911410d73b720881c055e808ec59 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 6 Sep 2021 12:22:51 +0300 Subject: [PATCH 1/9] fixed cart order issues --- .../pharmacyModule/OrderPreviewViewModel.dart | 21 +++-- .../pharmacies/ProductCheckTypeWidget.dart | 93 ++++++++++++++----- lib/pages/pharmacies/product_detail.dart | 10 +- .../pharmacies/screens/cart-order-page.dart | 19 ++-- lib/widgets/pharmacy/product_tile.dart | 53 ++++++----- 5 files changed, 126 insertions(+), 70 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 1fa34ee2..104dec05 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -55,30 +55,30 @@ class OrderPreviewViewModel extends BaseViewModel { } } - Future changeProductQuantity(ShoppingCart product) async { + Future changeProductQuantity(ShoppingCart product) async { setState(ViewState.Busy); - await _orderService.changeProductQuantity(product.id, product).then((res) { - _handleGetShoppingCartResponse(res); - }); + var resp = await _orderService.changeProductQuantity(product.id, product); + var object = _handleGetShoppingCartResponse(resp); if (_orderService.hasError) { error = _orderService.error; setState(ViewState.ErrorLocal); } else { setState(ViewState.Idle); } + return object; } - Future deleteProduct(ShoppingCart product) async { + Future deleteProduct(ShoppingCart product) async { setState(ViewState.Busy); - await _orderService.deleteProduct(product.id).then((res) { - _handleGetShoppingCartResponse(res); - }); + var resp = await _orderService.deleteProduct(product.id); + var object = _handleGetShoppingCartResponse(resp); if (_orderService.hasError) { error = _orderService.error; setState(ViewState.Error); } else { setState(ViewState.Idle); } + return object; } Future deleteShoppingCart() async { @@ -94,12 +94,12 @@ class OrderPreviewViewModel extends BaseViewModel { } } - _handleGetShoppingCartResponse(Map res) { + ShoppingCartResponse _handleGetShoppingCartResponse(Map res) { totalAdditionalShippingCharge = 0; if (res == null) { error = "response is null"; setState(ViewState.Error); - return; + return null; } print(res); cartResponse.itemCount = res["item_count"]; @@ -115,6 +115,7 @@ class OrderPreviewViewModel extends BaseViewModel { totalAdditionalShippingCharge += shoppingCart.product.additionalShippingCharge; }); cartResponse.updateShoppingCard(); + return cartResponse; } String getPaymentOptionImage(PaymentOption paymentOption) { diff --git a/lib/pages/pharmacies/ProductCheckTypeWidget.dart b/lib/pages/pharmacies/ProductCheckTypeWidget.dart index 878544e1..edecff62 100644 --- a/lib/pages/pharmacies/ProductCheckTypeWidget.dart +++ b/lib/pages/pharmacies/ProductCheckTypeWidget.dart @@ -1,47 +1,67 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/widgets/pharmacy/product_tile.dart'; import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/wishlist_view_model.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; AppSharedPreferences sharedPref = AppSharedPreferences(); var languageID; -class ProductCheckTypeWidget extends StatelessWidget { + +class ProductCheckTypeWidget extends StatefulWidget { final List wishlist; final bool isTrue; ProductCheckTypeWidget(this.isTrue, this.wishlist); + @override + _ProductCheckTypeWidgetState createState() => _ProductCheckTypeWidgetState(); +} +class _ProductCheckTypeWidgetState extends State { void initState() { getLanguageID(); } @override Widget build(BuildContext context) { - return isTrue + return widget.isTrue ? ListView.builder( - itemCount: wishlist.length, + itemCount: widget.wishlist.length, itemBuilder: (BuildContext context, int index) { return Column( children: [ Container( - child: isTrue + child: widget.isTrue ? productTile( - productName: languageID == 'ar' ? wishlist[index].product.namen : wishlist[index].product.name, - productPrice: wishlist[index].subtotal, - productRate: - double.parse(wishlist[index].subtotalVatRate), - productImage: wishlist[index].product.images[0].src, - showLine: isTrue, - productID: wishlist[index].product.id, + productName: languageID == 'ar' + ? widget.wishlist[index].product.namen + : widget.wishlist[index].product.name, + productPrice: widget.wishlist[index].subtotal, + productRate: double.parse( + widget.wishlist[index].subtotalVatRate), + productImage: + widget.wishlist[index].product.images[0].src, + showLine: widget.isTrue, + productID: widget.wishlist[index].product.id, + onDelete: deleteWishListItem, + ) : productTile( - productName: languageID == 'ar' ? wishlist[index].product.namen : wishlist[index].product.name, - productPrice: wishlist[index].subtotal, - productRate: - double.parse(wishlist[index].subtotalVatRate), - productImage: wishlist[index].product.images[0].src, - showLine: isTrue, + productName: languageID == 'ar' + ? widget.wishlist[index].product.namen + : widget.wishlist[index].product.name, + productPrice: widget.wishlist[index].subtotal, + productRate: double.parse( + widget.wishlist[index].subtotalVatRate), + productImage: + widget.wishlist[index].product.images[0].src, + showLine: widget.isTrue, + onDelete: deleteWishListItem, + ), ), Divider(height: 1, color: Colors.grey) @@ -51,20 +71,43 @@ class ProductCheckTypeWidget extends StatelessWidget { : GridView.count( crossAxisCount: 2, children: List.generate( - wishlist.length, + widget.wishlist.length, (index) => productTile( - productName: wishlist[index].product.name, - productPrice: wishlist[index].subtotal, - productRate: - double.parse(wishlist[index].subtotalVatRate), - productImage: wishlist[index].product.images[0].src, - showLine: isTrue, + productName: widget.wishlist[index].product.name, + productPrice: widget.wishlist[index].subtotal, + productRate: + double.parse(widget.wishlist[index].subtotalVatRate), + productImage: + widget.wishlist[index].product.images[0].src, + showLine: widget.isTrue, )), ); } + + deleteWishListItem(itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + GifLoaderDialogUtils.showMyDialog(context); + await x.deletWishlistData(itemID); + setState(() + async{ + await + //getWishlistData(); + Navigator.push(context, + FadePage(page: WishlistPage(false)), + ); + }); + GifLoaderDialogUtils.hideDialog(context); + print("Delete"); + } + + + getWishlistData() async { + WishListViewModel x = new WishListViewModel(); + await x.getWishlistData(); + } + } getLanguageID() async { languageID = await sharedPref.getString(APP_LANGUAGE); } - diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart index b1ec665a..c12ec87d 100644 --- a/lib/pages/pharmacies/product_detail.dart +++ b/lib/pages/pharmacies/product_detail.dart @@ -666,12 +666,14 @@ class __ProductDetailPageState extends State { itemBuilder: (context, index) { return InkWell( onTap: () - { - Navigator.push( + async { + GifLoaderDialogUtils.showMyDialog(context); + await Navigator.push( context, FadePage( - page: ProductDetailPage(widget.product.id), + page: ProductDetailPage(model.recommendedProductList[index]['id']), )); + GifLoaderDialogUtils.hideDialog(context); }, child: Card( elevation: 2, @@ -1982,7 +1984,9 @@ class _productNameAndPriceState extends State { onPressed: () async { if (customerId != null) { if (!isInWishlit) { + GifLoaderDialogUtils.showMyDialog(context); await addToWishlistFunction(widget.item.id); + GifLoaderDialogUtils.hideDialog(context); } else { await deleteFromWishlistFunction(widget.item.id); } diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 5271eda1..be87ae1d 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -26,7 +26,7 @@ class CartOrderPage extends StatelessWidget { return BaseView( onModelReady: (model){ model.getShoppingCart().then((value){ - appScaffold.appBar.badgeUpdater('${model.cartResponse.itemCount ?? 0}'); + appScaffold.appBar.badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); }); }, builder: (_, model, wi) => ChangeNotifierProvider.value( @@ -76,10 +76,10 @@ class CartOrderPage extends StatelessWidget { cart.shoppingCarts[index], () { print(cart.shoppingCarts[index] .quantity); - model - .changeProductQuantity( - cart.shoppingCarts[index]) - .then((value) { + model.changeProductQuantity(cart.shoppingCarts[index]).then((value) { + if (model.state != ViewState.Error) { + appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); + } if (model.state == ViewState.ErrorLocal) { Utils.showErrorToast( @@ -87,8 +87,13 @@ class CartOrderPage extends StatelessWidget { } }); }, - () => model.deleteProduct( - cart.shoppingCarts[index]))) + () { + model.deleteProduct(cart.shoppingCarts[index]).then((value){ + if (model.state != ViewState.Error) { + appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); + } + }); + })) ], ), ), diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 76e46949..b6f73823 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -24,23 +24,26 @@ class productTile extends StatelessWidget { final int status; final PharmacyProduct product; final dynamic productID; + final Function onDelete; +// final VoidCallback deleteWishlistItems; - productTile({ - this.productName, - this.productPrice, - this.productRate, - this.productReviews, - this.qyt, - this.totalPrice, - this.isOrderDetails = false, - this.productImage, - this.showLine = true, - this.img, - this.imgs, - this.status, - this.product, - this.productID, - }); + productTile( + {this.productName, + this.productPrice, + this.productRate, + this.productReviews, + this.qyt, + this.totalPrice, + this.isOrderDetails = false, + this.productImage, + this.showLine = true, + this.img, + this.imgs, + this.status, + this.product, + this.productID, + this.onDelete, + }); @override Widget build(BuildContext context) { @@ -136,9 +139,10 @@ class productTile extends StatelessWidget { children: [ IconButton( icon: Icon(FontAwesomeIcons.trashAlt, size: 15), - onPressed: (){ + onPressed: () { GifLoaderDialogUtils.showMyDialog(context); - deleteFromWishlistFunction(productID); +// deleteFromWishlistFunction(productID); + onDelete(productID); GifLoaderDialogUtils.hideDialog(context); }, ), @@ -148,14 +152,13 @@ class productTile extends StatelessWidget { IconButton( icon: Icon(FontAwesomeIcons.shoppingCart, size: 15), onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); + GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, productID); - GifLoaderDialogUtils.hideDialog(context); + GifLoaderDialogUtils.hideDialog(context); Navigator.push( context, FadePage(page: CartOrderPage()), ); - }, ), ], @@ -293,10 +296,10 @@ class productTile extends StatelessWidget { ); } - deleteFromWishlistFunction(itemID) async { - ProductDetailViewModel x = new ProductDetailViewModel(); - await x.deletWishlistData(itemID); - } +// deleteFromWishlistFunction(itemID) async { +// ProductDetailViewModel x = new ProductDetailViewModel(); +// await x.deletWishlistData(itemID); +// } addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); From bff7020b7846f755842d81755d93a3c75331bb71 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 13 Sep 2021 11:57:55 +0300 Subject: [PATCH 2/9] PAP-939: fixes --- .../New_E_Referral/new_e_referral_step_one_page.dart | 4 +++- .../E-Referral/search_for_referrals_page.dart | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_one_page.dart b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_one_page.dart index 5a3271f2..3a58ccb2 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_one_page.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_one_page.dart @@ -279,12 +279,13 @@ class MobileNumberTextFiled extends StatelessWidget { const MobileNumberTextFiled({ Key key, this.controller, - this.code + this.code, this.onChange }) : super(key: key); final TextEditingController controller; final String code; + final Function onChange; @override Widget build(BuildContext context) { @@ -313,6 +314,7 @@ class MobileNumberTextFiled extends StatelessWidget { margin: EdgeInsets.all(5), child: TextField( controller: controller, + onChanged: onChange, keyboardType: TextInputType.phone, decoration: InputDecoration( border: InputBorder.none, hintText: '5xxxxxxxx'), diff --git a/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart b/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart index 0b75705d..906108d4 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/search_for_referrals_page.dart @@ -47,6 +47,7 @@ class _SearchForReferralsPageState extends State { onModelReady: (model) => model.getAllCities(), builder: (_, model, widget) => AppScaffold( isShowAppBar: false, + baseViewModel: model, body: SingleChildScrollView( physics: ScrollPhysics(), child: Container( @@ -86,6 +87,11 @@ class _SearchForReferralsPageState extends State { ? "Enter Patient Identification No" : "Enter Referral Number", controller: _searchTextController, + onChanged: (_){ + setState(() { + + }); + }, ), SizedBox( height: 12, @@ -113,6 +119,12 @@ class _SearchForReferralsPageState extends State { ), MobileNumberTextFiled( controller: _mobileTextController, + onChange: (_){ + setState(() { + + }); + }, + code: _selectedCountry == null ? "11" : _selectedCountry["code"], From bb372210e02b2cf6b70d3dbab041bae69d019746 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 13 Sep 2021 12:05:01 +0300 Subject: [PATCH 3/9] PAP-938: fix Referral sent --- .../new_e_referral_step_three_page.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_three_page.dart b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_three_page.dart index a823c154..3f92823d 100644 --- a/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_three_page.dart +++ b/lib/pages/AlHabibMedicalService/E-Referral/New_E_Referral/new_e_referral_step_three_page.dart @@ -6,6 +6,8 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/bottom_options/BottomSheet.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -409,16 +411,17 @@ class _NewEReferralStepThreePageState extends State { 15; this.widget.createEReferralRequestModel.preferredBranchName = "Arryan Hospital"; - - // this.widget.createEReferralRequestModel.fullName= ""; this.widget.createEReferralRequestModel.otherRelationship = ""; - // this.widget.createEReferralRequestModel.; - // this.widget.createEReferralRequestModel. preferredBranchName= "Arryan Hospital"; - // this.widget.createEReferralRequestModel. preferredBranchName= "Arryan Hospital"; await model .createEReferral(this.widget.createEReferralRequestModel); + if(model.state == ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } else{ + AppToast.showSuccessToast(message: "Referral sent successfully"); + + } }, loading: model.state == ViewState.BusyLocal, disabled: medicalReportImages.length == 0, From 8c0dca781cfea56f9b54a43f2c6d3c3c643e8a08 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Thu, 16 Sep 2021 10:19:26 +0300 Subject: [PATCH 4/9] fixed compare issues and arabic version --- lib/config/localized_values.dart | 27 +- .../pharmacies/recommendedProduct_model.dart | 88 ++--- .../pharmacy_module_view_model.dart | 6 +- lib/pages/final_products_page.dart | 38 +-- lib/pages/landing/landing_page_pharmcy.dart | 6 +- lib/pages/parent_categorise_page.dart | 34 +- lib/pages/pharmacies/compare.dart | 316 ++++++++++++++++-- lib/pages/pharmacies/my_reviews.dart | 3 +- lib/pages/pharmacies/product-brands.dart | 2 +- lib/pages/pharmacies/product_detail.dart | 143 ++++---- .../pharmacies/screens/cart-order-page.dart | 13 +- .../screens/pharmacy_module_page.dart | 19 +- .../pharmacies/widgets/ProductTileItem.dart | 10 +- lib/pages/pharmacies/wishlist.dart | 3 +- lib/pages/pharmacy/profile/profile.dart | 3 +- lib/pages/search_products_page.dart | 13 +- lib/pages/sub_categorise_page.dart | 27 +- .../recommendedProduct_service.dart | 11 +- lib/uitl/translations_delegate_base.dart | 16 + 19 files changed, 532 insertions(+), 246 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index e16b0249..73490794 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -73,6 +73,8 @@ const Map localizedValues = { }, 'enterDocName': {'en': 'Enter Doctor name', 'ar': 'أدخل إسم الطبيب'}, 'search': {'en': 'Search', 'ar': 'بحث'}, + 'noResultFound': {'en': 'No Result Found', 'ar': 'المنتج غير موجود'}, + 'pleaseEnterProductName': {'en': 'Please Enter Product Name', 'ar': 'ادخل اسم المنتج'}, 'bookNow': {'en': 'BOOK NOW', 'ar': 'احجز الآن'}, 'docInfo': {'en': 'Doctor Information', 'ar': 'معلومات الطبيب'}, 'appoInfo': {'en': 'Appointment Information', 'ar': 'معلومات الموعد'}, @@ -712,11 +714,16 @@ const Map localizedValues = { "ar": "خدمة الاشعة: هذه الخدمة تمكنك من الاطلاع على تقارير وصور الاشعة التي تمت في مجموعة الحبيب الطبية وكذلك ارسال التقرير عن طريق الايميل." }, + + "noReviewsAvailable": {"en": "No Reviews Available", "ar": "لا يوجد تقييمات"}, + "noLocationAvailable": {"en": "No Location Available", "ar": "لا يوجد موقع"}, "orders": {"en": "Orders", "ar": "الطلبات"}, "lakum": {"en": "Lakum", "ar": "لكم"}, - "wishlist": {"en": "Wishlist", "ar": "الرغبات"}, + "wishlist": {"en": "Wishlist", "ar": "المفضلة"}, + "products": {"en": "Products", "ar": "المنتجات"}, "reviews": {"en": "Reviews", "ar": "التقيمات"}, - // "myPrescriptions": {"en": "My Prescriptions", "ar": "وصفاتي"}, + "brands": {"en": "Brands", "ar": "العلامات التجارية"}, + "productDetails": {"en": "Product Details", "ar": "تفاصيل المنتج"}, // "medicationRefill": {"en": "Medication Refill", "ar": "تعبئة الأدوية"}, "pillReminder": {"en": "Pill Reminder", "ar": "تذكير الأدويه"}, "shippingAddresses": {"en": "Shipping Addresses", "ar": "عناوين الشحن"}, @@ -848,7 +855,7 @@ const Map localizedValues = { }, "shopByBrands": {"en": "Shop By Brands", "ar": "تسوق حسب الماركات"}, "recentlyViewed": {"en": "Recently Viewed", "ar": "شوهدت مؤخرا"}, - "bestSellers": {"en": "Best Sellers", "ar": "أفضل البائعين"}, + "bestSellers": {"en": "Best Seller", "ar": "الأكثر مبيعأ"}, "deleteAllItems": {"en": "Delete All Items", "ar": "حذف كافة العناصر"}, "total": {"en": "Total", "ar": "المجموع"}, "totalWithColonRight": {"en": "Total:", "ar": ":المجموع"}, @@ -881,15 +888,18 @@ const Map localizedValues = { "en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك" }, - + "refine": {"en": "Refine", "ar": "refine"}, + "reset": {"en": "Reset", "ar": "اعادة تعيين"}, + "apply": {"en": "Apply", "ar": "تطبيق"}, + "viewCategorise": {"en": "View All Categories", "ar": "عرض جميع الفئات"}, "categorise": {"en": "Categories", "ar": "التطبيقات"}, - "wishList": {"en": "WishList", "ar": "الرغبات"}, + "wishList": {"en": "WishList", "ar": "المفضلة"}, "myAccount": {"en": "My Account", "ar": "حسابي"}, "cart": {"en": "Cart", "ar": "التسوق"}, "Alhabibapp": {"en": "Al habib app", "ar": "تطبيق الحبيب"}, "searchProductHere": { "en": "Search Product here", - "ar": "ابحث في الطلب الخاص بك" + "ar": "البحث عن منتج" }, "HHCNotAuthMsg": { "en": @@ -1539,7 +1549,10 @@ const Map localizedValues = { "vaccination": {"en": "Vaccination", "ar": "جدول التطعيمات"}, "welcomeBack": {"en": "Welcome back", "ar": "مرحبا مرة أخرى"}, "quantitySize": {"en": "Quantity", "ar": "كميه"}, - "addToCart": {"en": "add to cart", "ar": "إضفة للسلة"}, + "addToCart": {"en": "Add to Cart", "ar": "إضف للسلة"}, + "addToWishlist": {"en": "Add to Wishlist", "ar": "اضف للمفضلة"}, + "noData": {"en": "There is no data", "ar": "لايوجد بيانات"}, + "no_data": {"en": "No data", "ar": "لايوجد بيانات"}, "buyNow": {"en": "buy now", "ar": "إشتري الان"}, "quantityShortcut": {"en": "QTY", "ar": "كمية"}, diff --git a/lib/core/model/pharmacies/recommendedProduct_model.dart b/lib/core/model/pharmacies/recommendedProduct_model.dart index 7608aca4..0d40fce7 100644 --- a/lib/core/model/pharmacies/recommendedProduct_model.dart +++ b/lib/core/model/pharmacies/recommendedProduct_model.dart @@ -14,15 +14,15 @@ class RecommendedProductModel { // dynamic metaDescription; // dynamic metaTitle; bool allowCustomerReviews; - int approvedRatingSum; - int notApprovedRatingSum; - int approvedTotalReviews; - int notApprovedTotalReviews; + dynamic approvedRatingSum; + dynamic notApprovedRatingSum; + dynamic approvedTotalReviews; + dynamic notApprovedTotalReviews; dynamic sku; bool isRx; bool prescriptionRequired; -// dynamic rxMessage; -// dynamic rxMessagen; + dynamic rxMessage; + dynamic rxMessagen; // dynamic manufacturerPartNumber; // dynamic gtin; bool isGiftCard; @@ -30,33 +30,33 @@ class RecommendedProductModel { bool automaticallyAddRequiredProducts; bool isDownload; bool unlimitedDownloads; - int maxNumberOfDownloads; + dynamic maxNumberOfDownloads; // dynamic downloadExpirationDays; bool hasSampleDownload; bool hasUserAgreement; bool isRecurring; - int recurringCycleLength; - int recurringTotalCycles; + dynamic recurringCycleLength; + dynamic recurringTotalCycles; bool isRental; - int rentalPriceLength; + dynamic rentalPriceLength; bool isShipEnabled; bool isFreeShipping; bool shipSeparately; - int additionalShippingCharge; + dynamic additionalShippingCharge; bool isTaxExempt; bool isTelecommunicationsOrBroadcastingOrElectronicServices; bool useMultipleWarehouses; - int manageInventoryMethodId; - int stockQuantity; + dynamic manageInventoryMethodId; + dynamic stockQuantity; dynamic stockAvailability; dynamic stockAvailabilityn; bool displayStockAvailability; bool displayStockQuantity; - int minStockQuantity; - int notifyAdminForQuantityBelow; + dynamic minStockQuantity; + dynamic notifyAdminForQuantityBelow; bool allowBackInStockSubscriptions; - int orderMinimumQuantity; - int orderMaximumQuantity; + dynamic orderMinimumQuantity; + dynamic orderMaximumQuantity; // Null allowedQuantities; bool allowAddingOnlyExistingAttributeCombinations; bool disableBuyButton; @@ -64,18 +64,18 @@ class RecommendedProductModel { bool availableForPreOrder; // dynamic preOrderAvailabilityStartDateTimeUtc; bool callForPrice; - double price; - int oldPrice; - double productCost; + dynamic price; + dynamic oldPrice; + dynamic productCost; // dynamic specialPrice; // dynamic specialPriceStartDateTimeUtc; // dynamic specialPriceEndDateTimeUtc; bool customerEntersPrice; - int minimumCustomerEnteredPrice; - int maximumCustomerEnteredPrice; + dynamic minimumCustomerEnteredPrice; + dynamic maximumCustomerEnteredPrice; bool basepriceEnabled; - int basepriceAmount; - int basepriceBaseAmount; + dynamic basepriceAmount; + dynamic basepriceBaseAmount; bool hasTierPrices; bool hasDiscountsApplied; // dynamic discountName; @@ -85,30 +85,30 @@ class RecommendedProductModel { // dynamic discountPercentage; dynamic currency; dynamic currencyn; - double weight; - int length; - int width; - int height; + dynamic weight; + dynamic length; + dynamic width; + dynamic height; // dynamic availableStartDateTimeUtc; // dynamic availableEndDateTimeUtc; - int displayOrder; + dynamic displayOrder; bool published; bool deleted; dynamic createdOnUtc; dynamic updatedOnUtc; dynamic productType; - int parentGroupedProductId; + dynamic parentGroupedProductId; // List roleIds; // List discountIds; // List storeIds; - List manufacturerIds; + List manufacturerIds; // List reviews; List images; // List attributes; List specifications; // List associatedProductIds; // List tags; - int vendorId; + dynamic vendorId; dynamic seName; bool isinwishlist; @@ -135,8 +135,8 @@ class RecommendedProductModel { this.sku, this.isRx, this.prescriptionRequired, -// this.rxMessage, -// this.rxMessagen, + this.rxMessage, + this.rxMessagen, // this.manufacturerPartNumber, // this.gtin, this.isGiftCard, @@ -254,8 +254,8 @@ class RecommendedProductModel { sku = json['sku']; isRx = json['is_rx']; prescriptionRequired = json['prescription_required']; -// rxMessage = json['rx_message']; -// rxMessagen = json['rx_messagen']; + rxMessage = json['rx_message']; + rxMessagen = json['rx_messagen']; // manufacturerPartNumber = json['manufacturer_part_number']; // gtin = json['gtin']; isGiftCard = json['is_gift_card']; @@ -353,7 +353,7 @@ class RecommendedProductModel { // storeIds.add(new Null.fromJson(v)); // }); // } - manufacturerIds = json['manufacturer_ids'].cast(); + manufacturerIds = json['manufacturer_ids'].cast(); // if (json['reviews'] != null) { // reviews = new List(); // json['reviews'].forEach((v) { @@ -422,8 +422,8 @@ class RecommendedProductModel { data['sku'] = this.sku; data['is_rx'] = this.isRx; data['prescription_required'] = this.prescriptionRequired; -// data['rx_message'] = this.rxMessage; -// data['rx_messagen'] = this.rxMessagen; + data['rx_message'] = this.rxMessage; + data['rx_messagen'] = this.rxMessagen; // data['manufacturer_part_number'] = this.manufacturerPartNumber; // data['gtin'] = this.gtin; data['is_gift_card'] = this.isGiftCard; @@ -543,7 +543,7 @@ class RecommendedProductModel { } class LocalizedNames { - int languageId; + dynamic languageId; String localizedName; LocalizedNames({this.languageId, this.localizedName}); @@ -562,8 +562,8 @@ class LocalizedNames { } class Images { - int id; - int position; + dynamic id; + dynamic position; String src; String thumb; String attachment; @@ -590,8 +590,8 @@ class Images { } class Specifications { - int id; - int displayOrder; + dynamic id; + dynamic displayOrder; String defaultValue; String defaultValuen; String name; diff --git a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart index e63bb166..90439128 100644 --- a/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart @@ -33,10 +33,12 @@ class PharmacyModuleViewModel extends BaseViewModel { List get lastVisitedProducts => _pharmacyService.lastVisitedProducts; - - List> get recommendedProductList => + List get recommendedProductList => _recommendedProductService.recommendedList; +// List> get recommendedProductList => +// _recommendedProductService.recommendedList; + List get prescriptionsList => _prescriptionService.prescriptionsList; diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 1d5e511b..843d1d56 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -12,6 +13,8 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter/src/widgets/image.dart' as flutterImage; import 'base/base_view.dart'; + +dynamic languageID; class FinalProductsPage extends StatefulWidget { final String id; final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed @@ -33,6 +36,15 @@ class _FinalProductsPageState extends State { color: Colors.blue, size: 29.0, ); + + getLanguageID() async { + languageID = await sharedPref.getString(APP_LANGUAGE); + } + + void initState() { + getLanguageID(); + super.initState(); + } @override Widget build(BuildContext context) { return BaseView( @@ -55,7 +67,7 @@ class _FinalProductsPageState extends State { builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( - appBarTitle: "Products", + appBarTitle: TranslationBase.of(context).products, isBottomBar: false, isShowAppBar: true, backgroundColor: Colors.white, @@ -74,7 +86,7 @@ class _FinalProductsPageState extends State { Padding( padding: EdgeInsets.all(8.0), child: Texts( - 'Products', + TranslationBase.of(context).products, fontWeight: FontWeight.w600, ), ), @@ -213,11 +225,7 @@ class _FinalProductsPageState extends State { ), ), Container( - width: model - .finalProducts[ - index] - .rxMessage != - null + width: model.finalProducts[index].rxMessage != null ? MediaQuery.of( context) .size @@ -235,23 +243,15 @@ class _FinalProductsPageState extends State { .circular( 6)), ), - child: Texts( - model - .finalProducts[ - index] - .rxMessage != - null - ? model - .finalProducts[ - index] - .rxMessage - : "", + child:model.finalProducts[index].rxMessage != null + ? Texts( languageID == 'ar' ? model.finalProducts[index].rxMessagen + : model.finalProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w600, - ), + ): Texts(""), ), ], ), diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 04c9bb54..5da853fb 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -43,7 +43,7 @@ class _LandingPagePharmacyState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: currentTab != 4 + appBar: currentTab != 4 && currentTab != 3 ? AppBar( backgroundColor: Color(0xff5AB145), elevation: 0, @@ -55,7 +55,7 @@ class _LandingPagePharmacyState extends State { ), child: InkWell( child: Padding( - padding: EdgeInsets.all(8.0), + padding: EdgeInsets.all(5.0), child: Row( //crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, @@ -172,7 +172,7 @@ class _LandingPagePharmacyState extends State { .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode", onSuccess: (dynamic response, int statusCode) { print(response); - var product = PharmacyProduct.fromJson(response["products"][0]); + product = PharmacyProduct.fromJson(response["products"][0]); GifLoaderDialogUtils.hideDialog(context); Navigator.push(context, FadePage(page: ProductDetailPage(product))); }, onFailure: (String error, int statusCode) { diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index a7e43241..19c90e90 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_mo import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -108,8 +109,8 @@ class _ParentCategorisePageState extends State { padding: EdgeInsets.all(10.0), child: InkWell( child: Container( - child: Texts( - 'View All Categories', + child: Texts(TranslationBase.of(context).viewCategorise, +// 'View All Categories', fontWeight: FontWeight.w300, ), ), @@ -143,10 +144,8 @@ class _ParentCategorisePageState extends State { CrossAxisAlignment .start, children: [ - Texts(model - .categoriseParent[ - index] - .name), + Texts( projectViewModel.isArabic ? model.categoriseParent[index].namen + :model.categoriseParent[index].name), Divider( thickness: 0.6, color: Colors @@ -724,10 +723,7 @@ class _ParentCategorisePageState extends State { children: [ Stack( children: [ - if (model - .parentProducts[ - index] - .discountName != + if (model.parentProducts[index].discountName != null) RotatedBox( quarterTurns: 4, @@ -847,10 +843,7 @@ class _ParentCategorisePageState extends State { ), child: Center( child: Texts( - model - .parentProducts[ - index] - .discountName, + model.parentProducts[index].discountName, regular: true, color: Colors.white, @@ -858,11 +851,9 @@ class _ParentCategorisePageState extends State { ), ), ), - Texts( - model - .parentProducts[ - index] - .name, + Texts( projectViewModel.isArabic ? + model.parentProducts[index].namen + : model.parentProducts[index].name, regular: true, fontSize: 12, fontWeight: @@ -1047,9 +1038,8 @@ class _ParentCategorisePageState extends State { .width * 0.65, child: Texts( - model - .parentProducts[index] - .name, + projectViewModel.isArabic ? model.parentProducts[index].namen + : model.parentProducts[index].name , regular: true, fontSize: 13.2, fontWeight: diff --git a/lib/pages/pharmacies/compare.dart b/lib/pages/pharmacies/compare.dart index 505533cb..82a11610 100644 --- a/lib/pages/pharmacies/compare.dart +++ b/lib/pages/pharmacies/compare.dart @@ -1,3 +1,5 @@ +import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:carousel_slider/carousel_slider.dart'; @@ -5,9 +7,11 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:provider/provider.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -int counter = 0; +int counter = 0; +dynamic languageID; class ComparePage extends StatefulWidget { @override _ComparePageState createState() => _ComparePageState(); @@ -15,14 +19,24 @@ class ComparePage extends StatefulWidget { //CompareList compareItems = CompareList(); class _ComparePageState extends State { + getLanguageID() async { + languageID = await sharedPref.getString(APP_LANGUAGE); + } + void initState() { + getLanguageID(); + super.initState(); + } + @override Widget build(BuildContext context) { return AppScaffold( - appBarTitle: 'Reviews page', + appBarTitle: TranslationBase.of(context).compare, isShowAppBar: true, isPharmacy: true, - body: Container( - child: compareList(), + body: SingleChildScrollView( + child: Container( + child: compareList(), + ), ), ); } @@ -50,8 +64,8 @@ class compareList extends StatelessWidget { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text( - 'There is no data', + child: Text(TranslationBase.of(context).noData, +// 'There is no data', style: TextStyle(fontSize: 30), ), ) @@ -105,7 +119,7 @@ class _slideDetailState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Container( - height: 550, + height: 750, width: 150, margin: EdgeInsets.symmetric(horizontal: 10.0), decoration: BoxDecoration( @@ -157,7 +171,14 @@ class _slideDetailState extends State { child: Align( alignment: Alignment.topLeft, child: RichText( - text: TextSpan( + text: languageID == "ar"? TextSpan( + text: widget.data[index].namen, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ) + : TextSpan( text: widget.data[index].name, style: TextStyle( fontWeight: FontWeight.bold, @@ -173,7 +194,7 @@ class _slideDetailState extends State { alignment: Alignment.topLeft, child: RichText( text: TextSpan( - text: widget.data[index].price.toString(), + text: "SAR ${widget.data[index].price.toString()}", style: TextStyle( color: Colors.black54, fontSize: 15, @@ -195,10 +216,21 @@ class _slideDetailState extends State { child: Align( alignment: Alignment.topLeft, child: RichText( - text: TextSpan( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[0].nameN : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ) + :TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[0].name : - "No data", +// "No data", + TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, @@ -212,10 +244,82 @@ class _slideDetailState extends State { child: Align( alignment: Alignment.topLeft, child: RichText( - text: TextSpan( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[0].defaultValuen : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ):TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[0].defaultValue : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ), + ), + ), + ), + Padding( + padding: EdgeInsets.only(top: 8.0), + child: Container( + height: 1.0, + width: 300.0, + color: Colors.grey, + ), + ), + Container( + margin: EdgeInsets.all(5), + child: Align( + alignment: Alignment.topLeft, + child: RichText( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[1].nameN : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[1].name : - "No data", +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ), + ), + ), + ), + Container( + margin: EdgeInsets.all(5), + child: Align( + alignment: Alignment.topLeft, + child: RichText( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[1].defaultValuen : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ):TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[1].defaultValue : +// "No data", + TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, @@ -237,10 +341,20 @@ class _slideDetailState extends State { child: Align( alignment: Alignment.topLeft, child: RichText( - text: TextSpan( - text:widget.data[index].specifications != null ? + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[2].nameN : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ):TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[2].name : - "No data", +// "No data", + TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, @@ -254,10 +368,82 @@ class _slideDetailState extends State { child: Align( alignment: Alignment.topLeft, child: RichText( - text: TextSpan( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[2].defaultValuen : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ):TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[2].defaultValue : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ), + ), + ), + ), + Padding( + padding: EdgeInsets.only(top: 8.0), + child: Container( + height: 1.0, + width: 300.0, + color: Colors.grey, + ), + ), + Container( + margin: EdgeInsets.all(5), + child: Align( + alignment: Alignment.topLeft, + child: RichText( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[3].nameN : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[3].name : - "No data", +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ), + ), + ), + ), + Container( + margin: EdgeInsets.all(5), + child: Align( + alignment: Alignment.topLeft, + child: RichText( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[3].defaultValuen : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ):TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[3].defaultValue : +// "No data", + TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, @@ -279,10 +465,20 @@ class _slideDetailState extends State { child: Align( alignment: Alignment.topLeft, child: RichText( - text: TextSpan( - text:widget.data[index].specifications != null ? + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[4].nameN : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ):TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[4].name : - "No data", +// "No data", + TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, @@ -296,10 +492,82 @@ class _slideDetailState extends State { child: Align( alignment: Alignment.topLeft, child: RichText( - text: TextSpan( - text:widget.data[index].specifications != null ? + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[4].defaultValuen : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ):TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[4].defaultValue : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ), + ), + ), + ), + Padding( + padding: EdgeInsets.only(top: 8.0), + child: Container( + height: 1.0, + width: 300.0, + color: Colors.grey, + ), + ), + Container( + margin: EdgeInsets.all(5), + child: Align( + alignment: Alignment.topLeft, + child: RichText( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[5].nameN : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ):TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[5].name : - "No data", +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.black, + fontSize: 13), + ), + ), + ), + ), + Container( + margin: EdgeInsets.all(5), + child: Align( + alignment: Alignment.topLeft, + child: RichText( + text: languageID == "ar"? TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[5].defaultValuen : +// "No data", + TranslationBase.of(context).no_data, + style: TextStyle( + color: Colors.black54, + fontSize: 15, + fontWeight: FontWeight.bold), + ):TextSpan( + text: widget.data[index].specifications != null ? + widget.data[index].specifications[5].defaultValue : +// "No data", + TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, diff --git a/lib/pages/pharmacies/my_reviews.dart b/lib/pages/pharmacies/my_reviews.dart index 7b17a359..7e7e33a0 100644 --- a/lib/pages/pharmacies/my_reviews.dart +++ b/lib/pages/pharmacies/my_reviews.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/review_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:rating_bar/rating_bar.dart'; @@ -22,7 +23,7 @@ class _MyReviewsPageState extends State { return BaseView( onModelReady: (model) => model.getReviewData(), builder: (_, model, wi) => AppScaffold( - appBarTitle: 'My Reviews', + appBarTitle: TranslationBase.of(context).reviews, isShowAppBar: true, isPharmacy: true, baseViewModel: model, diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index e2fefab0..42a78d5c 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -31,7 +31,7 @@ class _ProductBrandsPageState extends State { allowAny: true, onModelReady: (model) => model.getBrandsData(), builder: (_, model, wi) => AppScaffold( - appBarTitle: 'Brands page', + appBarTitle: TranslationBase.of(context).brands, isShowAppBar: true, isPharmacy: true, isShowDecPage: false, diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart index c12ec87d..28afa2f4 100644 --- a/lib/pages/pharmacies/product_detail.dart +++ b/lib/pages/pharmacies/product_detail.dart @@ -17,9 +17,10 @@ import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; int price = 0; -var languageID; +dynamic languageID; bool isOverQuantity = false; bool isInWishlit = false; //int isSelected = 1; @@ -35,7 +36,7 @@ class ProductDetailPage extends StatefulWidget { // final Products recommendedProducts; - ProductDetailPage(this.product, ); + ProductDetailPage(this.product ); @override @@ -43,15 +44,20 @@ class ProductDetailPage extends StatefulWidget { } class __ProductDetailPageState extends State { + AppSharedPreferences sharedPref = AppSharedPreferences(); + bool isTrue = true; bool isDetails = true; bool isReviews = false; bool isAvailabilty = false; dynamic wishlistItems; - var model; + //var model; // String ProductId="4561"; - String productId = ""; + // String productId = ""; + getLanguageID() async { + languageID = await sharedPref.getString(APP_LANGUAGE); + } checkWishlist() async { GifLoaderDialogUtils.showMyDialog(context); @@ -72,11 +78,12 @@ class __ProductDetailPageState extends State { setState(() {}); } + void initState() { + getLanguageID(); price = 1; specificationData = widget.product; userInfo(); -// recommendedData= widget.recommendedProducts; super.initState(); } @@ -97,7 +104,7 @@ class __ProductDetailPageState extends State { Widget build(BuildContext context) { return customerId != null ? DetailPageScafold( - appBarTitle: 'product detail page', + appBarTitle: TranslationBase.of(context).productDetails, isShowAppBar: true, isPharmacy: true, isShowDecPage: false, @@ -125,7 +132,7 @@ class __ProductDetailPageState extends State { flex: 1, child: Container( alignment: Alignment.centerRight, - child: languageID == 'ar' + child: languageID == "ar" ? Text( widget.product .discountDescriptionn, @@ -166,7 +173,7 @@ class __ProductDetailPageState extends State { ), Container( width: 500, - height: 150, + height: 220, color: Colors.white, child: productNameAndPrice(context, widget.product), ), @@ -175,7 +182,7 @@ class __ProductDetailPageState extends State { ), Container( width: 500, - height: 120, + height: 100, color: Colors.white, child: Column( mainAxisAlignment: MainAxisAlignment.start, @@ -195,7 +202,8 @@ class __ProductDetailPageState extends State { padding: const EdgeInsets.all(8.0), child: Container( child: Text( - "there is no data", + TranslationBase.of(context).noData, +// "there is no data", ), ), ), @@ -335,10 +343,9 @@ class __ProductDetailPageState extends State { ), Container( child: Text( - languageID == 'ar' + languageID == "ar" ? widget.product.fullDescriptionn - : widget.product - .fullDescription ?? + : widget.product.fullDescription ?? "", style: TextStyle( fontSize: 16, @@ -507,7 +514,8 @@ class __ProductDetailPageState extends State { : Container( padding: EdgeInsets.all(15), alignment: Alignment.center, - child: Text('No Reviews Available'), + child: Text(TranslationBase.of(context).noReviewsAvailable,), +// Text('No Reviews Available'), ), ) : isAvailabilty @@ -521,8 +529,8 @@ class __ProductDetailPageState extends State { ? Container( padding: EdgeInsets.all(15), alignment: Alignment.center, - child: Text( - 'No location Available'), + child: Text(TranslationBase.of(context).noLocationAvailable,), +// Text('No location Available'), ) : ListView.builder( physics: ScrollPhysics(), @@ -614,14 +622,7 @@ class __ProductDetailPageState extends State { ), Row( children: [ -// Container( -// width: 500, -// height: 100, -// margin: EdgeInsets.only(bottom: 100), -// color: Colors.white, -// child: Text("ENAD TEST"), -// ), - Container( + customerId != null ? Container( width: 410, height: 50, // margin: EdgeInsets.only(bottom: 5), @@ -630,7 +631,8 @@ class __ProductDetailPageState extends State { TranslationBase.of(context).recommended, bold: true, ), - ), + ) + : Container(), ], ), SingleChildScrollView( @@ -653,7 +655,6 @@ class __ProductDetailPageState extends State { onModelReady: (model) => model.getRecommendedProducts(widget.product.id), builder: (_, model, wi) => Container( child: -// Text(model.recommendedProductList[0].id), model.recommendedProductList.length != null ? Expanded( child: ListView.builder( @@ -668,10 +669,13 @@ class __ProductDetailPageState extends State { onTap: () async { GifLoaderDialogUtils.showMyDialog(context); - await Navigator.push( + RecommendedProductModel data = model.recommendedProductList[index]; + var json = data.toJson(); + PharmacyProduct product = new PharmacyProduct.fromJson(json); + await Navigator.pushReplacement( context, FadePage( - page: ProductDetailPage(model.recommendedProductList[index]['id']), + page: ProductDetailPage(product), )); GifLoaderDialogUtils.hideDialog(context); }, @@ -702,26 +706,26 @@ class __ProductDetailPageState extends State { child: Align( alignment: Alignment.topRight, child: IconButton( - icon: Icon(model.recommendedProductList[index]['isinwishlist'] != true ? Icons.favorite_border : Icons.favorite), - color: model.recommendedProductList[index]['isinwishlist'] != true ? Colors.grey : Colors.red, + icon: Icon(model.recommendedProductList[index].isinwishlist != true ? Icons.favorite_border : Icons.favorite), + color: model.recommendedProductList[index].isinwishlist != true ? Colors.grey : Colors.red, onPressed: () async { if (customerId != null ) { - if (!isInWishlit && model.recommendedProductList[index]['isinwishlist'] != true) { + if (!isInWishlit && model.recommendedProductList[index].isinwishlist != true) { GifLoaderDialogUtils.showMyDialog(context); - await addToWishlistFunction(model.recommendedProductList[index]['id']); + await addToWishlistFunction(model.recommendedProductList[index].id); // checkWishlist(); GifLoaderDialogUtils.hideDialog(context); setState((){ - model.recommendedProductList[index]['isinwishlist'] = true; + model.recommendedProductList[index].isinwishlist= true; }); } else { GifLoaderDialogUtils.showMyDialog(context); - await deleteFromWishlistFunction(model.recommendedProductList[index]['id']); + await deleteFromWishlistFunction(model.recommendedProductList[index].id); GifLoaderDialogUtils.hideDialog(context); setState((){ - model.recommendedProductList[index]['isinwishlist'] = false; + model.recommendedProductList[index].isinwishlist = false; }); } } else { @@ -773,10 +777,10 @@ class __ProductDetailPageState extends State { alignment: Alignment.center, // padding: EdgeInsets.only(left: 25, bottom: 20), - child: (model.recommendedProductList[index]['images'] != null && - model.recommendedProductList[index]['images'].length > 0) + child: (model.recommendedProductList[index].images != null && + model.recommendedProductList[index].images.length > 0) ? Image.network( - model.recommendedProductList[index]['images'][0]['src'].toString(), + model.recommendedProductList[index].images[0].src.toString(), // item.images[0].src, fit: BoxFit.cover, height: 60, @@ -788,7 +792,7 @@ class __ProductDetailPageState extends State { ), ), Container( - width: model.recommendedProductList[index]['rx_message'] != + width: model.recommendedProductList[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 @@ -802,20 +806,16 @@ class __ProductDetailPageState extends State { borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: - Texts( - model.recommendedProductList[index]['rx_message'] != null - ? model.recommendedProductList[index]['rx_message'] - : "", - color: - Colors.white, - regular: - true, - fontSize: - 10, - fontWeight: - FontWeight.w400, - ), + child: model.recommendedProductList[index].rxMessage != null + ? Texts( + languageID == "ar" + ? model.recommendedProductList[index].rxMessagen + : model.recommendedProductList[index].rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ):Texts (""), ), ]), Container( @@ -831,10 +831,9 @@ class __ProductDetailPageState extends State { .start, children: [ Text( - languageID == - "ar" - ? model.recommendedProductList[index]['namen'] - : model.recommendedProductList[index]['name'], + languageID == "ar" + ? model.recommendedProductList[index].namen + : model.recommendedProductList[index].name, style: TextStyle( color: @@ -853,7 +852,7 @@ class __ProductDetailPageState extends State { 5), child: Texts( - "SAR ${model.recommendedProductList[index]['price']}", + "SAR ${model.recommendedProductList[index].price}", bold: true, fontSize: @@ -879,8 +878,7 @@ class __ProductDetailPageState extends State { Alignment.topLeft, child: RatingBar.readOnly( - initialRating: - model.recommendedProductList[index]['approved_rating_sum'].toDouble(), + initialRating: model.recommendedProductList[index].approvedRatingSum.toDouble(), // initialRating: productRate, size: 13.0, @@ -900,7 +898,7 @@ class __ProductDetailPageState extends State { ), ), Texts( - "(${model.recommendedProductList[index]['approved_total_reviews'].toString()})", + "(${model.recommendedProductList[index].notApprovedTotalReviews.toString()})", // bold: true, fontSize: 12, @@ -941,7 +939,7 @@ class __ProductDetailPageState extends State { widget.product), ) : AppScaffold( - appBarTitle: 'product detail page', + appBarTitle: TranslationBase.of(context).productDetails, isShowAppBar: true, isPharmacy: true, isShowDecPage: false, @@ -1321,7 +1319,8 @@ class __ProductDetailPageState extends State { : Container( padding: EdgeInsets.all(15), alignment: Alignment.center, - child: Text('No Reviews Available'), + child: Text(TranslationBase.of(context).noReviewsAvailable), +// Text('No Reviews Available'), ), ) : isAvailabilty @@ -1938,7 +1937,8 @@ class _productNameAndPriceState extends State { width: 40, ), Text( - widget.item.stockAvailability, + languageID == 'ar'? + widget.item.stockAvailabilityn : widget.item.stockAvailability , style: widget.item.stockAvailability == 'Out of stock' ? TextStyle(fontWeight: FontWeight.bold, color: Colors.red) : TextStyle( @@ -2098,9 +2098,9 @@ fixingString(txt) { return newTxt; } -getLanguageID() async { - languageID = await sharedPref.getString(APP_LANGUAGE); -} +//getLanguageID() async { +// languageID = await sharedPref.getString(APP_LANGUAGE); +//} getSpecificationData(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); @@ -2165,7 +2165,8 @@ settingModalBottomSheet(context) { children: [ new ListTile( leading: Icon(Icons.shopping_cart), - title: Text('Add to cart'), + title: Text(TranslationBase.of(context) + .addToCart,), onTap: () => { if (price > 0) {addToCartFunction(price, itemID, context)} @@ -2177,12 +2178,14 @@ settingModalBottomSheet(context) { }), ListTile( leading: Icon(Icons.favorite_border), - title: Text('Add to wishlist'), + title: Text(TranslationBase.of(context) + .addToWishlist,), onTap: () => {addToWishlistFunction(itemID)}, ), ListTile( leading: Icon(Icons.compare), - title: Text('Compare'), + title: Text(TranslationBase.of(context) + .compare,), onTap: () => { Provider.of(context, listen: false) .addItem(specificationData), diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index be87ae1d..3a65dea3 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -69,22 +69,15 @@ class CartOrderPage extends StatelessWidget { child: Column( children: [ ...List.generate( - cart.shoppingCarts != null - ? cart.shoppingCarts.length - : 0, + cart.shoppingCarts != null ? cart.shoppingCarts.length : 0, (index) => ProductOrderItem( - cart.shoppingCarts[index], () { - print(cart.shoppingCarts[index] - .quantity); + cart.shoppingCarts[index], () {print(cart.shoppingCarts[index].quantity); model.changeProductQuantity(cart.shoppingCarts[index]).then((value) { if (model.state != ViewState.Error) { appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); } if (model.state == - ViewState.ErrorLocal) { - Utils.showErrorToast( - model.error); - } + ViewState.ErrorLocal) {Utils.showErrorToast(model.error);} }); }, () { diff --git a/lib/pages/pharmacies/screens/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index e4830583..9b91b77a 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -53,7 +53,7 @@ class _PharmacyPageState extends State { languageID = await sharedPref.getString(APP_LANGUAGE); } - List recommendedProductList = []; +// List recommendedProductList = []; List wishList = []; var model; @@ -66,8 +66,7 @@ class _PharmacyPageState extends State { checkWishlist(); // userInfo(widget.product.id, widget.product); userInfo(id, product); - print("-------------this--------------"); - print(itemID); + getLanguageID(); } @override @@ -138,7 +137,7 @@ class _PharmacyPageState extends State { return Container( // width: 160.0, height: - MediaQuery.of(context).size.height * 0.6, + MediaQuery.of(context).size.height * 0.3, padding: EdgeInsets.only( bottom: 5.0, left: 5.0, right: 8.0), margin: EdgeInsets.only(right: 10.0), @@ -217,16 +216,8 @@ class _PharmacyPageState extends State { 30.0)), child: Text( languageID == "ar" - ? model - .prescriptionsList[ - index] - .isInOutPatientDescriptionN - .toString() - : model - .prescriptionsList[ - index] - .isInOutPatientDescription - .toString(), + ? model.prescriptionsList[index].isInOutPatientDescriptionN.toString() + : model.prescriptionsList[index].isInOutPatientDescription.toString(), style: TextStyle( color: Colors.white, fontSize: 15.0, diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index 20d6b730..a7e71fab 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -57,10 +57,10 @@ class ProductTileItem extends StatelessWidget { shape: Border(right: BorderSide(color: Colors.grey.shade300, width: 1)), margin: EdgeInsets.symmetric( horizontal: 8, - vertical: 4, + vertical: 0, ), child: Container( - padding: EdgeInsets.symmetric(horizontal: 0), + padding: EdgeInsets.symmetric(horizontal: 4), width: MediaQuery.of(context).size.width / 3, child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -92,13 +92,13 @@ class ProductTileItem extends StatelessWidget { borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - item.rxMessage != null ? item.rxMessage : "", + child: item.rxMessage != null ? Texts( + projectProvider.isArabic ? item.rxMessagen : item.rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ), + ): Texts(""), ) ], ), diff --git a/lib/pages/pharmacies/wishlist.dart b/lib/pages/pharmacies/wishlist.dart index 000e8404..b75f709b 100644 --- a/lib/pages/pharmacies/wishlist.dart +++ b/lib/pages/pharmacies/wishlist.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/wishlist_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/ProductCheckTypeWidget.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -18,7 +19,7 @@ class _WishlistPageState extends State { return BaseView( onModelReady: (model) => model.getWishlistData(), builder: (_, model, wi) => AppScaffold( - appBarTitle: 'Wishlist page', + appBarTitle: TranslationBase.of(context).wishlist, isShowAppBar: widget.showBar, isShowDecPage: false, isPharmacy: true, diff --git a/lib/pages/pharmacy/profile/profile.dart b/lib/pages/pharmacy/profile/profile.dart index cd5c6ec7..918e9668 100644 --- a/lib/pages/pharmacy/profile/profile.dart +++ b/lib/pages/pharmacy/profile/profile.dart @@ -93,11 +93,12 @@ class _ProfilePageState extends State { }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).myAccount, - isShowAppBar: false, + isShowAppBar: true, isShowDecPage: false, isPharmacy: true, body: user != null ? Container( + color: Colors.white, child: SingleChildScrollView( child: Column( children: [ diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index 73b17558..16720946 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.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'; @@ -32,7 +33,7 @@ class _SearchProductsPageState extends State { builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( - appBarTitle: 'Search', + appBarTitle: TranslationBase.of(context).search, isBottomBar: false, isShowAppBar: true, backgroundColor: Colors.white, @@ -53,7 +54,7 @@ class _SearchProductsPageState extends State { key: _formKey, child: TextFields( autoFocus: true, - hintText: 'Search', + hintText: TranslationBase.of(context).search, fontSize: 14.5, prefixIcon: Icon(Icons.search), inputAction: TextInputAction.search, @@ -62,12 +63,14 @@ class _SearchProductsPageState extends State { }, onSubmit: (value) { searchMedicine(model, context); - msg = 'No Result Found'; +// msg = 'No Result Found'; + msg = TranslationBase.of(context).noResultFound; }, controller: textController, validator: (value) { if (value.isEmpty) { - return 'please Enter Product Name'; +// return 'please Enter Product Name'; + return TranslationBase.of(context).pleaseEnterProductName; } return null; }, @@ -79,7 +82,7 @@ class _SearchProductsPageState extends State { ), InkWell( child: Texts( - 'Cancel', + TranslationBase.of(context).cancel, fontSize: 17.0, fontWeight: FontWeight.w500, ), diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index cc374b96..1bbd431f 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -103,7 +104,7 @@ class _SubCategorisePageState extends State { Padding( padding: EdgeInsets.all(10.0), child: Container( - child: Texts('View All Categories'), + child: Texts(TranslationBase.of(context).viewCategorise), ), ), Icon(Icons.arrow_forward) @@ -266,8 +267,8 @@ class _SubCategorisePageState extends State { SizedBox( width: 10.0, ), - Texts( - 'Refine', + Texts(TranslationBase.of(context).refine, +// 'Refine', fontWeight: FontWeight.w600, ), ], @@ -304,8 +305,8 @@ class _SubCategorisePageState extends State { SizedBox( width: 10.0, ), - Texts( - 'Refine', + Texts(TranslationBase.of(context).refine, +// 'Refine', fontWeight: FontWeight.w600, ), @@ -313,8 +314,8 @@ class _SubCategorisePageState extends State { width: 250.0, ), InkWell( - child: Texts( - 'Close', + child: Texts(TranslationBase.of(context).close, +// 'Close', color: Colors.red, fontWeight: FontWeight.w600, @@ -336,7 +337,7 @@ class _SubCategorisePageState extends State { children: [ ExpansionTile( title: - Texts('Categorise'), + Texts(TranslationBase.of(context).categorise), children: [ ProcedureListWidget( model: model, @@ -374,7 +375,7 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts('Brands'), + title: Texts(TranslationBase.of(context).brands), children: [ ProcedureListWidget( model: model, @@ -413,7 +414,7 @@ class _SubCategorisePageState extends State { color: Colors.black12, ), ExpansionTile( - title: Texts('Price'), + title: Texts(TranslationBase.of(context).price), children: [ Container( color: Color( @@ -504,7 +505,8 @@ class _SubCategorisePageState extends State { Container( width: 100, child: Button( - label: 'Reset', + label: TranslationBase.of(context).reset, +// 'Reset', backgroundColor: Colors.red, ), @@ -559,7 +561,8 @@ class _SubCategorisePageState extends State { brandId: brandIds); }, - label: 'Apply', + label: TranslationBase.of(context).apply, +// 'Apply', backgroundColor: Colors .green, diff --git a/lib/services/pharmacy_services/recommendedProduct_service.dart b/lib/services/pharmacy_services/recommendedProduct_service.dart index 3b432c02..8953152e 100644 --- a/lib/services/pharmacy_services/recommendedProduct_service.dart +++ b/lib/services/pharmacy_services/recommendedProduct_service.dart @@ -16,9 +16,11 @@ class RecommendedProductService extends BaseService{ AuthenticatedUser authUser = new AuthenticatedUser(); AuthProvider authProvider = new AuthProvider(); - List> _recommendedProductList = List(); - List> get recommendedList => _recommendedProductList; +// List> _recommendedProductList = List(); +// List> get recommendedList => _recommendedProductList; + List _recommendedProductList = List(); + List get recommendedList => _recommendedProductList; Future getRecommendedProducts(productId) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); @@ -28,11 +30,10 @@ class RecommendedProductService extends BaseService{ onSuccess: (dynamic response, int statusCode) { _recommendedProductList.clear(); response['products'].forEach((item) { - _recommendedProductList.add(item); +// _recommendedProductList.add(item); + _recommendedProductList.add(RecommendedProductModel.fromJson(item)); }); - print("---------------------Recommended Product List------------------------"); - print(_recommendedProductList.length); //print(item['name']); print(response); }, onFailure: (String error, int statusCode) { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 6514a435..5ec22a2c 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -66,6 +66,8 @@ class TranslationBase { localizedValues['enterDocName'][locale.languageCode]; String get search => localizedValues['search'][locale.languageCode]; + String get noResultFound => localizedValues['noResultFound'][locale.languageCode]; + String get pleaseEnterProductName => localizedValues['pleaseEnterProductName'][locale.languageCode]; String get bookNow => localizedValues['bookNow'][locale.languageCode]; @@ -725,7 +727,12 @@ class TranslationBase { String get orders => localizedValues['orders'][locale.languageCode]; String get lakum => localizedValues['lakum'][locale.languageCode]; String get wishlist => localizedValues['wishlist'][locale.languageCode]; + String get brands => localizedValues['brands'][locale.languageCode]; + String get products => localizedValues['products'][locale.languageCode]; String get reviews => localizedValues['reviews'][locale.languageCode]; + String get productDetails => localizedValues['productDetails'][locale.languageCode]; + String get noReviewsAvailable => localizedValues['noReviewsAvailable'][locale.languageCode]; + String get noLocationAvailable => localizedValues['noLocationAvailable'][locale.languageCode]; String get myPrescriptions => localizedValues['myPrescriptions'][locale.languageCode]; String get medicationRefill => @@ -901,6 +908,10 @@ class TranslationBase { String get iAm => localizedValues['i-am'][locale.languageCode]; String get yearOld => localizedValues['years-old'][locale.languageCode]; String get categorise => localizedValues['categorise'][locale.languageCode]; + String get refine => localizedValues['refine'][locale.languageCode]; + String get apply => localizedValues['apply'][locale.languageCode]; + String get reset => localizedValues['reset'][locale.languageCode]; + String get viewCategorise => localizedValues['viewCategorise'][locale.languageCode]; String get cart => localizedValues['cart'][locale.languageCode]; String get wishList => localizedValues['wishList'][locale.languageCode]; String get Alhabibapp => localizedValues['Alhabibapp'][locale.languageCode]; @@ -1377,9 +1388,14 @@ class TranslationBase { String get quantitySize => localizedValues['quantitySize'][locale.languageCode]; String get addToCart => localizedValues['addToCart'][locale.languageCode]; + String get addToWishlist => localizedValues['addToWishlist'][locale.languageCode]; String get buyNow => localizedValues['buyNow'][locale.languageCode]; String get quantityShortcut => localizedValues['quantityShortcut'][locale.languageCode]; + String get noData => + localizedValues['noData'][locale.languageCode]; + String get no_data => + localizedValues['no_data'][locale.languageCode]; String get year => localizedValues['Year'][locale.languageCode]; String get month => localizedValues['Month'][locale.languageCode]; From b0165c0d292c0a9555699e9eb9bd69f8eb9adf3a Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 19 Sep 2021 16:38:01 +0300 Subject: [PATCH 5/9] fix pharmacy products filtering --- lib/pages/parent_categorise_page.dart | 594 ++++++++------------------ lib/pages/sub_categorise_page.dart | 533 +++++++---------------- 2 files changed, 327 insertions(+), 800 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index a7e43241..2efc7d96 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_mo import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -24,8 +25,7 @@ class ParentCategorisePage extends StatefulWidget { ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => - _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { @@ -56,9 +56,7 @@ class _ParentCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( appBarTitle: titleName, isBottomBar: false, isShowAppBar: true, @@ -126,31 +124,20 @@ class _ParentCategorisePageState extends State { color: Colors.white, child: Center( child: ListView.builder( - scrollDirection: - Axis.vertical, - itemCount: model - .categoriseParent.length, - itemBuilder: - (BuildContext context, - int index) { + scrollDirection: Axis.vertical, + itemCount: model.categoriseParent.length, + itemBuilder: (BuildContext context, int index) { return Container( child: Padding( - padding: - EdgeInsets.all(4.0), + padding: EdgeInsets.all(4.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(model - .categoriseParent[ - index] - .name), + Texts(model.categoriseParent[index].name), Divider( thickness: 0.6, - color: Colors - .black12, + color: Colors.black12, ) ], ), @@ -158,16 +145,9 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: - SubCategorisePage( - title: model - .categoriseParent[ - index] - .name, - id: model - .categoriseParent[ - index] - .id, + page: SubCategorisePage( + title: model.categoriseParent[index].name, + id: model.categoriseParent[index].id, parentId: id, )), ); @@ -201,28 +181,22 @@ class _ParentCategorisePageState extends State { child: Center( child: ListView.builder( scrollDirection: Axis.horizontal, - itemCount: model.categoriseParent.length > 8 - ? 8 - : model.categoriseParent.length, + itemCount: model.categoriseParent.length > 8 ? 8 : model.categoriseParent.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( @@ -233,10 +207,7 @@ class _ParentCategorisePageState extends State { ), ), Container( - width: MediaQuery.of(context) - .size - .width * - 0.197, + width: MediaQuery.of(context).size.width * 0.197, // height: MediaQuery.of(context) // .size // .height * @@ -244,12 +215,8 @@ class _ParentCategorisePageState extends State { child: Center( child: Texts( projectViewModel.isArabic - ? model - .categoriseParent[index] - .namen - : model - .categoriseParent[index] - .name, + ? model.categoriseParent[index].namen + : model.categoriseParent[index].name, fontSize: 13.4, fontWeight: FontWeight.w600, maxLines: 3, @@ -263,10 +230,8 @@ class _ParentCategorisePageState extends State { context, FadePage( page: SubCategorisePage( - title: model - .categoriseParent[index].name, - id: model - .categoriseParent[index].id, + title: model.categoriseParent[index].name, + id: model.categoriseParent[index].id, parentId: id, )), ); @@ -312,21 +277,16 @@ class _ParentCategorisePageState 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( @@ -337,8 +297,7 @@ class _ParentCategorisePageState extends State { ), Texts( 'Refine', - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, ), SizedBox( width: 250.0, @@ -347,13 +306,11 @@ class _ParentCategorisePageState extends State { child: Texts( 'Close', color: Colors.red, - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop( - context); + Navigator.pop(context); }, ), ], @@ -366,37 +323,27 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( - title: - Texts('Categorise'), + title: Texts('Categorise'), children: [ ProcedureListWidget( model: model, - masterList: model - .categoriseParent, - removeHistory: - (item) { + masterList: model.categoriseParent, + 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), ) ], ), @@ -409,33 +356,23 @@ class _ParentCategorisePageState extends State { 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), ) ], ), @@ -447,63 +384,40 @@ class _ParentCategorisePageState extends State { title: Texts('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( - 'Min'), + Texts('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( - 'Max'), + Texts('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, ), ), ], @@ -518,26 +432,18 @@ class _ParentCategorisePageState 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: [ Container( width: 100, child: Button( label: 'Reset', - backgroundColor: - Colors.red, + backgroundColor: Colors.red, ), ), SizedBox( @@ -546,54 +452,38 @@ class _ParentCategorisePageState extends State { Container( width: 200, child: Button( - onTap: () { - 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 = - ""; + String brandIds = ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; + if (brandIds == "") { + brandIds = brand.id; } else { - brandIds = - "$brandIds,${brand.id}"; + brandIds = "$brandIds,${brand.id}"; } } - model.getFilteredProducts( - min: minField - .text - .toString(), - max: maxField - .text - .toString(), - categoryId: - categoriesId, - brandId: - brandIds); + GifLoaderDialogUtils.showMyDialog(context); + + await model.getFilteredProducts( + min: minField.text.toString(), + max: maxField.text.toString(), + categoryId: categoriesId, + brandId: brandIds); + GifLoaderDialogUtils.hideDialog(context); + + Navigator.pop(context); }, label: 'Apply', - backgroundColor: - Colors - .green, + backgroundColor: Colors.green, ), ), ], @@ -659,13 +549,10 @@ class _ParentCategorisePageState extends State { ), styleOne == true ? Container( - height: model.parentProducts.length * - MediaQuery.of(context).size.height * - 0.15, + height: model.parentProducts.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, @@ -677,9 +564,7 @@ class _ParentCategorisePageState extends State { baseViewModel: model, child: InkWell( child: Card( - color: model.parentProducts[index] - .discountName != - null + color: model.parentProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, @@ -712,111 +597,62 @@ class _ParentCategorisePageState extends State { ), 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: [ - if (model - .parentProducts[ - index] - .discountName != - null) + if (model.parentProducts[index].discountName != null) RotatedBox( quarterTurns: 4, child: Container( - decoration: - BoxDecoration(), + decoration: BoxDecoration(), child: Padding( - padding: - EdgeInsets.only( + padding: EdgeInsets.only( right: 5.0, top: 20.0, bottom: 5.0, ), child: Texts( - 'offer' - .toUpperCase(), + 'offer'.toUpperCase(), color: Colors.red, fontSize: 13.0, - fontWeight: - FontWeight - .w900, + fontWeight: FontWeight.w900, ), ), - transform: new Matrix4 - .rotationZ( - 5.837200), + transform: new Matrix4.rotationZ(5.837200), ), ), 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 - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[ - index] - .images[0] - .thumb + model.parentProducts[index].images.isNotEmpty + ? model.parentProducts[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 - .parentProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 + width: model.parentProducts[index].rxMessage != null + ? MediaQuery.of(context).size.width / 5 : 0, - padding: - EdgeInsets.all(4), + padding: EdgeInsets.all(4), decoration: BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( - model - .parentProducts[ - index] - .rxMessage != - null - ? model - .parentProducts[ - index] - .rxMessage + model.parentProducts[index].rxMessage != null + ? model.parentProducts[index].rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), ), ], @@ -827,53 +663,32 @@ class _ParentCategorisePageState extends State { vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (model - .parentProducts[ - index] - .discountName != - null) + if (model.parentProducts[index].discountName != null) Container( - width: - double.infinity, + width: double.infinity, height: 13.0, - decoration: - BoxDecoration( - color: Color( - 0xff5AB145), + decoration: BoxDecoration( + color: Color(0xff5AB145), ), child: Center( child: Texts( - model - .parentProducts[ - index] - .discountName, + model.parentProducts[index].discountName, regular: true, - color: - Colors.white, + color: Colors.white, fontSize: 10.4, ), ), ), Texts( - model - .parentProducts[ - index] - .name, + model.parentProducts[index].name, regular: true, fontSize: 12, - fontWeight: - FontWeight.w700, + fontWeight: FontWeight.w700, ), Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: 4), + padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -883,26 +698,21 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: model - .parentProducts[ - index] - .approvedRatingSum > - 0 - ? (model.parentProducts[index].approvedRatingSum - .toDouble() / - model - .parentProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, + totalAverage: + model.parentProducts[index].approvedRatingSum > 0 + ? (model.parentProducts[index].approvedRatingSum + .toDouble() / + model.parentProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, forceStars: true), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) ], ), @@ -917,8 +727,7 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model - .parentProducts[index]), + page: ProductDetailPage(model.parentProducts[index]), )), }, )); @@ -926,14 +735,11 @@ class _ParentCategorisePageState extends State { ), ) : Container( - height: model.parentProducts.length * - MediaQuery.of(context).size.height * - 0.122, + height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), itemCount: model.parentProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -943,11 +749,9 @@ class _ParentCategorisePageState 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, @@ -955,22 +759,11 @@ class _ParentCategorisePageState extends State { ), ), Container( - margin: - EdgeInsets.fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, child: Image.network( - model - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[ - index] - .images[0] - .thumb + model.parentProducts[index].images.isNotEmpty + ? model.parentProducts[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.contain, height: 80, @@ -981,44 +774,22 @@ class _ParentCategorisePageState extends State { Column( children: [ Container( - width: model - .parentProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 + width: model.parentProducts[index].rxMessage != null + ? MediaQuery.of(context).size.width / 5 : 0, - padding: - EdgeInsets.all(4), + padding: EdgeInsets.all(4), decoration: BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( - model - .parentProducts[ - index] - .rxMessage != - null - ? model - .parentProducts[ - index] - .rxMessage + model.parentProducts[index].rxMessage != null + ? model.parentProducts[index].rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), ), ], @@ -1031,29 +802,19 @@ class _ParentCategorisePageState 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( - model - .parentProducts[index] - .name, + model.parentProducts[index].name, regular: true, fontSize: 13.2, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, maxLines: 5, ), ), @@ -1061,9 +822,7 @@ class _ParentCategorisePageState 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.parentProducts[index].price}", bold: true, @@ -1073,30 +832,20 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: model - .parentProducts[ - index] - .approvedRatingSum > - 0 - ? (model - .parentProducts[ - index] - .approvedRatingSum - .toDouble() / - model - .parentProducts[ - index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, + totalAverage: + model.parentProducts[index].approvedRatingSum > 0 + ? (model.parentProducts[index].approvedRatingSum + .toDouble() / + model.parentProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, forceStars: true), Texts( "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) ], ), @@ -1110,8 +859,7 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.parentProducts[index]), + page: ProductDetailPage(model.parentProducts[index]), )), }, ); @@ -1125,8 +873,7 @@ class _ParentCategorisePageState 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; } @@ -1134,8 +881,7 @@ class _ParentCategorisePageState 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/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index cc374b96..737ccafe 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/product_detail.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -21,8 +22,7 @@ class SubCategorisePage extends StatefulWidget { 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 { @@ -50,9 +50,7 @@ class _SubCategorisePageState extends State { TextEditingController maxField = TextEditingController(); return BaseView( 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, @@ -84,8 +82,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, @@ -97,8 +94,7 @@ class _SubCategorisePageState extends State { children: [ InkWell( child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( padding: EdgeInsets.all(10.0), @@ -115,30 +111,21 @@ 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(model - .subCategorise[ - index] - .name), + Texts(model.subCategorise[index].name), Divider( thickness: 0.6, color: Colors.black12, @@ -149,12 +136,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: - FinalProductsPage( - id: model - .subCategorise[ - index] - .id, + page: FinalProductsPage( + id: model.subCategorise[index].id, ), ), ); @@ -187,23 +170,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( @@ -214,14 +193,8 @@ 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( model.subCategorise[index].name, @@ -281,21 +254,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( @@ -306,8 +274,7 @@ class _SubCategorisePageState extends State { ), Texts( 'Refine', - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, ), SizedBox( width: 250.0, @@ -316,13 +283,11 @@ class _SubCategorisePageState extends State { child: Texts( 'Close', color: Colors.red, - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop( - context); + Navigator.pop(context); }, ), ], @@ -335,37 +300,27 @@ class _SubCategorisePageState extends State { Column( children: [ ExpansionTile( - title: - Texts('Categorise'), + title: Texts('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), ) ], ), @@ -378,33 +333,23 @@ class _SubCategorisePageState extends State { 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), ) ], ), @@ -416,63 +361,40 @@ class _SubCategorisePageState extends State { title: Texts('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( - 'Min'), + Texts('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( - 'Max'), + Texts('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, ), ), ], @@ -487,26 +409,18 @@ 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: [ Container( width: 100, child: Button( label: 'Reset', - backgroundColor: - Colors.red, + backgroundColor: Colors.red, ), ), SizedBox( @@ -515,54 +429,36 @@ class _SubCategorisePageState extends State { Container( width: 200, child: Button( - onTap: () { - 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 = - ""; + String brandIds = ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; + if (brandIds == "") { + brandIds = brand.id; } else { - brandIds = - "$brandIds,${brand.id}"; + brandIds = "$brandIds,${brand.id}"; } } + GifLoaderDialogUtils.showMyDialog(context); - model.getFilteredProducts( - min: minField - .text - .toString(), - max: maxField - .text - .toString(), - categoryId: - categoriesId, - brandId: - brandIds); + await model.getFilteredProducts( + min: minField.text.toString(), + max: maxField.text.toString(), + categoryId: categoriesId, + brandId: brandIds); + GifLoaderDialogUtils.hideDialog(context); + Navigator.pop(context); }, label: 'Apply', - backgroundColor: - Colors - .green, + backgroundColor: Colors.green, ), ), ], @@ -628,27 +524,22 @@ class _SubCategorisePageState extends State { ), styleOne == true ? Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.15, + height: model.parentProducts.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, + itemCount: model.parentProducts.length, itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.subProducts[index] - .discountName != - null + color: model.parentProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, @@ -681,77 +572,41 @@ class _SubCategorisePageState extends State { ), 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.parentProducts[index].images.isNotEmpty + ? model.parentProducts[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 + width: model.parentProducts[index].rxMessage != null + ? MediaQuery.of(context).size.width / 5 : 0, - padding: - EdgeInsets.all(4), + padding: EdgeInsets.all(4), decoration: BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( - model.subProducts[index] - .rxMessage != - null - ? model - .subProducts[ - index] - .rxMessage + model.parentProducts[index].rxMessage != null + ? model.parentProducts[index].rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), ), ], @@ -762,26 +617,18 @@ class _SubCategorisePageState extends State { vertical: 0, ), child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - model.subProducts[index] - .name, + model.parentProducts[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}", + "SAR ${model.parentProducts[index].price}", bold: true, fontSize: 14, ), @@ -789,26 +636,21 @@ class _SubCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: model - .subProducts[ - index] - .approvedRatingSum > - 0 - ? (model.subProducts[index].approvedRatingSum - .toDouble() / - model - .subProducts[index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, + totalAverage: + model.parentProducts[index].approvedRatingSum > 0 + ? (model.parentProducts[index].approvedRatingSum + .toDouble() / + model.parentProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, forceStars: true), Texts( - "(${model.subProducts[index].approvedTotalReviews})", + "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) ], ), @@ -823,8 +665,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[index]), + page: ProductDetailPage(model.parentProducts[index]), )), }, )); @@ -832,14 +673,11 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.subProducts.length * - MediaQuery.of(context).size.height * - 0.122, + height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122, child: ListView.builder( physics: NeverScrollableScrollPhysics(), - itemCount: model.subProducts.length, - itemBuilder: - (BuildContext context, int index) { + itemCount: model.parentProducts.length, + itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( child: Row( @@ -849,11 +687,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, @@ -861,22 +697,11 @@ class _SubCategorisePageState extends State { ), ), Container( - margin: - EdgeInsets.fromLTRB( - 0, 0, 0, 0), - alignment: - Alignment.center, + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, child: Image.network( - model - .subProducts[ - index] - .images - .isNotEmpty - ? model - .subProducts[ - index] - .images[0] - .thumb + model.parentProducts[index].images.isNotEmpty + ? model.parentProducts[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.contain, height: 80, @@ -887,42 +712,22 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - width: model - .subProducts[ - index] - .rxMessage != - null - ? MediaQuery.of( - context) - .size - .width / - 5 + width: model.parentProducts[index].rxMessage != null + ? MediaQuery.of(context).size.width / 5 : 0, - padding: - EdgeInsets.all(4), + padding: EdgeInsets.all(4), decoration: BoxDecoration( - color: - Color(0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: Radius - .circular( - 6)), + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( - model.subProducts[index] - .rxMessage != - null - ? model - .subProducts[ - index] - .rxMessage + model.parentProducts[index].rxMessage != null + ? model.parentProducts[index].rxMessage : "", color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ), ), ], @@ -936,28 +741,19 @@ 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( - model.subProducts[index] - .name, + model.parentProducts[index].name, regular: true, fontSize: 13.2, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, maxLines: 5, ), ), @@ -965,11 +761,9 @@ 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}", + "SAR ${model.parentProducts[index].price}", bold: true, fontSize: 14, ), @@ -977,30 +771,20 @@ class _SubCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: model - .subProducts[ - index] - .approvedRatingSum > - 0 - ? (model - .subProducts[ - index] - .approvedRatingSum - .toDouble() / - model - .parentProducts[ - index] - .approvedRatingSum - .toDouble()) - .toDouble() - : 0, + totalAverage: + model.parentProducts[index].approvedRatingSum > 0 + ? (model.parentProducts[index].approvedRatingSum + .toDouble() / + model.parentProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, forceStars: true), Texts( - "(${model.subProducts[index].approvedTotalReviews})", + "(${model.parentProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, - fontWeight: - FontWeight.w400, + fontWeight: FontWeight.w400, ) ], ), @@ -1014,8 +798,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage( - model.subProducts[index]), + page: ProductDetailPage(model.parentProducts[index]), )), }, ); @@ -1029,8 +812,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; } @@ -1038,8 +820,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; } From cb9d8cb9d94da4488376c60a1230ebcfef957419 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 20 Sep 2021 08:40:52 +0300 Subject: [PATCH 6/9] fix pharmacy products filtering --- .../service/pharmacy_categorise_service.dart | 114 ++++++++++-------- .../pharmacy_categorise_view_model.dart | 41 ++++--- lib/pages/sub_categorise_page.dart | 69 +++++------ 3 files changed, 116 insertions(+), 108 deletions(-) diff --git a/lib/core/service/pharmacy_categorise_service.dart b/lib/core/service/pharmacy_categorise_service.dart index 58f58ddb..c13f0548 100644 --- a/lib/core/service/pharmacy_categorise_service.dart +++ b/lib/core/service/pharmacy_categorise_service.dart @@ -95,9 +95,8 @@ class PharmacyCategoriseService extends BaseService { Future searchProducts({String productName}) async { hasError = false; _searchList.clear(); - String endPoint = productName != null - ? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1' - : GET_SEARCH_PRODUCTS + ""; + String endPoint = + productName != null ? GET_SEARCH_PRODUCTS + "$productName" + '&language_id=1' : GET_SEARCH_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -132,8 +131,7 @@ class PharmacyCategoriseService extends BaseService { Future getCategoriseParent({String id}) async { hasError = false; _parentCategoriseList.clear(); - String endPoint = - id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + ""; + String endPoint = id != null ? GET_CATEGORISE_PARENT + "$id" : GET_CATEGORISE_PARENT + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -151,9 +149,7 @@ class PharmacyCategoriseService extends BaseService { Future getParentProducts({String id}) async { hasError = false; _parentProductsList.clear(); - String endPoint = id != null - ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' - : GET_PARENT_PRODUCTS + ""; + String endPoint = id != null ? GET_PARENT_PRODUCTS + "$id" + '&page=1&limit=50' : GET_PARENT_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -172,8 +168,7 @@ class PharmacyCategoriseService extends BaseService { hasError = false; _subCategoriseList.clear(); - String endPoint = - id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + ""; + String endPoint = id != null ? GET_SUB_CATEGORISE + "$id" : GET_SUB_CATEGORISE + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -191,9 +186,7 @@ class PharmacyCategoriseService extends BaseService { Future getSubProducts({String id}) async { hasError = false; _subProductsList.clear(); - String endPoint = id != null - ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' - : GET_SUB_PRODUCTS + ""; + String endPoint = id != null ? GET_SUB_PRODUCTS + "$id" + '&page=1&limit=50' : GET_SUB_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -211,8 +204,7 @@ class PharmacyCategoriseService extends BaseService { Future getFinalProducts({String id}) async { hasError = false; _finalProducts.clear(); - String endPoint = - id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + ""; + String endPoint = id != null ? GET_FINAL_PRODUCTS + "$id" : GET_FINAL_PRODUCTS + ""; await baseAppClient.getPharmacy( endPoint, onSuccess: (dynamic response, int statusCode) { @@ -249,14 +241,11 @@ class PharmacyCategoriseService extends BaseService { Future getLastVisitedProducts() async { String lastVisited = ""; - if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != - null) { - lastVisited = - await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); + if (await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS) != null) { + lastVisited = await this.sharedPref.getString(PHARMACY_LAST_VISITED_PRODUCTS); try { - await baseAppClient - .getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_IDS$lastVisited", + onSuccess: (dynamic response, int statusCode) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); @@ -277,8 +266,7 @@ class PharmacyCategoriseService extends BaseService { 'id,discount_ids,name,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage,reviews', }; try { - await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_PHARMACY_BEST_SELLER_PRODUCT, onSuccess: (dynamic response, int statusCode) { _finalProducts.clear(); response['products'].forEach((item) { _finalProducts.add(PharmacyProduct.fromJson(item)); @@ -292,8 +280,7 @@ class PharmacyCategoriseService extends BaseService { } } - Future getFilteredProducts( - {String categoryId, String brandId, String min, String max}) async { + Future getFilteredProducts({String categoryId, String brandId, String min, String max}) async { hasError = false; String endPoint; @@ -317,24 +304,47 @@ class PharmacyCategoriseService extends BaseService { ); } + Future getFilteredSubProducts({String categoryId, String brandId, String min, String max}) async { + hasError = false; + String endPoint; + + _subProductsList.clear(); + endPoint = FILTERED_PRODUCTS + + "$categoryId" + + "&manufacturerids=$brandId" + + "&price_min=$min" + + "&price_max=$max&page=1&limit=50"; + await baseAppClient.getPharmacy( + endPoint, + onSuccess: (dynamic response, int statusCode) { + response['products'].forEach((item) { + _subProductsList.add(PharmacyProduct.fromJson(item)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + ); + } + Future getMostViewedProducts() async { Map queryParams = { 'fields': - 'id,discount_ids,name,reviews,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage', + 'id,discount_ids,name,reviews,namen,localized_names,display_order,short_description,full_description,full_descriptionn,sku,order_minimum_quantity,order_maximum_quantity,price,old_price,images,is_rx,rx_message,rx_messagen,discount_name,discount_namen,approved_rating_sum,approved_total_reviews,allow_back_in_stock_subscriptions,stock_quantity,stock_availability,stock_availabilityn,discount_percentage', }; try { - await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, - onSuccess: (dynamic response, int statusCode) { - _finalProducts.clear(); - response['products'].forEach((item) { - _finalProducts.add(PharmacyProduct.fromJson(item)); - }); - print("most viewed products ---------"); - print(response); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, queryParams: queryParams); + await baseAppClient.getPharmacy(GET_MOST_VIEWED_PRODUCTS, onSuccess: (dynamic response, int statusCode) { + _finalProducts.clear(); + response['products'].forEach((item) { + _finalProducts.add(PharmacyProduct.fromJson(item)); + }); + print("most viewed products ---------"); + print(response); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, queryParams: queryParams); } catch (error) { throw error; } @@ -342,22 +352,20 @@ class PharmacyCategoriseService extends BaseService { Future getNewProducts() async { Map queryParams = { - 'fields': - 'Id,name,namen,localized_names,price,images,sku,stock_availability,published', + 'fields': 'Id,name,namen,localized_names,price,images,sku,stock_availability,published', }; try { - await baseAppClient.getPharmacy(GET_NEW_PRODUCTS, - onSuccess: (dynamic response, int statusCode) { - _finalProducts.clear(); - response['products'].forEach((item) { - _finalProducts.add(PharmacyProduct.fromJson(item)); - }); - print("new products ---------"); - print(response); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, queryParams: queryParams); + await baseAppClient.getPharmacy(GET_NEW_PRODUCTS, onSuccess: (dynamic response, int statusCode) { + _finalProducts.clear(); + response['products'].forEach((item) { + _finalProducts.add(PharmacyProduct.fromJson(item)); + }); + print("new products ---------"); + print(response); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, queryParams: queryParams); } catch (error) { throw error; } diff --git a/lib/core/viewModels/pharmacy_categorise_view_model.dart b/lib/core/viewModels/pharmacy_categorise_view_model.dart index e48329ba..4b5687fc 100644 --- a/lib/core/viewModels/pharmacy_categorise_view_model.dart +++ b/lib/core/viewModels/pharmacy_categorise_view_model.dart @@ -17,28 +17,20 @@ import 'base_view_model.dart'; class PharmacyCategoriseViewModel extends BaseViewModel { bool hasError = false; - PharmacyCategoriseService _pharmacyCategoriseService = - locator(); + PharmacyCategoriseService _pharmacyCategoriseService = locator(); - List get categorise => - _pharmacyCategoriseService.categoriseList; + List get categorise => _pharmacyCategoriseService.categoriseList; - List get categoriseParent => - _pharmacyCategoriseService.parentCategoriseList; + List get categoriseParent => _pharmacyCategoriseService.parentCategoriseList; - List get parentProducts => - _pharmacyCategoriseService.parentProductsList; + List get parentProducts => _pharmacyCategoriseService.parentProductsList; - List get subCategorise => - _pharmacyCategoriseService.subCategoriseList; + List get subCategorise => _pharmacyCategoriseService.subCategoriseList; - List get subProducts => - _pharmacyCategoriseService.subProductsList; + List get subProducts => _pharmacyCategoriseService.subProductsList; - List get finalProducts => - _pharmacyCategoriseService.finalProducts; - List get brandsList => - _pharmacyCategoriseService.brandsList; + List get finalProducts => _pharmacyCategoriseService.finalProducts; + List get brandsList => _pharmacyCategoriseService.brandsList; List get searchList => _pharmacyCategoriseService.searchList; @@ -157,12 +149,23 @@ class PharmacyCategoriseViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getFilteredProducts( - {String categoryId, String brandId, String min, String max}) async { + Future getFilteredProducts({String categoryId, String brandId, String min, String max}) async { hasError = false; // _insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); - await _pharmacyCategoriseService.getFilteredProducts( + await _pharmacyCategoriseService.getFilteredProducts(categoryId: categoryId, brandId: brandId, max: max, min: min); + if (_pharmacyCategoriseService.hasError) { + error = _pharmacyCategoriseService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + Future getFilteredSubProducts({String categoryId, String brandId, String min, String max}) async { + hasError = false; + // _insuranceCardService.clearInsuranceCard(); + setState(ViewState.Busy); + await _pharmacyCategoriseService.getFilteredSubProducts( categoryId: categoryId, brandId: brandId, max: max, min: min); if (_pharmacyCategoriseService.hasError) { error = _pharmacyCategoriseService.error; diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 737ccafe..1e57e319 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -449,7 +449,7 @@ class _SubCategorisePageState extends State { } GifLoaderDialogUtils.showMyDialog(context); - await model.getFilteredProducts( + await model.getFilteredSubProducts( min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, @@ -524,7 +524,7 @@ class _SubCategorisePageState extends State { ), styleOne == true ? Container( - height: model.parentProducts.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( @@ -533,13 +533,13 @@ class _SubCategorisePageState extends State { mainAxisSpacing: 2.0, childAspectRatio: 0.9, ), - itemCount: model.parentProducts.length, + itemCount: model.subProducts.length, itemBuilder: (BuildContext context, int index) { return NetworkBaseView( baseViewModel: model, child: InkWell( child: Card( - color: model.parentProducts[index].discountName != null + color: model.subProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, elevation: 0, @@ -583,15 +583,15 @@ class _SubCategorisePageState extends State { margin: EdgeInsets.fromLTRB(0, 16, 0, 0), alignment: Alignment.center, child: Image.network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[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.parentProducts[index].rxMessage != null + width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, padding: EdgeInsets.all(4), @@ -600,8 +600,8 @@ class _SubCategorisePageState extends State { borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( - model.parentProducts[index].rxMessage != null - ? model.parentProducts[index].rxMessage + model.subProducts[index].rxMessage != null + ? model.subProducts[index].rxMessage : "", color: Colors.white, regular: true, @@ -620,7 +620,7 @@ class _SubCategorisePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - model.parentProducts[index].name, + model.subProducts[index].name, regular: true, fontSize: 12, fontWeight: FontWeight.w400, @@ -628,7 +628,7 @@ class _SubCategorisePageState extends State { Padding( padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( - "SAR ${model.parentProducts[index].price}", + "SAR ${model.subProducts[index].price}", bold: true, fontSize: 14, ), @@ -637,17 +637,16 @@ class _SubCategorisePageState extends State { children: [ StarRating( totalAverage: - model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index].approvedRatingSum + model.subProducts[index].approvedRatingSum > 0 + ? (model.subProducts[index].approvedRatingSum .toDouble() / - model.parentProducts[index] - .approvedRatingSum + model.subProducts[index].approvedRatingSum .toDouble()) .toDouble() : 0, forceStars: true), Texts( - "(${model.parentProducts[index].approvedTotalReviews})", + "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, fontWeight: FontWeight.w400, @@ -665,7 +664,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.parentProducts[index]), + page: ProductDetailPage(model.subProducts[index]), )), }, )); @@ -673,10 +672,10 @@ class _SubCategorisePageState extends State { ), ) : Container( - height: model.parentProducts.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.parentProducts.length, + itemCount: model.subProducts.length, itemBuilder: (BuildContext context, int index) { return InkWell( child: Card( @@ -700,8 +699,8 @@ class _SubCategorisePageState extends State { margin: EdgeInsets.fromLTRB(0, 0, 0, 0), alignment: Alignment.center, child: Image.network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[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.contain, height: 80, @@ -712,7 +711,7 @@ class _SubCategorisePageState extends State { Column( children: [ Container( - width: model.parentProducts[index].rxMessage != null + width: model.subProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5 : 0, padding: EdgeInsets.all(4), @@ -721,8 +720,8 @@ class _SubCategorisePageState extends State { borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), child: Texts( - model.parentProducts[index].rxMessage != null - ? model.parentProducts[index].rxMessage + model.subProducts[index].rxMessage != null + ? model.subProducts[index].rxMessage : "", color: Colors.white, regular: true, @@ -750,7 +749,7 @@ class _SubCategorisePageState extends State { Container( width: MediaQuery.of(context).size.width * 0.65, child: Texts( - model.parentProducts[index].name, + model.subProducts[index].name, regular: true, fontSize: 13.2, fontWeight: FontWeight.w500, @@ -763,7 +762,7 @@ class _SubCategorisePageState extends State { Padding( padding: const EdgeInsets.only(top: 4, bottom: 4), child: Texts( - "SAR ${model.parentProducts[index].price}", + "SAR ${model.subProducts[index].price}", bold: true, fontSize: 14, ), @@ -771,17 +770,15 @@ class _SubCategorisePageState extends State { Row( children: [ StarRating( - totalAverage: - model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index].approvedRatingSum - .toDouble() / - model.parentProducts[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, + totalAverage: model.subProducts[index].approvedRatingSum > 0 + ? (model.subProducts[index].approvedRatingSum.toDouble() / + model.subProducts[index].approvedRatingSum + .toDouble()) + .toDouble() + : 0, forceStars: true), Texts( - "(${model.parentProducts[index].approvedTotalReviews})", + "(${model.subProducts[index].approvedTotalReviews})", regular: true, fontSize: 10, fontWeight: FontWeight.w400, @@ -798,7 +795,7 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: ProductDetailPage(model.parentProducts[index]), + page: ProductDetailPage(model.subProducts[index]), )), }, ); From bcfbca98a160818cd0f6e01c987cbdabce0cf91a Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Mon, 20 Sep 2021 10:33:41 +0300 Subject: [PATCH 7/9] fixed arabic version --- lib/config/localized_values.dart | 1 + .../pharmacies/screens/cart-order-page.dart | 4 ++-- lib/pages/sub_categorise_page.dart | 16 +++++++++------- lib/uitl/translations_delegate_base.dart | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 73490794..28d53047 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -302,6 +302,7 @@ const Map localizedValues = { "ar": "خطأ في إرسال البريد الإلكتروني" }, "close": {"en": "Close", "ar": "مغلق"}, + "closeIt": {"en": "Close", "ar": "اغلاق"}, "booked": {"en": "Booked", "ar": "محجوز"}, "confirmed": {"en": "Confirmed", "ar": "مؤكد"}, "arrived": {"en": "Arrived", "ar": "تم الحضور"}, diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 3a65dea3..6c760fcd 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -200,8 +200,8 @@ class CartOrderPage extends StatelessWidget { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text( - 'There is no data', + child: Text(TranslationBase.of(context).noData, +// 'There is no data', style: TextStyle(fontSize: 30), ), ) diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 1bbd431f..ef76fd65 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -314,7 +314,7 @@ class _SubCategorisePageState extends State { width: 250.0, ), InkWell( - child: Texts(TranslationBase.of(context).close, + child: Texts(TranslationBase.of(context).closeIt, // 'Close', color: Colors.red, fontWeight: @@ -502,13 +502,15 @@ class _SubCategorisePageState extends State { MainAxisAlignment .spaceEvenly, children: [ - Container( - width: 100, - child: Button( - label: TranslationBase.of(context).reset, + Expanded( + child: Container( + width: 100, + child: Button( + label: TranslationBase.of(context).reset, // 'Reset', - backgroundColor: - Colors.red, + backgroundColor: + Colors.red, + ), ), ), SizedBox( diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 5ec22a2c..f6363a22 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -343,6 +343,7 @@ class TranslationBase { localizedValues['scanQRHospital'][locale.languageCode]; String get sendEmail => localizedValues['sendEmail'][locale.languageCode]; String get close => localizedValues['close'][locale.languageCode]; + String get closeIt => localizedValues['closeIt'][locale.languageCode]; String get booked => localizedValues['booked'][locale.languageCode]; String get confirmed => localizedValues['confirmed'][locale.languageCode]; String get arrived => localizedValues['arrived'][locale.languageCode]; From 0a1db70229775a797ba7296df01114d7ce7706ce Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 22 Sep 2021 11:59:51 +0300 Subject: [PATCH 8/9] parent product and sub product update --- lib/pages/parent_categorise_page.dart | 543 ++++++++++++++------------ lib/pages/sub_categorise_page.dart | 482 ++++++++++++----------- 2 files changed, 546 insertions(+), 479 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 2efc7d96..ba20010b 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -547,113 +547,256 @@ class _ParentCategorisePageState extends State { thickness: 1.0, color: Colors.grey.shade400, ), - styleOne == true - ? Container( - height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.15, - child: GridView.builder( - physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 0.9, - ), - itemCount: model.parentProducts.length, - itemBuilder: (BuildContext context, int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model.parentProducts[index].discountName != null - ? Color(0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - left: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - top: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(110.0), + model.parentProducts.isNotEmpty + ? styleOne == true + ? Container( + height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.15, + child: GridView.builder( + physics: NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 0.9, + ), + itemCount: model.parentProducts.length, + itemBuilder: (BuildContext context, int index) { + return NetworkBaseView( + baseViewModel: model, + child: InkWell( + child: Card( + color: model.parentProducts[index].discountName != null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + ), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), + ), + color: Colors.white, + ), + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + if (model.parentProducts[index].discountName != null) + RotatedBox( + quarterTurns: 4, + child: Container( + decoration: BoxDecoration(), + child: Padding( + padding: EdgeInsets.only( + right: 5.0, + top: 20.0, + bottom: 5.0, + ), + child: Texts( + 'offer'.toUpperCase(), + color: Colors.red, + fontSize: 13.0, + fontWeight: FontWeight.w900, + ), + ), + transform: new Matrix4.rotationZ(5.837200), + ), + ), + Container( + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, + child: Image.network( + model.parentProducts[index].images.isNotEmpty + ? model.parentProducts[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.parentProducts[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: Texts( + model.parentProducts[index].rxMessage != null + ? model.parentProducts[index].rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (model.parentProducts[index].discountName != null) + Container( + width: double.infinity, + height: 13.0, + decoration: BoxDecoration( + color: Color(0xff5AB145), + ), + child: Center( + child: Texts( + model.parentProducts[index].discountName, + regular: true, + color: Colors.white, + fontSize: 10.4, + ), + ), + ), + Texts( + model.parentProducts[index].name, + regular: true, + fontSize: 12, + fontWeight: FontWeight.w700, + ), + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: + model.parentProducts[index].approvedRatingSum > 0 + ? (model.parentProducts[index] + .approvedRatingSum + .toDouble() / + model.parentProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: true), + Texts( + "(${model.parentProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + ], + ), + ], + ), + ), + ], + ), ), - color: Colors.white, ), - padding: EdgeInsets.symmetric(horizontal: 0), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model.parentProducts[index]), + )), + }, + )); + }, + ), + ) + : Container( + height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemCount: model.parentProducts.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + child: Card( + child: Row( children: [ Stack( children: [ - if (model.parentProducts[index].discountName != null) - RotatedBox( - quarterTurns: 4, - child: Container( + Column( + children: [ + Container( decoration: BoxDecoration(), child: Padding( padding: EdgeInsets.only( - right: 5.0, - top: 20.0, - bottom: 5.0, - ), - child: Texts( - 'offer'.toUpperCase(), - color: Colors.red, - fontSize: 13.0, - fontWeight: FontWeight.w900, + left: 9.0, + top: 8.0, + right: 10.0, ), ), - transform: new Matrix4.rotationZ(5.837200), ), - ), - Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, - child: Image.network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[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( + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, + child: Image.network( + model.parentProducts[index].images.isNotEmpty + ? model.parentProducts[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.contain, + height: 80, + ), + ), + ], ), - Container( - width: model.parentProducts[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: Texts( - model.parentProducts[index].rxMessage != null - ? model.parentProducts[index].rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ), + Column( + children: [ + Container( + width: model.parentProducts[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: Texts( + model.parentProducts[index].rxMessage != null + ? model.parentProducts[index].rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ), + ), + ], ), ], ), @@ -663,29 +806,24 @@ class _ParentCategorisePageState extends State { vertical: 0, ), child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (model.parentProducts[index].discountName != null) - Container( - width: double.infinity, - height: 13.0, - decoration: BoxDecoration( - color: Color(0xff5AB145), - ), - child: Center( - child: Texts( - model.parentProducts[index].discountName, - regular: true, - color: Colors.white, - fontSize: 10.4, - ), - ), + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of(context).size.width * 0.65, + child: Texts( + model.parentProducts[index].name, + regular: true, + fontSize: 13.2, + fontWeight: FontWeight.w500, + maxLines: 5, ), - Texts( - model.parentProducts[index].name, - regular: true, - fontSize: 12, - fontWeight: FontWeight.w700, + ), + SizedBox( + height: 8.0, ), Padding( padding: const EdgeInsets.only(top: 4, bottom: 4), @@ -722,148 +860,43 @@ class _ParentCategorisePageState extends State { ], ), ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage(model.parentProducts[index]), - )), - }, - )); - }, - ), - ) - : Container( - height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122, - child: ListView.builder( - physics: NeverScrollableScrollPhysics(), - itemCount: model.parentProducts.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - child: Card( - child: Row( - children: [ - Stack( - children: [ - Column( - children: [ - Container( - decoration: BoxDecoration(), - child: Padding( - padding: EdgeInsets.only( - left: 9.0, - top: 8.0, - right: 10.0, - ), - ), - ), - Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, - child: Image.network( - model.parentProducts[index].images.isNotEmpty - ? model.parentProducts[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.contain, - height: 80, - ), - ), - ], - ), - Column( - children: [ - Container( - width: model.parentProducts[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: Texts( - model.parentProducts[index].rxMessage != null - ? model.parentProducts[index].rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ), - ), - ], - ), - ], - ), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 4.0, - ), - Container( - width: MediaQuery.of(context).size.width * 0.65, - child: Texts( - model.parentProducts[index].name, - regular: true, - fontSize: 13.2, - fontWeight: FontWeight.w500, - maxLines: 5, - ), - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), - child: Texts( - "SAR ${model.parentProducts[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( - children: [ - StarRating( - totalAverage: - model.parentProducts[index].approvedRatingSum > 0 - ? (model.parentProducts[index].approvedRatingSum - .toDouble() / - model.parentProducts[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) - ], - ), - ], - ), - ), - ], + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model.parentProducts[index]), + )), + }, + ); + }), + ) + : Padding( + padding: const EdgeInsets.all(12.0), + child: Container( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage(model.parentProducts[index]), - )), - }, - ); - }), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + 'There is no data', + style: TextStyle(fontSize: 30), + ), + ) + ], + ), + ), + ), ) ], ), diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 1e57e319..5a9dbcfb 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -522,108 +522,246 @@ class _SubCategorisePageState extends State { thickness: 1.0, color: Colors.grey.shade400, ), - styleOne == true - ? Container( - height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, - child: GridView.builder( - physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 0.9, - ), - itemCount: model.subProducts.length, - itemBuilder: (BuildContext context, int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model.subProducts[index].discountName != null - ? Color(0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - left: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - top: BorderSide( - color: Colors.grey.shade300, - width: 1, - ), - ), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(110.0), + model.subProducts.isNotEmpty + ? styleOne == true + ? Container( + height: model.subProducts.length * MediaQuery.of(context).size.height * 0.15, + child: GridView.builder( + physics: NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 0.9, + ), + itemCount: model.subProducts.length, + itemBuilder: (BuildContext context, int index) { + return NetworkBaseView( + baseViewModel: model, + child: InkWell( + child: Card( + color: model.subProducts[index].discountName != null + ? Color(0xffFFFF00) + : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), ), - color: Colors.white, - ), - padding: EdgeInsets.symmetric(horizontal: 0), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), + ), + color: Colors.white, + ), + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - margin: EdgeInsets.fromLTRB(0, 16, 0, 0), - alignment: Alignment.center, - child: Image.network( - 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, - ), + Stack( + children: [ + Container( + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, + child: Image.network( + 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)), + ), + child: Texts( + model.subProducts[index].rxMessage != null + ? model.subProducts[index].rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ), + ), + ], ), 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)), + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, ), - child: Texts( - model.subProducts[index].rxMessage != null - ? model.subProducts[index].rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + model.subProducts[index].name, + regular: true, + fontSize: 12, + fontWeight: FontWeight.w400, + ), + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 4), + child: Texts( + "SAR ${model.subProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ + StarRating( + totalAverage: + model.subProducts[index].approvedRatingSum > 0 + ? (model.subProducts[index].approvedRatingSum + .toDouble() / + model.subProducts[index] + .approvedRatingSum + .toDouble()) + .toDouble() + : 0, + forceStars: true), + Texts( + "(${model.subProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + ], + ), + ], ), ), ], ), + ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model.subProducts[index]), + )), + }, + )); + }, + ), + ) + : Container( + 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) { + return InkWell( + child: Card( + child: Row( + children: [ + Stack( + children: [ + Column( + children: [ + Container( + decoration: BoxDecoration(), + child: Padding( + padding: EdgeInsets.only( + left: 9.0, + top: 8.0, + right: 10.0, + ), + ), + ), + Container( + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, + child: Image.network( + 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.contain, + height: 80, + ), + ), + ], + ), + Column( + children: [ + 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)), + ), + child: Texts( + model.subProducts[index].rxMessage != null + ? model.subProducts[index].rxMessage + : "", + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + ], + ), Container( + height: 100.0, margin: EdgeInsets.symmetric( horizontal: 6, vertical: 0, ), child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - model.subProducts[index].name, - regular: true, - fontSize: 12, - fontWeight: FontWeight.w400, + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of(context).size.width * 0.65, + child: Texts( + model.subProducts[index].name, + regular: true, + fontSize: 13.2, + fontWeight: FontWeight.w500, + maxLines: 5, + ), + ), + SizedBox( + height: 8.0, ), Padding( padding: const EdgeInsets.only(top: 4, bottom: 4), @@ -659,147 +797,43 @@ class _SubCategorisePageState extends State { ], ), ), - ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage(model.subProducts[index]), - )), - }, - )); - }, - ), - ) - : Container( - 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) { - return InkWell( - child: Card( - child: Row( - children: [ - Stack( - children: [ - Column( - children: [ - Container( - decoration: BoxDecoration(), - child: Padding( - padding: EdgeInsets.only( - left: 9.0, - top: 8.0, - right: 10.0, - ), - ), - ), - Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, - child: Image.network( - 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.contain, - height: 80, - ), - ), - ], - ), - Column( - children: [ - 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)), - ), - child: Texts( - model.subProducts[index].rxMessage != null - ? model.subProducts[index].rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ), - ), - ], - ), - ], - ), - Container( - height: 100.0, - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 4.0, - ), - Container( - width: MediaQuery.of(context).size.width * 0.65, - child: Texts( - model.subProducts[index].name, - regular: true, - fontSize: 13.2, - fontWeight: FontWeight.w500, - maxLines: 5, - ), - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: const EdgeInsets.only(top: 4, bottom: 4), - child: Texts( - "SAR ${model.subProducts[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( - children: [ - StarRating( - totalAverage: model.subProducts[index].approvedRatingSum > 0 - ? (model.subProducts[index].approvedRatingSum.toDouble() / - model.subProducts[index].approvedRatingSum - .toDouble()) - .toDouble() - : 0, - forceStars: true), - Texts( - "(${model.subProducts[index].approvedTotalReviews})", - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) - ], - ), - ], - ), - ), - ], + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model.subProducts[index]), + )), + }, + ); + }), + ) + : Padding( + padding: const EdgeInsets.all(12.0), + child: Container( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage(model.subProducts[index]), - )), - }, - ); - }), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + 'There is no data', + style: TextStyle(fontSize: 30), + ), + ) + ], + ), + ), + ), ) ], ), From e4d54f0c0bb9ff2a1a1bb40e253abde1be10dd5d Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 22 Sep 2021 12:13:49 +0300 Subject: [PATCH 9/9] parent product and sub product update --- lib/pages/parent_categorise_page.dart | 323 ++++++++------------------ lib/pages/sub_categorise_page.dart | 316 ++++++++----------------- 2 files changed, 187 insertions(+), 452 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 99e671ab..40bf2dc7 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -26,8 +26,7 @@ class ParentCategorisePage extends StatefulWidget { ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => - _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { @@ -58,9 +57,7 @@ class _ParentCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), - builder: (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - PharmacyAppScaffold( + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( appBarTitle: titleName, isBottomBar: false, isShowAppBar: true, @@ -111,8 +108,7 @@ class _ParentCategorisePageState extends State { child: InkWell( child: Container( child: Texts( - TranslationBase.of(context) - .viewCategorise, + TranslationBase.of(context).viewCategorise, // 'View All Categories', fontWeight: FontWeight.w300, ), @@ -130,37 +126,22 @@ class _ParentCategorisePageState extends State { color: Colors.white, child: Center( child: ListView.builder( - scrollDirection: - Axis.vertical, - itemCount: model - .categoriseParent.length, - itemBuilder: - (BuildContext context, - int index) { + scrollDirection: Axis.vertical, + itemCount: model.categoriseParent.length, + itemBuilder: (BuildContext context, int index) { return Container( child: Padding( - padding: - EdgeInsets.all(4.0), + padding: EdgeInsets.all(4.0), child: InkWell( child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(projectViewModel - .isArabic - ? model - .categoriseParent[ - index] - .namen - : model - .categoriseParent[ - index] - .name), + Texts(projectViewModel.isArabic + ? model.categoriseParent[index].namen + : model.categoriseParent[index].name), Divider( thickness: 0.6, - color: Colors - .black12, + color: Colors.black12, ) ], ), @@ -168,16 +149,9 @@ class _ParentCategorisePageState extends State { Navigator.push( context, FadePage( - page: - SubCategorisePage( - title: model - .categoriseParent[ - index] - .name, - id: model - .categoriseParent[ - index] - .id, + page: SubCategorisePage( + title: model.categoriseParent[index].name, + id: model.categoriseParent[index].id, parentId: id, )), ); @@ -211,28 +185,22 @@ class _ParentCategorisePageState extends State { child: Center( child: ListView.builder( scrollDirection: Axis.horizontal, - itemCount: model.categoriseParent.length > 8 - ? 8 - : model.categoriseParent.length, + itemCount: model.categoriseParent.length > 8 ? 8 : model.categoriseParent.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( @@ -266,10 +234,8 @@ class _ParentCategorisePageState extends State { context, FadePage( page: SubCategorisePage( - title: model - .categoriseParent[index].name, - id: model - .categoriseParent[index].id, + title: model.categoriseParent[index].name, + id: model.categoriseParent[index].id, parentId: id, )), ); @@ -315,21 +281,16 @@ class _ParentCategorisePageState 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( @@ -340,8 +301,7 @@ class _ParentCategorisePageState extends State { ), Texts( 'Refine', - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, ), SizedBox( width: 250.0, @@ -350,13 +310,11 @@ class _ParentCategorisePageState extends State { child: Texts( 'Close', color: Colors.red, - fontWeight: - FontWeight.w600, + fontWeight: FontWeight.w600, fontSize: 15.0, ), onTap: () { - Navigator.pop( - context); + Navigator.pop(context); }, ), ], @@ -369,37 +327,27 @@ class _ParentCategorisePageState extends State { Column( children: [ ExpansionTile( - title: - Texts('Categorise'), + title: Texts('Categorise'), children: [ ProcedureListWidget( model: model, - masterList: model - .categoriseParent, - removeHistory: - (item) { + masterList: model.categoriseParent, + 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), ) ], ), @@ -412,33 +360,23 @@ class _ParentCategorisePageState extends State { 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), ) ], ), @@ -450,63 +388,40 @@ class _ParentCategorisePageState extends State { title: Texts('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( - 'Min'), + Texts('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( - 'Max'), + Texts('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, ), ), ], @@ -521,26 +436,18 @@ class _ParentCategorisePageState 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: [ Container( width: 100, child: Button( label: 'Reset', - backgroundColor: - Colors.red, + backgroundColor: Colors.red, ), ), SizedBox( @@ -549,65 +456,38 @@ class _ParentCategorisePageState 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 = - ""; + String brandIds = ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; + if (brandIds == "") { + brandIds = brand.id; } else { - brandIds = - "$brandIds,${brand.id}"; + brandIds = "$brandIds,${brand.id}"; } } - GifLoaderDialogUtils - .showMyDialog( - context); + GifLoaderDialogUtils.showMyDialog(context); await model.getFilteredProducts( - min: minField - .text - .toString(), - max: maxField - .text - .toString(), - categoryId: - categoriesId, - brandId: - brandIds); - GifLoaderDialogUtils - .hideDialog( - context); + min: minField.text.toString(), + max: maxField.text.toString(), + categoryId: categoriesId, + brandId: brandIds); + GifLoaderDialogUtils.hideDialog(context); - Navigator.pop( - context); + Navigator.pop(context); }, label: 'Apply', - backgroundColor: - Colors - .green, + backgroundColor: Colors.green, ), ), ], @@ -808,13 +688,9 @@ class _ParentCategorisePageState extends State { ), ), Texts( - projectViewModel - .isArabic - ? model - .parentProducts[ - index] - .namen - :model.parentProducts[index].name, + projectViewModel.isArabic + ? model.parentProducts[index].namen + : model.parentProducts[index].name, regular: true, fontSize: 12, fontWeight: FontWeight.w700, @@ -946,13 +822,8 @@ class _ParentCategorisePageState extends State { width: MediaQuery.of(context).size.width * 0.65, child: Texts( projectViewModel.isArabic - ? model - .parentProducts[ - index] - .namen - : model - .parentProducts[ - index].name, + ? model.parentProducts[index].namen + : model.parentProducts[index].name, regular: true, fontSize: 13.2, fontWeight: FontWeight.w500, @@ -973,8 +844,8 @@ class _ParentCategorisePageState extends State { Row( children: [ StarRating( - totalAverage:model - .parentProducts[index].approvedRatingSum > 0 + totalAverage: + model.parentProducts[index].approvedRatingSum > 0 ? (model.parentProducts[index].approvedRatingSum .toDouble() / model.parentProducts[index] @@ -1043,8 +914,7 @@ class _ParentCategorisePageState 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; } @@ -1052,8 +922,7 @@ class _ParentCategorisePageState 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/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 8c3b42ad..45617072 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -23,8 +23,7 @@ class SubCategorisePage extends StatefulWidget { 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 { @@ -52,9 +51,7 @@ class _SubCategorisePageState extends State { TextEditingController maxField = TextEditingController(); return BaseView( 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, @@ -86,8 +83,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, @@ -99,14 +95,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) @@ -118,30 +112,21 @@ 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(model - .subCategorise[ - index] - .name), + Texts(model.subCategorise[index].name), Divider( thickness: 0.6, color: Colors.black12, @@ -152,12 +137,8 @@ class _SubCategorisePageState extends State { Navigator.push( context, FadePage( - page: - FinalProductsPage( - id: model - .subCategorise[ - index] - .id, + page: FinalProductsPage( + id: model.subCategorise[index].id, ), ), ); @@ -190,23 +171,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( @@ -217,14 +194,8 @@ 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( model.subCategorise[index].name, @@ -285,21 +256,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( @@ -309,30 +275,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); }, ), ], @@ -345,39 +304,27 @@ 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), ) ], ), @@ -386,40 +333,27 @@ 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), ) ], ), @@ -428,69 +362,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( - 'Min'), + Texts('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( - 'Max'), + Texts('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, ), ), ], @@ -505,31 +413,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, ), ), ), @@ -539,66 +436,37 @@ 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 = - ""; + String brandIds = ""; for (CategoriseParentModel brand in entityListBrands) { - if (brandIds == - "") { - brandIds = - brand - .id; + 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, ), ), ], @@ -983,8 +851,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; } @@ -992,8 +859,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; }