|
|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/locator.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
|
@ -24,6 +26,9 @@ class RecommendedProducts extends StatefulWidget {
|
|
|
|
|
final Function addToWishlistFunction;
|
|
|
|
|
final Function deleteFromWishlistFunction;
|
|
|
|
|
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject =
|
|
|
|
|
locator<AuthenticatedUserObject>();
|
|
|
|
|
|
|
|
|
|
RecommendedProducts(
|
|
|
|
|
{Key key,
|
|
|
|
|
this.product,
|
|
|
|
|
@ -134,63 +139,27 @@ class _RecommendedProductsState extends State<RecommendedProducts> {
|
|
|
|
|
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 (widget.customerId != null) {
|
|
|
|
|
if (!widget.isInWishList &&
|
|
|
|
|
model
|
|
|
|
|
.recommendedProductList[
|
|
|
|
|
index]
|
|
|
|
|
.isinwishlist !=
|
|
|
|
|
true) {
|
|
|
|
|
GifLoaderDialogUtils
|
|
|
|
|
.showMyDialog(context);
|
|
|
|
|
await widget.addToWishlistFunction(
|
|
|
|
|
itemID: model
|
|
|
|
|
.recommendedProductList[
|
|
|
|
|
index]
|
|
|
|
|
.id,
|
|
|
|
|
model: widget
|
|
|
|
|
.productDetailViewModel);
|
|
|
|
|
// checkWishlist();
|
|
|
|
|
GifLoaderDialogUtils
|
|
|
|
|
.hideDialog(context);
|
|
|
|
|
if (widget.authenticatedUserObject.isLogin
|
|
|
|
|
) {
|
|
|
|
|
if (!widget.isInWishList && model.recommendedProductList[index].isinwishlist != true) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await widget.addToWishlistFunction(model.recommendedProductList[index].id,
|
|
|
|
|
);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
setState(() {
|
|
|
|
|
model
|
|
|
|
|
.recommendedProductList[
|
|
|
|
|
index]
|
|
|
|
|
.isinwishlist = true;
|
|
|
|
|
});
|
|
|
|
|
model.recommendedProductList[index].isinwishlist = true;});
|
|
|
|
|
} else {
|
|
|
|
|
GifLoaderDialogUtils
|
|
|
|
|
.showMyDialog(context);
|
|
|
|
|
await widget.deleteFromWishlistFunction(
|
|
|
|
|
itemID: model
|
|
|
|
|
.recommendedProductList[
|
|
|
|
|
index]
|
|
|
|
|
.id,
|
|
|
|
|
model: widget
|
|
|
|
|
.productDetailViewModel);
|
|
|
|
|
GifLoaderDialogUtils
|
|
|
|
|
.hideDialog(context);
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await widget.deleteFromWishlistFunction(model.recommendedProductList[index].id,
|
|
|
|
|
);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
setState(() {
|
|
|
|
|
model
|
|
|
|
|
.recommendedProductList[
|
|
|
|
|
index]
|
|
|
|
|
.isinwishlist = false;
|
|
|
|
|
model.recommendedProductList[index].isinwishlist = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|