fixed issues

merge-update-with-lab-changes
Fatimah Alshammari 4 years ago
parent 444bc7383d
commit c4e185ea60

@ -630,6 +630,16 @@ const Map localizedValues = {
"years-old": {"en": "years old", "ar": "سنة"}, "years-old": {"en": "years old", "ar": "سنة"},
"drag-point": {"en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك"}, "drag-point": {"en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك"},
"refine": {"en": "Refine", "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": "اعادة تعيين"}, "reset": {"en": "Reset", "ar": "اعادة تعيين"},
"apply": {"en": "Apply", "ar": "تطبيق"}, "apply": {"en": "Apply", "ar": "تطبيق"},
"viewCategorise": {"en": "View All Categories", "ar": "عرض جميع الفئات"}, "viewCategorise": {"en": "View All Categories", "ar": "عرض جميع الفئات"},

@ -55,10 +55,10 @@ class ProductDetailViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future notifyMe(customerId, itemID) async { Future notifyMe(customerId, itemID, context) async {
hasError = false; hasError = false;
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await _productDetailService.notifyMe(customerId, itemID); await _productDetailService.notifyMe(customerId, itemID, context);
if (_productDetailService.hasError) { if (_productDetailService.hasError) {
error = _productDetailService.error; error = _productDetailService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
@ -66,10 +66,10 @@ class ProductDetailViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future addToCartData(quantity, itemID) async { Future addToCartData(quantity, itemID, context) async {
hasError = false; hasError = false;
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
var resp = await _productDetailService.addToCart(quantity, itemID); var resp = await _productDetailService.addToCart(quantity, itemID, context);
ShoppingCartResponse object = _handleGetShoppingCartResponse(resp); ShoppingCartResponse object = _handleGetShoppingCartResponse(resp);
if (_productDetailService.hasError) { if (_productDetailService.hasError) {
error = _productDetailService.error; error = _productDetailService.error;
@ -103,11 +103,11 @@ class ProductDetailViewModel extends BaseViewModel {
return cartResponse; return cartResponse;
} }
Future addToWishlistData(itemID) async { Future addToWishlistData(itemID, context) async {
hasError = false; hasError = false;
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
GifLoaderDialogUtils.showMyDialog(locator<NavigationService>().navigatorKey.currentContext); GifLoaderDialogUtils.showMyDialog(locator<NavigationService>().navigatorKey.currentContext);
await _productDetailService.addToWishlist(itemID); await _productDetailService.addToWishlist(itemID, context);
GifLoaderDialogUtils.hideDialog(locator<NavigationService>().navigatorKey.currentContext); GifLoaderDialogUtils.hideDialog(locator<NavigationService>().navigatorKey.currentContext);
if (_productDetailService.hasError) { if (_productDetailService.hasError) {
@ -128,11 +128,11 @@ class ProductDetailViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future deleteWishlistData(itemID) async { Future deleteWishlistData(itemID, context) async {
hasError = false; hasError = false;
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
GifLoaderDialogUtils.showMyDialog(locator<NavigationService>().navigatorKey.currentContext); GifLoaderDialogUtils.showMyDialog(locator<NavigationService>().navigatorKey.currentContext);
await _productDetailService.deleteItemFromWishlist(itemID); await _productDetailService.deleteItemFromWishlist(itemID, context);
GifLoaderDialogUtils.hideDialog(locator<NavigationService>().navigatorKey.currentContext); GifLoaderDialogUtils.hideDialog(locator<NavigationService>().navigatorKey.currentContext);
if (_productDetailService.hasError) { if (_productDetailService.hasError) {

@ -530,6 +530,6 @@ class _FinalProductsPageState extends State<FinalProductsPage> {
addToCartFunction(quantity, itemID) async { addToCartFunction(quantity, itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel x = new ProductDetailViewModel();
await x.addToCartData(quantity, itemID); await x.addToCartData(quantity, itemID, context);
} }
} }

@ -368,7 +368,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Column( Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Texts('Min'), Texts(TranslationBase.of(context).min),
Container( Container(
color: Colors.white, color: Colors.white,
width: 200, width: 200,
@ -385,7 +385,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
Column( Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Texts('Max'), Texts(TranslationBase.of(context).max),
Container( Container(
color: Colors.white, color: Colors.white,
width: 200, width: 200,
@ -588,7 +588,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
bottom: 5.0, bottom: 5.0,
), ),
child: Texts( child: Texts(
'offer'.toUpperCase(), TranslationBase.of(context).offers.toUpperCase(),
color: Colors.red, color: Colors.red,
fontSize: 13.0, fontSize: 13.0,
fontWeight: FontWeight.w900, fontWeight: FontWeight.w900,
@ -876,8 +876,8 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
), ),
Padding( Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Text( child: Text(TranslationBase.of(context).noData,
'There is no data', // 'There is no data',
style: TextStyle(fontSize: 30), style: TextStyle(fontSize: 30),
), ),
) )
@ -895,7 +895,7 @@ class _ParentCategorisePageState extends State<ParentCategorisePage> {
addToCartFunction(quantity, itemID) async { addToCartFunction(quantity, itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel x = new ProductDetailViewModel();
await x.addToCartData(quantity, itemID); await x.addToCartData(quantity, itemID, context);
} }
bool isEntityListSelected(CategoriseParentModel masterKey) { bool isEntityListSelected(CategoriseParentModel masterKey) {

@ -48,7 +48,7 @@ class _ProductCheckTypeWidgetState extends State<ProductCheckTypeWidget> {
deleteWishListItem(itemID) async { deleteWishListItem(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel x = new ProductDetailViewModel();
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await x.deleteWishlistData(itemID); await x.deleteWishlistData(itemID, context);
await widget.model.getWishlistData(isLocalLoader: true); await widget.model.getWishlistData(isLocalLoader: true);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} }

@ -1,5 +1,6 @@
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class CompareList with ChangeNotifier { class CompareList with ChangeNotifier {
@ -7,20 +8,28 @@ class CompareList with ChangeNotifier {
List<PharmacyProduct> get productListItems => _product; List<PharmacyProduct> get productListItems => _product;
void addItem(data) { void addItem(data, context) {
if (_product.length == 0) { if (_product.length == 0) {
_product.add(data); _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 { } else {
for (int i = 0; i < _product.length; i++) { for (int i = 0; i < _product.length; i++) {
if (_product.length <= 4 && _product[i].id != data.id) { if (_product.length <= 4 && _product[i].id != data.id) {
_product.add(data); _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; break;
} else if(_product[i].id == data.id){ } 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){ } 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'
);
} }
} }
} }

@ -328,19 +328,19 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await model.addToCartData(quantity, itemID); await model.addToCartData(quantity, itemID, context);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} }
addToWishlistFunction({itemID, ProductDetailViewModel model}) async { addToWishlistFunction({itemID, ProductDetailViewModel model}) async {
isInWishList = true; isInWishList = true;
await model.addToWishlistData(itemID); await model.addToWishlistData(itemID, context);
setState(() {}); setState(() {});
} }
deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async {
isInWishList = false; isInWishList = false;
await model.deleteWishlistData(itemID); await model.deleteWishlistData(itemID, context);
setState(() {}); setState(() {});
} }
@ -350,11 +350,11 @@ class __ProductDetailPageState extends State<ProductDetailPage> {
ProductDetailViewModel model, ProductDetailViewModel model,
}) async { }) async {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await model.addToCartData(quantity, itemID); await model.addToCartData(quantity, itemID, context);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} }
} }
notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model, context}) async {
await model.notifyMe(customerId, itemId); await model.notifyMe(customerId, itemId, context);
} }

@ -128,11 +128,11 @@ class _ProductNameAndPriceState extends State<ProductNameAndPrice> {
SizedBox( SizedBox(
width: 10, width: 10,
), ),
Texts( // Texts(
"${widget.item.approvedRatingSum}", // "${widget.item.approvedRatingSum}",
fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
fontSize: 12, // fontSize: 12,
), // ),
SizedBox( SizedBox(
width: 30, width: 30,
), ),

@ -157,7 +157,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} else { } else {
AppToast.showErrorToast(message: "you should add quantity"); AppToast.showErrorToast(message: TranslationBase.of(context).addQuantity
// "you should add quantity"
);
} }
}), }),
ListTile( ListTile(
@ -184,7 +186,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
), ),
onTap: () { onTap: () {
Provider.of<CompareList>(context, listen: false) Provider.of<CompareList>(context, listen: false)
.addItem(specificationData); .addItem(specificationData,context);
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
), ),

@ -534,13 +534,13 @@ class _RecommendedProductPageState extends State<RecommendedProductPage>
addToWishlistFunction(itemID) async { addToWishlistFunction(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel x = new ProductDetailViewModel();
isInWishlist = true; isInWishlist = true;
await x.addToWishlistData(itemID); await x.addToWishlistData(itemID, context);
} }
deleteFromWishlistFunction(itemID) async { deleteFromWishlistFunction(itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel x = new ProductDetailViewModel();
isInWishlist = false; isInWishlist = false;
await x.addToWishlistData(itemID); await x.addToWishlistData(itemID, context);
} }
} }

@ -213,8 +213,8 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
height: MediaQuery.of(context).size.height * 0.10, height: MediaQuery.of(context).size.height * 0.10,
child: Center( child: Center(
child: Texts( child: Texts(
//projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name,
model.subCategorise[index].name, // model.subCategorise[index].name,
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
maxLines: 2, maxLines: 2,
@ -386,7 +386,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Column( Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Texts('Min'), Texts(TranslationBase.of(context).min),
Container( Container(
color: Colors.white, color: Colors.white,
width: 200, width: 200,
@ -403,7 +403,7 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
Column( Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Texts('Max'), Texts(TranslationBase.of(context).max),
Container( Container(
color: Colors.white, color: Colors.white,
width: 200, width: 200,
@ -897,6 +897,6 @@ class _SubCategorisePageState extends State<SubCategorisePage> {
addToCartFunction(quantity, itemID) async { addToCartFunction(quantity, itemID) async {
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel x = new ProductDetailViewModel();
await x.addToCartData(quantity, itemID); await x.addToCartData(quantity, itemID, context);
} }
} }

@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart';
import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart';
import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart';
class ProductDetailService extends BaseService { class ProductDetailService extends BaseService {
@ -91,7 +92,7 @@ class ProductDetailService extends BaseService {
}, body: request); }, body: request);
} }
Future<Map> addToCart(quantity, itemID) async { Future<Map> addToCart(quantity, itemID, context) async {
var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
hasError = false; hasError = false;
Map<String, dynamic> request; Map<String, dynamic> request;
@ -106,7 +107,9 @@ class ProductDetailService extends BaseService {
response['shopping_carts'].forEach((item) { response['shopping_carts'].forEach((item) {
_addToCartModel.add(Wishlist.fromJson(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; localRes = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
@ -117,10 +120,12 @@ class ProductDetailService extends BaseService {
return Future.value(localRes); return Future.value(localRes);
} }
Future notifyMe(customerId, itemID) async { Future notifyMe(customerId, itemID, context) async {
hasError = false; hasError = false;
await baseAppClient.getPharmacy(SUBSCRIBE_PRODUCT + "SinceId=$customerId&ProductId=$itemID", onSuccess: (dynamic response, int statusCode) { 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) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; 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); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
hasError = false; hasError = false;
Map<String, dynamic> request; Map<String, dynamic> request;
@ -141,7 +146,9 @@ class ProductDetailService extends BaseService {
response['shopping_carts'].forEach((item) { response['shopping_carts'].forEach((item) {
_wishListProducts.add(Wishlist.fromJson(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) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; 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); var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
hasError = false; hasError = false;
await baseAppClient.getPharmacy(DELETE_WISHLIST + customerId + "+&product_id=" + itemID + "&cart_type=Wishlist", onSuccess: (dynamic response, int statusCode) { 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) { response['shopping_carts'].forEach((item) {
_wishListProducts.add(Wishlist.fromJson(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) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;

@ -1206,6 +1206,26 @@ class TranslationBase {
String get refine => localizedValues['refine'][locale.languageCode]; 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 apply => localizedValues['apply'][locale.languageCode];
String get reset => localizedValues['reset'][locale.languageCode]; String get reset => localizedValues['reset'][locale.languageCode];

@ -295,6 +295,6 @@ class productTile extends StatelessWidget {
addToCartFunction(quantity, itemID, BuildContext context) async { addToCartFunction(quantity, itemID, BuildContext context) async {
ProductDetailViewModel x = new ProductDetailViewModel(); ProductDetailViewModel x = new ProductDetailViewModel();
await x.addToCartData(quantity, itemID); await x.addToCartData(quantity, itemID, context);
} }
} }

Loading…
Cancel
Save