|
|
|
|
@ -1,113 +1,58 @@
|
|
|
|
|
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/core/viewModels/pharmacyModule/wishlist_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.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;
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class ProductCheckTypeWidget extends StatefulWidget {
|
|
|
|
|
final List<dynamic> wishlist;
|
|
|
|
|
final bool isTrue;
|
|
|
|
|
final WishListViewModel model;
|
|
|
|
|
|
|
|
|
|
ProductCheckTypeWidget(this.isTrue, this.wishlist);
|
|
|
|
|
ProductCheckTypeWidget({this.model});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ProductCheckTypeWidgetState createState() => _ProductCheckTypeWidgetState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ProductCheckTypeWidgetState extends State<ProductCheckTypeWidget> {
|
|
|
|
|
void initState() {
|
|
|
|
|
getLanguageID();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return widget.isTrue
|
|
|
|
|
? ListView.builder(
|
|
|
|
|
itemCount: widget.wishlist.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
child: widget.isTrue
|
|
|
|
|
? productTile(
|
|
|
|
|
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'
|
|
|
|
|
? 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)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
: GridView.count(
|
|
|
|
|
crossAxisCount: 2,
|
|
|
|
|
children: List.generate(
|
|
|
|
|
widget.wishlist.length,
|
|
|
|
|
(index) => productTile(
|
|
|
|
|
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,
|
|
|
|
|
)),
|
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
|
return ListView.builder(
|
|
|
|
|
itemCount: widget.model.wishListList.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
child: productTile(
|
|
|
|
|
productName: projectViewModel.isArabic
|
|
|
|
|
? widget.model.wishListList[index].product.namen
|
|
|
|
|
: widget.model.wishListList[index].product.name,
|
|
|
|
|
productPrice: widget.model.wishListList[index].subtotal,
|
|
|
|
|
productRate: double.parse(widget.model.wishListList[index].subtotalVatRate),
|
|
|
|
|
productImage: widget.model.wishListList[index].product.images[0].src,
|
|
|
|
|
productID: widget.model.wishListList[index].product.id,
|
|
|
|
|
onDelete: deleteWishListItem,
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Divider(height: 1, color: Colors.grey)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
await widget.model.getWishlistData(isLocalLoader: true);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
print("Delete");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getWishlistData() async {
|
|
|
|
|
WishListViewModel x = new WishListViewModel();
|
|
|
|
|
await x.getWishlistData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getLanguageID() async {
|
|
|
|
|
languageID = await sharedPref.getString(APP_LANGUAGE);
|
|
|
|
|
}
|
|
|
|
|
|