seaching competed

This commit is contained in:
2025-05-10 15:38:46 +05:30
parent e10f6747c9
commit ce0a60dbd1
13 changed files with 152 additions and 2387 deletions

View File

@@ -70,6 +70,14 @@ class _BestDealScreenState extends State<BestDealScreen> {
? TextField(
controller: _searchController,
autofocus: true,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
onSubmitted: (value) {
if (value.isNotEmpty) {
Provider.of<ProductProvider>(context, listen: false)
.getBestDealProduct(context, _searchController.text);
}
},
decoration: const InputDecoration(
hintText: "Search...",
border: InputBorder.none,
@@ -290,7 +298,7 @@ class _BestDealScreenState extends State<BestDealScreen> {
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1.3),
(MediaQuery.of(context).size.height / 1.1),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
@@ -298,22 +306,19 @@ class _BestDealScreenState extends State<BestDealScreen> {
var bestdealproduct = provider.bestdeal[index];
return InkWell(
onTap: () async {
var status = await provider.getProduuctDetails(context,
bestdealproduct.id, 1, bestdealproduct.discountPrice);
if (status) {
context.push(
MyRoutes.PRODUCTDETAILS,
extra: {
"id": bestdealproduct.id,
"quantity": 1,
"price": bestdealproduct.discountPrice,
},
);
}
var status = await provider.getProduuctDetails(
context, bestdealproduct.id, 1, bestdealproduct.discountPrice);
if (status) {
context.push(
MyRoutes.PRODUCTDETAILS,
extra: {
"id": bestdealproduct.id,
"quantity": 1,
"price": bestdealproduct.discountPrice,
},
);
}
// context.push(
// MyRoutes.PRODUCTDETAILS,
// extra: {
@@ -345,7 +350,7 @@ class _BestDealScreenState extends State<BestDealScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: MediaQuery.of(context).size.height * 0.19,
height: MediaQuery.of(context).size.height * 0.25,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),

View File

@@ -138,7 +138,7 @@ class _CtegoryProductState extends State<CtegoryProduct> {
child: LayoutBuilder(
builder: (context, constraints) {
final itemWidth = (constraints.maxWidth - 20) / 2;
final itemHeight = itemWidth * 1.4;
final itemHeight = itemWidth * 1.7;
return GridView.builder(
controller: _scrollController,
@@ -197,7 +197,7 @@ class _CtegoryProductState extends State<CtegoryProduct> {
children: [
Container(
height: itemWidth *
0.9, // Adjust height for image container
1.1, // Adjust height for image container
// width: itemWidth,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
@@ -375,277 +375,4 @@ class _CtegoryProductState extends State<CtegoryProduct> {
double discountPercentage = (discountAmount / basePrice) * 100;
return discountPercentage.round();
}
Widget filterCategory() {
final activeIndexProvider = Provider.of<ProductProvider>(context);
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.iscategroyloading) {
return Center(
child: Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: APPCOLOR.bgGrey,
width: 1,
),
),
child: const Center(
child: CupertinoActivityIndicator(),
),
),
);
} else {
final categories = [DatumCategory(id: "all", name: "ALL")];
categories.addAll(provider.categoryList.cast<DatumCategory>());
return Container(
decoration: const BoxDecoration(color: Colors.white),
width: 70,
child: ListView.builder(
itemCount: categories.length,
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
var category = categories[index];
return Padding(
padding: const EdgeInsets.only(bottom: 0),
child: InkWell(
onTap: () {
provider.iscroll = true;
provider.products.clear();
provider.isLoadingg = false;
provider.hasMore = true;
provider.page = 1;
provider.notifyListeners();
if (category.id == "all") {
provider.gettAllProduct(context, "", true, '', false);
} else {
provider.gettAllProduct(
context, "/category/${category.id}", true, '', false);
}
activeIndexProvider.setActiveIndex(index);
},
child: Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Container(
decoration: BoxDecoration(
color: activeIndexProvider.activeIndex == index
? Colors.greenAccent.withOpacity(0.3)
: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(5)),
child: Padding(
padding: const EdgeInsets.only(top: 0, bottom: 0),
child: SizedBox(
width: 70,
child: Column(
children: [
if (category.name == "ALL") ...{
if (provider.categoriesss.isNotEmpty)
PopupMenuButton<ProductCategoryModel>(
onSelected: (ProductCategoryModel value) {
activeIndexProvider.setActiveIndex(0);
if (value.id == "all") {
provider.iscroll = true;
provider.products.clear();
provider.isLoadingg = false;
provider.hasMore = true;
provider.page = 1;
provider.gettAllProduct(
context, "", true, '', false);
provider.getAllcategory(context);
} else {
provider.categoryList.clear();
provider.getSubcategory(
context, value.id);
}
provider.setSelectedCategory(value);
},
itemBuilder: (BuildContext context) =>
provider.categoriesss
.map(
(category) => PopupMenuItem(
value: category,
child: Text(category.name ??
"Unknown"),
),
)
.toList(),
child: Center(
child: Column(
children: [
const Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text("All"),
Icon(Icons.arrow_drop_down)
],
),
CachedNetworkImage(
errorWidget:
(context, url, error) {
return Container(
height: 40,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius:
BorderRadius
.circular(10),
border: Border.all(
color: Colors
.transparent,
width: 1,
)),
child: Center(
child: Image.asset(
APPASSETS.placeHolder,
height: 50 * 0.4,
color: APPCOLOR.bgGrey,
)),
);
},
placeholder: (context, url) {
return Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius:
BorderRadius
.circular(10),
border: Border.all(
color:
APPCOLOR.bgGrey,
width: 1,
)),
child: const Center(
child:
CupertinoActivityIndicator(),
),
);
},
imageBuilder:
(context, cIMage) {
return Container(
// width: 60,
height: 70,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(
Radius.circular(5!),
),
image: DecorationImage(
fit: BoxFit.fill,
image: cIMage,
)),
);
},
imageUrl: provider
.selectedCategory
?.image ??
'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png'),
],
),
)),
} else ...{
Column(
children: [
CachedNetworkImage(
errorWidget: (context, url, error) {
return Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius:
BorderRadius.circular(10),
border: Border.all(
color: Colors.transparent,
width: 1,
)),
child: Center(
child: Image.asset(
APPASSETS.placeHolder,
height: 50 * 0.4,
color: APPCOLOR.bgGrey,
)),
);
},
placeholder: (context, url) {
return Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius:
BorderRadius.circular(10),
border: Border.all(
color: APPCOLOR.bgGrey,
width: 1,
)),
child: const Center(
child:
CupertinoActivityIndicator(),
),
);
},
imageBuilder: (context, cIMage) {
return Container(
height: 60,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(5!),
),
image: DecorationImage(
fit: BoxFit.fill,
image: cIMage,
)),
);
},
imageUrl: category.image),
SizedBox(
height: 5,
),
Container(
width: 50,
child: Text(
category.name,
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style:
activeIndexProvider.activeIndex ==
index
? context.customExtraBold(
APPCOLOR.balck1A1A1A, 9)
: context.customMedium(
APPCOLOR.balck1A1A1A, 10),
),
),
],
),
},
],
),
),
),
),
),
),
);
},
),
);
}
});
}
}

