merge-requests/420/head
Elham Rababh 5 years ago
parent 145117aa63
commit b0b278a7e3

@ -97,12 +97,12 @@ class ProductDetailViewModel extends BaseViewModel{
} }
Future deletWishlistData(itemID) async { Future deleteWishlistData(itemID) async {
hasError = false; hasError = false;
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
GifLoaderDialogUtils.showMyDialog( GifLoaderDialogUtils.showMyDialog(
locator<NavigationService>().navigatorKey.currentContext); locator<NavigationService>().navigatorKey.currentContext);
await _productDetailService.delteItemFromWishlist(itemID); await _productDetailService.deleteItemFromWishlist(itemID);
GifLoaderDialogUtils.hideDialog( GifLoaderDialogUtils.hideDialog(
locator<NavigationService>().navigatorKey.currentContext); locator<NavigationService>().navigatorKey.currentContext);
@ -125,4 +125,10 @@ class ProductDetailViewModel extends BaseViewModel{
setState(ViewState.Idle); setState(ViewState.Idle);
} }
clearReview(){
productDetailService.clear();
}
} }

@ -87,7 +87,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.deletWishlistData(itemID); await x.deleteWishlistData(itemID);
setState(() setState(()
async{ async{
await await

@ -98,8 +98,8 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
product: widget.product, product: widget.product,
quantity: quantity, quantity: quantity,
model: model, model: model,
addToWishlistFunction: (item) { addToWishlistFunction: () {
addToWishlistFunction(itemID:item,model:model); addToWishlistFunction(itemID:itemID,model:model);
setState(() {}); setState(() {});
}, },
), ),
@ -221,6 +221,8 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
await model.getProductReviewsData( await model.getProductReviewsData(
widget.product.id); widget.product.id);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
} else {
model.clearReview();
} }
setState(() { setState(() {
isDetails = false; isDetails = false;
@ -324,7 +326,7 @@ class __ProductDetailPageState extends State<ProductDetailPage>{
deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async {
isInWishList = false; isInWishList = false;
await model.deletWishlistData(itemID); await model.deleteWishlistData(itemID);
} }
} }

@ -8,7 +8,8 @@ class ReviewsInfo extends StatelessWidget {
final PharmacyProduct product; final PharmacyProduct product;
final ProductDetailViewModel previousModel; final ProductDetailViewModel previousModel;
const ReviewsInfo({Key key, this.product, this.previousModel}) : super(key: key); const ReviewsInfo({Key key, this.product, this.previousModel})
: super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -31,8 +32,8 @@ class ReviewsInfo extends StatelessWidget {
children: [ children: [
Container( Container(
child: Text( child: Text(
previousModel.productDetailService[0].reviews[index] previousModel.productDetailService[0]
.customerId .reviews[index].customerId
.toString(), .toString(),
style: TextStyle( style: TextStyle(
fontSize: 17, fontSize: 17,
@ -43,8 +44,8 @@ class ReviewsInfo extends StatelessWidget {
Container( Container(
margin: EdgeInsets.only(left: 210), margin: EdgeInsets.only(left: 210),
child: RatingBar.readOnly( child: RatingBar.readOnly(
initialRating: previousModel.productDetailService[0] initialRating: previousModel
.reviews[index].rating .productDetailService[0].reviews[index].rating
.toDouble(), .toDouble(),
size: 15.0, size: 15.0,
filledColor: Colors.yellow[700], filledColor: Colors.yellow[700],
@ -63,8 +64,8 @@ class ReviewsInfo extends StatelessWidget {
), ),
Container( Container(
child: Text( child: Text(
previousModel.productDetailService[0].reviews[index] previousModel
.reviewText, .productDetailService[0].reviews[index].reviewText,
style: TextStyle(fontSize: 20), style: TextStyle(fontSize: 20),
), ),
), ),

@ -127,8 +127,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget {
TranslationBase.of(context).addToWishlist, TranslationBase.of(context).addToWishlist,
), ),
onTap: () { onTap: () {
addToWishlistFunction(itemID: itemID, model: model); addToWishlistFunction();
}, }
), ),
ListTile( ListTile(
leading: Icon(Icons.compare), leading: Icon(Icons.compare),

@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
class ProductDetailService extends BaseService { class ProductDetailService extends BaseService {
bool isLogin = false; bool isLogin = false;
@ -98,7 +99,7 @@ class ProductDetailService extends BaseService {
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
AppToast.showErrorToast(message: super.error??'something went wrong please try again'); AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage());
}, body: request); }, body: request);
} }
@ -109,7 +110,7 @@ class ProductDetailService extends BaseService {
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
AppToast.showErrorToast(message: 'something went wrong please try again'); AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage());
}); });
} }
@ -126,12 +127,13 @@ class ProductDetailService extends BaseService {
_wishListProducts.clear(); _wishListProducts.clear();
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: '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;
AppToast.showErrorToast(message: 'something went wrong please try again'); AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage());
}, body: request); }, body: request);
} }
@ -149,7 +151,7 @@ class ProductDetailService extends BaseService {
super.error = error; super.error = error;
}); });
} }
Future delteItemFromWishlist(itemID) async { Future deleteItemFromWishlist(itemID) 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", await baseAppClient.getPharmacy(DELETE_WISHLIST+customerId+"+&product_id="+itemID+"&cart_type=Wishlist",

Loading…
Cancel
Save