final category discuss

This commit is contained in:
2025-05-09 15:02:13 +05:30
parent f863a81bb1
commit 873c73143b
12 changed files with 653 additions and 684 deletions

View File

@@ -12,7 +12,7 @@ class APIURL {
static const String getBestDealProduct = "${BASE_URL}products/best-deals";
static const String getAllcategory = "${BASE_URL}categories";
static const String addToWish = "${BASE_URL}carts/wishlist/items";
static const String getSubcategory = "${BASE_URL}categories/by-level/2";
static const String getSubcategory = "${BASE_URL}categories/by-level/3";
static const String deleteToWish = "${BASE_URL}carts/wishlist/items";
static const String addToCart = "${BASE_URL}carts/items";
static const String gettAllWishList = "${BASE_URL}carts/wishlist";
@@ -50,10 +50,7 @@ class APIURL {
static const String updateStatus = "${BASE_URL}orders/items/";
static const String checkAddress = "${BASE_URL}distance/by-address/";
static const String productReview = "${BASE_URL}products/";
static const String productReview = "${BASE_URL}products/";
static const String upDateDeviceToken = "${BASE_URL}devices/register";
}

View File

@@ -25,6 +25,12 @@ import 'package:http/http.dart' as http;
class ProductProvider extends ChangeNotifier {
final _homeRepo = getIt<ProductRepo>();
String searchValue = '';
bool isLoadingg = false;
@@ -39,7 +45,8 @@ class ProductProvider extends ChangeNotifier {
bool iscroll = true;
Future<void> gettAllProduct(BuildContext context, String id, bool status,
String search, bool first) async {
String search, bool first) async
{
print("kdjfhgkfkjdghkjkdfg");
// if (isLoadingg || !hasMore) return;
@@ -174,6 +181,7 @@ class ProductProvider extends ChangeNotifier {
},
);
}
int selectedImage = 0;
ProductDetailsData productDetails = ProductDetailsData();
bool isProductLoading = true;
@@ -281,7 +289,8 @@ class ProductProvider extends ChangeNotifier {
print("Error fetching categories: $error");
notifyListeners();
},
(categoryList) {
(categoryList)
{
if (categoryList.isNotEmpty) {
final categories = [ProductCategoryModel(id: "all", name: "ALL")];
categories.addAll(categoryList.cast<ProductCategoryModel>());

View File

@@ -143,7 +143,7 @@ class ProductRepo {
.map((item) => ProductCategoryModel.fromJson(item))
.toList();
if (response != null && response.data != null) {
// Parse the response data into a list of ProductCategoryModel
final List<ProductCategoryModel> productModels = (response.data as List)
.map((item) => ProductCategoryModel.fromJson(item))
.toList();

View File

@@ -28,37 +28,7 @@ class FruitVeggieDetail extends StatefulWidget {
class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
final ScrollController _scrollController = ScrollController();
// @override
// void initState() {
// final productProvider = Provider.of<ProductProvider>(context, listen: false)
// .gettAllProduct(context, "", true, '', true);
// WidgetsBinding.instance.addPostFrameCallback((_) {
// final productProvider =
// Provider.of<ProductProvider>(context, listen: false);
// productProvider.getAllcategory(context);
// productProvider.getCategoryByLevel();
// productProvider.setActiveIndex(0);
// });
// _scrollController.addListener(() {
// if (_scrollController.position.pixels ==
// _scrollController.position.maxScrollExtent) {
// final productProvider =
// Provider.of<ProductProvider>(context, listen: false);
// productProvider.gettAllProduct(context, "", false, '', false);
// }
// });
// super.initState();
// }
// @override
// void dispose() {
// _scrollController.dispose();
// super.dispose();
// }
@override
void initState() {
super.initState();
@@ -66,15 +36,13 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
WidgetsBinding.instance.addPostFrameCallback((_) {
final productProvider =
Provider.of<ProductProvider>(context, listen: false);
productProvider.page = 1;
// Initial product fetch
productProvider.gettAllProduct(context, "", true, '', true);
// Fetch categories
productProvider.getAllcategory(context);
productProvider.getCategoryByLevel();
// Set initial tab/index
productProvider.setActiveIndex(0);
});
@@ -84,7 +52,6 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
final productProvider =
Provider.of<ProductProvider>(context, listen: false);
// Load more products on scroll
productProvider.gettAllProduct(context, "", false, '', false);
}
});
@@ -231,14 +198,12 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
alignment: Alignment.center,
children: [
AppNetworkImage(
imageUrl: product
.productImages!.first.url ??
"https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
backGroundColor: Colors.transparent,
radius: 10,
boxFit:BoxFit.fill
),
imageUrl: product
.productImages!.first.url ??
"https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
backGroundColor: Colors.transparent,
radius: 10,
boxFit: BoxFit.fill),
Positioned(
right: 1,
bottom: 0,
@@ -258,12 +223,11 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontWeight:FontWeight.bold,
fontWeight: FontWeight.bold,
fontSize: 10)),
),
),
)
],
),
),

View File

@@ -41,7 +41,6 @@ class ProductDetails extends StatefulWidget {
class _ProductDetailsState extends State<ProductDetails> {
int quantity = 1;
int selectedImage = 0;
String productId = '';
@override
@@ -158,16 +157,14 @@ class _ProductDetailsState extends State<ProductDetails> {
},
options: CarouselOptions(
height: 300,
initialPage: selectedImage,
initialPage: provider.selectedImage,
enableInfiniteScroll: true,
autoPlay: true,
autoPlayInterval: Duration(seconds: 3),
autoPlayAnimationDuration: Duration(milliseconds: 800),
enlargeCenterPage: true,
onPageChanged: (index, reason) {
setState(() {
selectedImage = index;
});
provider.selectedImage = index;
},
),
),
@@ -183,7 +180,9 @@ class _ProductDetailsState extends State<ProductDetails> {
height: 8,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: selectedImage == index ? Colors.red : Colors.grey,
color: provider.selectedImage == index
? Colors.red
: Colors.grey,
),
);
}).toList(),