View File

@@ -135,7 +135,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
title: Text(category.name!),
onTap: () {
context.push(MyRoutes.CATEGORYPRODUCT,
extra: {"id":category.id,"name": category.name});
extra: {"id": category.id, "name": category.name});
},
);
}
@@ -198,8 +198,8 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
padding: const EdgeInsets.only(bottom: 0),
child: InkWell(
onTap: () {
context.push(MyRoutes.CATEGORYPRODUCT,
extra: {"id":category.id,"name": category.name});
context.push(MyRoutes.CATEGORYPRODUCT,
extra: {"id": category.id, "name": category.name});
// provider.iscroll = true;
// provider.products.clear();
// provider.isLoadingg = false;
@@ -232,117 +232,117 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
child: Column(
children: [
if (category.name == "ALL") ...{
if (provider.categoriesss.isNotEmpty)
PopupMenuButton<ProductCategoryModel>(
onSelected: (ProductCategoryModel value) {
activeIndexProvider.setActiveIndex(0);
// if (provider.categoriesss.isNotEmpty)
// PopupMenuButton<ProductCategoryModel>(
// onSelected: (ProductCategoryModel value) {
// activeIndexProvider.setActiveIndex(0);
if (value.id == "all") {
provider.iscroll = true;
provider.products.clear();
provider.isLoadingg = false;
provider.hasMore = true;
provider.page = 1;
provider.gettAllProduct(
context, "", true, '', false);
provider.getAllcategory(context);
} else {
provider.categoryList.clear();
provider.getSubcategory(
context, value.id);
}
// if (value.id == "all") {
// provider.iscroll = true;
// provider.products.clear();
// provider.isLoadingg = false;
// provider.hasMore = true;
// provider.page = 1;
// provider.gettAllProduct(
// context, "", true, '', false);
// provider.getAllcategory(context);
// } else {
// provider.categoryList.clear();
// provider.getSubcategory(
// context, value.id);
// }
provider.setSelectedCategory(value);
},
itemBuilder: (BuildContext context) =>
provider.categoriesss
.map(
(category) => PopupMenuItem(
value: category,
child: Text(category.name ??
"Unknown"),
),
)
.toList(),
child: Center(
child: Column(
children: [
const Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Text("All"),
Icon(Icons.arrow_drop_down)
],
),
CachedNetworkImage(
errorWidget:
(context, url, error) {
return Container(
height: 40,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius:
BorderRadius
.circular(10),
border: Border.all(
color: Colors
.transparent,
width: 1,
)),
child: Center(
child: Image.asset(
APPASSETS.placeHolder,
height: 50 * 0.4,
color: APPCOLOR.bgGrey,
)),
);
},
placeholder: (context, url) {
return Container(
height: 50,
width: 50,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius:
BorderRadius
.circular(10),
border: Border.all(
color:
APPCOLOR.bgGrey,
width: 1,
)),
child: const Center(
child:
CupertinoActivityIndicator(),
),
);
},
imageBuilder:
(context, cIMage) {
return Container(
// width: 60,
height: 70,
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(
Radius.circular(5!),
),
image: DecorationImage(
fit: BoxFit.fill,
image: cIMage,
)),
);
},
imageUrl: provider
.selectedCategory
?.image ??
'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png'),
],
),
)),
// provider.setSelectedCategory(value);
// },
// itemBuilder: (BuildContext context) =>
// provider.categoriesss
// .map(
// (category) => PopupMenuItem(
// value: category,
// child: Text(category.name ??
// "Unknown"),
// ),
// )
// .toList(),
// child: Center(
// child: Column(
// children: [
// const Row(
// crossAxisAlignment:
// CrossAxisAlignment.center,
// mainAxisAlignment:
// MainAxisAlignment.center,
// children: [
// Text("All"),
// Icon(Icons.arrow_drop_down)
// ],
// ),
// CachedNetworkImage(
// errorWidget:
// (context, url, error) {
// return Container(
// height: 40,
// decoration: BoxDecoration(
// color: APPCOLOR.bgGrey,
// borderRadius:
// BorderRadius
// .circular(10),
// border: Border.all(
// color: Colors
// .transparent,
// width: 1,
// )),
// child: Center(
// child: Image.asset(
// APPASSETS.placeHolder,
// height: 50 * 0.4,
// color: APPCOLOR.bgGrey,
// )),
// );
// },
// placeholder: (context, url) {
// return Container(
// height: 50,
// width: 50,
// decoration: BoxDecoration(
// color: APPCOLOR.bgGrey,
// borderRadius:
// BorderRadius
// .circular(10),
// border: Border.all(
// color:
// APPCOLOR.bgGrey,
// width: 1,
// )),
// child: const Center(
// child:
// CupertinoActivityIndicator(),
// ),
// );
// },
// imageBuilder:
// (context, cIMage) {
// return Container(
// // width: 60,
// height: 70,
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.all(
// Radius.circular(5!),
// ),
// image: DecorationImage(
// fit: BoxFit.fill,
// image: cIMage,
// )),
// );
// },
// imageUrl: provider
// .selectedCategory
// ?.image ??
// 'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png'),
// ],
// ),
// )),
} else ...{
Column(
children: [
@@ -387,7 +387,7 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
},
imageBuilder: (context, cIMage) {
return Container(
height: 60,
height: 70,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(5!),

View File

@@ -164,6 +164,14 @@ class _HomeScreenState extends State<HomeScreen> {
),
child: TextFormField(
controller: _searchController,
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
onFieldSubmitted: (value) {
if (value.isNotEmpty) {
provider.getHomeProduct(context, "",
_searchController.text, '', '', '');
}
},
onChanged: (value) {
if (value.isEmpty) {
provider.getHomeProduct(context, "",
@@ -383,14 +391,14 @@ class _HomeScreenState extends State<HomeScreen> {
height: 300.h,
))
: SizedBox(
height: MediaQuery.of(context).size.height * 0.3,
height: MediaQuery.of(context).size.height * 0.4,
child: ListView.builder(
itemCount: provider.bestdeal.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
var bestdealproduct = provider.bestdeal[index];
double cardWidth =
MediaQuery.of(context).size.width * 0.4;
MediaQuery.of(context).size.width * 0.5;
return InkWell(
onTap: () async {
@@ -424,7 +432,7 @@ class _HomeScreenState extends State<HomeScreen> {
Center(
child: Container(
height: MediaQuery.of(context).size.height *
0.17,
0.25,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),

View File

@@ -421,7 +421,7 @@ class _ProductDetailsState extends State<ProductDetails> {
children: [
_buildText(
"Customer Care Details ",
'In case of any issue, contact us${provider.productDetails.data!.store!.officialPhoneNumber ?? ''}',
'In case of any issue, contact us: +91${provider.productDetails.data!.store!.officialPhoneNumber ?? ''}',
),
if (isExpanded)
_buildText(
@@ -975,13 +975,13 @@ class _ProductDetailsState extends State<ProductDetails> {
return Center(child: Text('No products available'));
} else {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.3,
height: MediaQuery.of(context).size.height * 0.4,
child: ListView.builder(
itemCount: provider.bestdeal.length,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
var bestdealproduct = provider.bestdeal[index];
double cardWidth = MediaQuery.of(context).size.width * 0.4;
double cardWidth = MediaQuery.of(context).size.width * 0.5;
return InkWell(
onTap: () async {
@@ -1020,7 +1020,7 @@ class _ProductDetailsState extends State<ProductDetails> {
children: [
Center(
child: Container(
height: MediaQuery.of(context).size.height * 0.17,
height: MediaQuery.of(context).size.height * 0.25,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),