pagedetails

This commit is contained in:
2025-01-29 19:02:28 +05:30
parent 5c69ac3322
commit cae6f13d35
19 changed files with 1391 additions and 531 deletions

View File

@@ -80,6 +80,8 @@ class ProductProvider extends ChangeNotifier {
);
}
//similarProduct
List<BannerData> banner = [];
bool isBannerLoading = true;
@@ -310,21 +312,84 @@ class ProductProvider extends ChangeNotifier {
List<WishListItem> wishListItem = [];
int totalItems=0;
int totalItems = 0;
Future<void> gettAllWishList(BuildContext context) async {
var data = {};
var result = await _homeRepo.gettAllWishList(data);
try {
var result = await _homeRepo.gettAllWishList(data);
return result.fold(
(error) {
print("sdfgdfgfdggf");
isWishListItemLoadingg = false;
notifyListeners();
},
(response) {
print("lsjfdgjsdfsdfgkdfkgkjkf");
wishListItem = response.items!;
totalItems = response.totalItems;
isWishListItemLoadingg = false;
notifyListeners();
},
);
} catch (e) {
isWishListItemLoadingg = false;
notifyListeners();
print("jdsgkdfkghk");
}
}
////////////////////////////// product increase ////////////////////////////////////
int _quantity = 1;
double _unitPrice = 0.0;
double _totalPrice = 0.0;
int get quantity => _quantity;
double get totalPrice => _totalPrice;
void setProductPrice(double price) {
_unitPrice = price;
_totalPrice = _unitPrice * _quantity;
notifyListeners();
}
void increaseQuantity() {
print("kjfgkhkdfhgkjdhfg");
_quantity++;
_totalPrice = _unitPrice * _quantity;
notifyListeners();
}
void decreaseQuantity() {
if (_quantity > 1) {
_quantity--;
_totalPrice = _unitPrice * _quantity;
notifyListeners();
}
}
//////////////////////////////////////////////////////////////similar product//////////////////////
List<Product> similarProductlist = [];
Future<void> similarProductprovider(BuildContext context, String id) async {
var data = {};
var result = await _homeRepo.similarProduct(data, context, id);
return result.fold(
(error) {
isWishListItemLoadingg = false;
// isLoadingg = false;
notifyListeners();
},
(response) {
wishListItem = response.items!;
totalItems=response.totalItems;
isWishListItemLoadingg = false;
print("jkshdfkhdjkfkjdfkgkjdfjgk ${response}");
similarProductlist = response! as List<Product>;
// isLoadingg = false;
notifyListeners();
},
);

View File

@@ -67,6 +67,24 @@ class ProductRepo {
}
}
FutureResult<List<Product>> similarProduct(
data, BuildContext context, id) async {
try {
var response = await _productService.similarProduct(data, id);
List<Product> products = (response as List)
.map((item) => Product.fromJson(item as Map<String, dynamic>))
.toList();
print("sdkjfkjdkfjgjfdjg");
return right(products);
} on DioException catch (e) {
var error = CustomDioExceptions.handleError(e);
return left(error);
}
}
FutureResult<String> addToWish(data) async {
try {
var response = await _productService.addToWish(data);
@@ -98,13 +116,12 @@ class ProductRepo {
FutureResult<WishListModel> gettAllWishList(data) async {
try {
var response = await _productService.gettAllWishList(data);
WishListModel wishListModel=wishListModelFromJson(response.toString());
// final String model = response.toString();
WishListModel wishListModel = wishListModelFromJson(response.toString());
// final String model = response.toString();
return right(wishListModel);
} on DioException catch (e)
{
} on DioException catch (e) {
print("djhgfjdfhjg ${e}");
var error = CustomDioExceptions.handleError(e);
return left(error);

View File

@@ -44,6 +44,14 @@ class ProductService extends ApiService {
return response;
}
Future similarProduct(data,id) async {
var response = await api.get(APIURL.similarProduct+id+"/similar", data: jsonEncode(data));
return response;
}
Future addToWish(data) async {
var response = await api.post(APIURL.addToWish, data: jsonEncode(data));