From c4e185ea60003f35265b64ead1e1fcb9f6fe8457 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 10 Nov 2021 09:40:12 +0300 Subject: [PATCH] fixed issues --- lib/config/localized_values.dart | 10 ++++++++ .../product_detail_view_model.dart | 16 ++++++------ lib/pages/final_products_page.dart | 2 +- lib/pages/parent_categorise_page.dart | 12 ++++----- .../pharmacies/ProductCheckTypeWidget.dart | 2 +- lib/pages/pharmacies/compare-list.dart | 19 ++++++++++---- .../product-details/product-detail.dart | 12 ++++----- .../product-name-and-price.dart | 10 ++++---- .../shared/product_details_app_bar.dart | 6 +++-- .../screens/recommended-product-page.dart | 4 +-- lib/pages/sub_categorise_page.dart | 10 ++++---- .../product_detail_service.dart | 25 +++++++++++++------ lib/uitl/translations_delegate_base.dart | 20 +++++++++++++++ lib/widgets/pharmacy/product_tile.dart | 2 +- 14 files changed, 100 insertions(+), 50 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 4a8ee340..7be2decb 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -630,6 +630,16 @@ const Map localizedValues = { "years-old": {"en": "years old", "ar": "سنة"}, "drag-point": {"en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك"}, "refine": {"en": "Refine", "ar": "تصفية"}, + "max": {"en": "Max", "ar": "اعلى"}, + "addToCompareMsg": {"en": "You have added a product to the Compare list", "ar": "تمت الاضافه لقائمة المقارنه"}, + "itInListMsg": {"en": "Item is already in the list", "ar": "المنتج موجود في القائمه"}, + "compareListFull": {"en": "Your compare list is full", "ar": "قائمة المقارنة ممتلئه"}, + "addQuantity": {"en": "You should add quantity", "ar": "اختر الكمية"}, + "addToCartMsg": {"en": "You have added a product to the cart", "ar": "تمت اضافة المنتج بنجاح"}, + "addToWishlistMsg": {"en": "You have added a product to the Wishlist", "ar": "تمت الاضافة لقائمة الرغبات"}, + "notifyMeMsg": {"en": "You will be notified when product available", "ar": "سيتم اخبارك في حال توفر المنتج"}, + "removeFromWishlistMsg": {"en": "You have removed a product from the Wishlist", "ar": "تمت ازالة المنتج بنجاح"}, + "min": {"en": "Min", "ar": "اقل"}, "reset": {"en": "Reset", "ar": "اعادة تعيين"}, "apply": {"en": "Apply", "ar": "تطبيق"}, "viewCategorise": {"en": "View All Categories", "ar": "عرض جميع الفئات"}, diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 2ae935dd..6eb1f4b9 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -55,10 +55,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future notifyMe(customerId, itemID) async { + Future notifyMe(customerId, itemID, context) async { hasError = false; setState(ViewState.BusyLocal); - await _productDetailService.notifyMe(customerId, itemID); + await _productDetailService.notifyMe(customerId, itemID, context); if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); @@ -66,10 +66,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future addToCartData(quantity, itemID) async { + Future addToCartData(quantity, itemID, context) async { hasError = false; setState(ViewState.BusyLocal); - var resp = await _productDetailService.addToCart(quantity, itemID); + var resp = await _productDetailService.addToCart(quantity, itemID, context); ShoppingCartResponse object = _handleGetShoppingCartResponse(resp); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -103,11 +103,11 @@ class ProductDetailViewModel extends BaseViewModel { return cartResponse; } - Future addToWishlistData(itemID) async { + Future addToWishlistData(itemID, context) async { hasError = false; setState(ViewState.BusyLocal); GifLoaderDialogUtils.showMyDialog(locator().navigatorKey.currentContext); - await _productDetailService.addToWishlist(itemID); + await _productDetailService.addToWishlist(itemID, context); GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext); if (_productDetailService.hasError) { @@ -128,11 +128,11 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future deleteWishlistData(itemID) async { + Future deleteWishlistData(itemID, context) async { hasError = false; setState(ViewState.BusyLocal); GifLoaderDialogUtils.showMyDialog(locator().navigatorKey.currentContext); - await _productDetailService.deleteItemFromWishlist(itemID); + await _productDetailService.deleteItemFromWishlist(itemID, context); GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext); if (_productDetailService.hasError) { diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 63e684fe..519c8c4d 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -530,6 +530,6 @@ class _FinalProductsPageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index ecf33158..1c52b7a5 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -368,7 +368,7 @@ class _ParentCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Min'), + Texts(TranslationBase.of(context).min), Container( color: Colors.white, width: 200, @@ -385,7 +385,7 @@ class _ParentCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Max'), + Texts(TranslationBase.of(context).max), Container( color: Colors.white, width: 200, @@ -588,7 +588,7 @@ class _ParentCategorisePageState extends State { bottom: 5.0, ), child: Texts( - 'offer'.toUpperCase(), + TranslationBase.of(context).offers.toUpperCase(), color: Colors.red, fontSize: 13.0, fontWeight: FontWeight.w900, @@ -876,8 +876,8 @@ class _ParentCategorisePageState extends State { ), 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), ), ) @@ -895,7 +895,7 @@ class _ParentCategorisePageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } bool isEntityListSelected(CategoriseParentModel masterKey) { diff --git a/lib/pages/pharmacies/ProductCheckTypeWidget.dart b/lib/pages/pharmacies/ProductCheckTypeWidget.dart index 2b88d30a..46c5e7a3 100644 --- a/lib/pages/pharmacies/ProductCheckTypeWidget.dart +++ b/lib/pages/pharmacies/ProductCheckTypeWidget.dart @@ -48,7 +48,7 @@ class _ProductCheckTypeWidgetState extends State { deleteWishListItem(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); GifLoaderDialogUtils.showMyDialog(context); - await x.deleteWishlistData(itemID); + await x.deleteWishlistData(itemID, context); await widget.model.getWishlistData(isLocalLoader: true); GifLoaderDialogUtils.hideDialog(context); } diff --git a/lib/pages/pharmacies/compare-list.dart b/lib/pages/pharmacies/compare-list.dart index c4da5ba2..afa5382f 100644 --- a/lib/pages/pharmacies/compare-list.dart +++ b/lib/pages/pharmacies/compare-list.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; class CompareList with ChangeNotifier { @@ -7,20 +8,28 @@ class CompareList with ChangeNotifier { List get productListItems => _product; - void addItem(data) { + void addItem(data, context) { if (_product.length == 0) { _product.add(data); - AppToast.showSuccessToast(message: 'You have added a product to the Compare list'); + AppToast.showSuccessToast(message:TranslationBase.of(context).addToCompareMsg + // 'You have added a product to the Compare list' + ); } else { for (int i = 0; i < _product.length; i++) { if (_product.length <= 4 && _product[i].id != data.id) { _product.add(data); - AppToast.showSuccessToast(message: 'You have added a product to the Compare list'); + AppToast.showSuccessToast(message:TranslationBase.of(context).addToCompareMsg + // 'You have added a product to the Compare list' + ); break; } else if(_product[i].id == data.id){ - AppToast.showErrorToast(message: 'the item is already in the list'); + AppToast.showErrorToast(message:TranslationBase.of(context).itInListMsg + // 'the item is already in the list' + ); } else if(_product.length == 4){ - AppToast.showErrorToast(message: 'your compare list is full'); + AppToast.showErrorToast(message: TranslationBase.of(context).compareListFull + // 'your compare list is full' + ); } } } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 2676280f..3c44463e 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -328,19 +328,19 @@ class __ProductDetailPageState extends State { addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); + await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = true; - await model.addToWishlistData(itemID); + await model.addToWishlistData(itemID, context); setState(() {}); } deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = false; - await model.deleteWishlistData(itemID); + await model.deleteWishlistData(itemID, context); setState(() {}); } @@ -350,11 +350,11 @@ class __ProductDetailPageState extends State { ProductDetailViewModel model, }) async { GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); + await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); } } -notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { - await model.notifyMe(customerId, itemId); +notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model, context}) async { + await model.notifyMe(customerId, itemId, context); } diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index e214d70e..a70d9fc2 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -128,11 +128,11 @@ class _ProductNameAndPriceState extends State { SizedBox( width: 10, ), - Texts( - "${widget.item.approvedRatingSum}", - fontWeight: FontWeight.bold, - fontSize: 12, - ), +// Texts( +// "${widget.item.approvedRatingSum}", +// fontWeight: FontWeight.bold, +// fontSize: 12, +// ), SizedBox( width: 30, ), diff --git a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart index 1626e24f..944e065c 100644 --- a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart @@ -157,7 +157,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { Navigator.of(context).pop(); } } else { - AppToast.showErrorToast(message: "you should add quantity"); + AppToast.showErrorToast(message: TranslationBase.of(context).addQuantity + // "you should add quantity" + ); } }), ListTile( @@ -184,7 +186,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { ), onTap: () { Provider.of(context, listen: false) - .addItem(specificationData); + .addItem(specificationData,context); Navigator.of(context).pop(); }, ), diff --git a/lib/pages/pharmacies/screens/recommended-product-page.dart b/lib/pages/pharmacies/screens/recommended-product-page.dart index 4ea089fa..b04201e5 100644 --- a/lib/pages/pharmacies/screens/recommended-product-page.dart +++ b/lib/pages/pharmacies/screens/recommended-product-page.dart @@ -534,13 +534,13 @@ class _RecommendedProductPageState extends State addToWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlist = true; - await x.addToWishlistData(itemID); + await x.addToWishlistData(itemID, context); } deleteFromWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlist = false; - await x.addToWishlistData(itemID); + await x.addToWishlistData(itemID, context); } } diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 22b9151d..01b061b6 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -213,8 +213,8 @@ class _SubCategorisePageState extends State { height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( - //projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, - model.subCategorise[index].name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, + // model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, maxLines: 2, @@ -386,7 +386,7 @@ class _SubCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Min'), + Texts(TranslationBase.of(context).min), Container( color: Colors.white, width: 200, @@ -403,7 +403,7 @@ class _SubCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Max'), + Texts(TranslationBase.of(context).max), Container( color: Colors.white, width: 200, @@ -897,6 +897,6 @@ class _SubCategorisePageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } } diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 795530ff..7a50a37c 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; class ProductDetailService extends BaseService { @@ -91,7 +92,7 @@ class ProductDetailService extends BaseService { }, body: request); } - Future addToCart(quantity, itemID) async { + Future addToCart(quantity, itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; Map request; @@ -106,7 +107,9 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _addToCartModel.add(Wishlist.fromJson(item)); }); - AppToast.showSuccessToast(message: 'You have added a product to the cart'); + AppToast.showSuccessToast(message: TranslationBase.of(context).addToCartMsg + // 'You have added a product to the cart' + ); localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -117,10 +120,12 @@ class ProductDetailService extends BaseService { return Future.value(localRes); } - Future notifyMe(customerId, itemID) async { + Future notifyMe(customerId, itemID, context) async { hasError = false; await baseAppClient.getPharmacy(SUBSCRIBE_PRODUCT + "SinceId=$customerId&ProductId=$itemID", onSuccess: (dynamic response, int statusCode) { - AppToast.showSuccessToast(message: 'You will be notified when product available'); + AppToast.showSuccessToast(message: TranslationBase.of(context).notifyMeMsg + //'You will be notified when product available' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -128,7 +133,7 @@ class ProductDetailService extends BaseService { }); } - Future addToWishlist(itemID) async { + Future addToWishlist(itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; Map request; @@ -141,7 +146,9 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); }); - AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); + AppToast.showSuccessToast(message: TranslationBase.of(context).addToWishlistMsg + // 'You have added a product to the Wishlist' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -163,7 +170,7 @@ class ProductDetailService extends BaseService { }); } - Future deleteItemFromWishlist(itemID) async { + Future deleteItemFromWishlist(itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; await baseAppClient.getPharmacy(DELETE_WISHLIST + customerId + "+&product_id=" + itemID + "&cart_type=Wishlist", onSuccess: (dynamic response, int statusCode) { @@ -171,7 +178,9 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); }); - AppToast.showSuccessToast(message: 'You have removed a product from the Wishlist'); + AppToast.showSuccessToast(message: TranslationBase.of(context).removeFromWishlistMsg + // 'You have removed a product from the Wishlist' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index d1bc500d..63d1719f 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1206,6 +1206,26 @@ class TranslationBase { String get refine => localizedValues['refine'][locale.languageCode]; + String get max => localizedValues['max'][locale.languageCode]; + + String get min => localizedValues['min'][locale.languageCode]; + + String get addToCompareMsg => localizedValues['addToCompareMsg'][locale.languageCode]; + + String get itInListMsg => localizedValues['itInListMsg'][locale.languageCode]; + + String get compareListFull => localizedValues['compareListFull'][locale.languageCode]; + + String get addQuantity => localizedValues['addQuantity'][locale.languageCode]; + + String get addToCartMsg => localizedValues['addToCartMsg'][locale.languageCode]; + + String get addToWishlistMsg => localizedValues['addToWishlistMsg'][locale.languageCode]; + + String get notifyMeMsg => localizedValues['notifyMeMsg'][locale.languageCode]; + + String get removeFromWishlistMsg => localizedValues['removeFromWishlistMsg'][locale.languageCode]; + String get apply => localizedValues['apply'][locale.languageCode]; String get reset => localizedValues['reset'][locale.languageCode]; diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index c63410ba..70a727bf 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -295,6 +295,6 @@ class productTile extends StatelessWidget { addToCartFunction(quantity, itemID, BuildContext context) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } }