implementsProdctApi

This commit is contained in:
bestonemitRam
2025-01-27 01:11:20 +05:30
parent 9e559bdded
commit cbeaa2af5c
24 changed files with 2231 additions and 1026 deletions

View File

@@ -1,10 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:grocery_app/src/common_widget/network_image.dart';
import 'package:grocery_app/src/logic/provider/home_provider.dart';
import 'package:grocery_app/utils/constants/assets_constant.dart';
import 'package:grocery_app/utils/constants/color_constant.dart';
import 'package:grocery_app/utils/extensions/uicontext.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:provider/provider.dart';
class FruitVeggieDetail extends StatefulWidget {
const FruitVeggieDetail({super.key});
@@ -14,17 +16,19 @@ class FruitVeggieDetail extends StatefulWidget {
}
class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
int activeIndex = 0;
@override
void initState() {
Provider.of<ProductProvider>(context, listen: false)
.getAllcategory(context);
void changeActiveIndex(int currentActiveIndex) {
activeIndex = currentActiveIndex;
setState(() {});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
centerTitle: true,
leading: Center(
child: SizedBox(
@@ -62,175 +66,373 @@ class _FruitVeggieDetailState extends State<FruitVeggieDetail> {
],
),
body: Row(
children: [
Container(
decoration: const BoxDecoration(color: Colors.white),
width: 100,
child: ListView.builder(
itemCount: 10,
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
changeActiveIndex(index);
},
child: SizedBox(
height: 150,
child: Column(
children: [
Row(
children: [filterCategory(), productWidget()],
),
);
}
Widget productWidget() {
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.isLoadingg) {
return Center(child: CircularProgressIndicator());
} else if (provider.products.isEmpty) {
return Center(child: Text('No products available'));
} else {
return Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10, right: 10),
child: LayoutBuilder(
builder: (context, constraints) {
final itemWidth = (constraints.maxWidth - 20) / 2;
final itemHeight = itemWidth * 1.5;
return GridView.builder(
itemCount: provider.products.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: itemWidth / itemHeight,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
),
itemBuilder: (context, index) {
var product = provider.products[index];
return Container(
height: itemHeight,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 1,
offset: const Offset(5, 5),
),
],
),
child: Padding(
padding: const EdgeInsets.all(5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Center(
child: Container(
decoration: BoxDecoration(
color: activeIndex == index ? Colors.greenAccent.withOpacity(0.1) : APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(5),
Container(
height: itemWidth *
0.6, // Adjust height for image container
width: itemWidth,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),
),
child: Stack(
alignment: Alignment.center,
children: [
AppNetworkImage(
height: 70,
width: 70,
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,
),
child: AppNetworkImage(
height: 80,
width: 80,
imageUrl: 'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
backGroundColor: APPCOLOR.bgGrey,
radius: 10,
Positioned(
right: 5,
top: 5,
child: Icon(Icons.favorite_border),
),
),
],
),
),
Container(
width: 3,
height: 100,
color: activeIndex == index ? APPCOLOR.lightGreen : Colors.transparent,
)
const SizedBox(height: 5),
Text(
product.name ?? " ",
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(
APPCOLOR.balck1A1A1A, 14),
),
const SizedBox(height: 5),
Text(
product.unit ?? " ",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(
Colors.grey.withOpacity(0.8),
12,
),
),
const SizedBox(height: 3),
Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"\$${product.discountPrice ?? " "}",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customSemiBold(
Colors.black, 12),
),
const SizedBox(width: 5),
Text(
"\$${product.basePrice ?? " "}",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context
.customMedium(
Colors.grey.withOpacity(0.8),
12,
)
.copyWith(
decoration:
TextDecoration.lineThrough,
),
),
],
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Container(
height: 40,
width: 60,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(5),
),
child: Center(
child: Text(
'Add',
style: context.customRegular(
Colors.white, 12),
),
),
),
),
),
],
),
],
),
Text(
"Fresh Vegitables",
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: activeIndex == index ? context.customExtraBold(APPCOLOR.balck1A1A1A, 14) : context.customMedium(APPCOLOR.balck1A1A1A, 14),
)
],
),
),
),
);
},
);
},
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 10, right: 10),
child: GridView.builder(
itemCount: 20,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 1.1), crossAxisSpacing: 10, mainAxisSpacing: 10),
itemBuilder: (context, index) {
return Container(
height: 300,
// width: 150,
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15), boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 1,
offset: const Offset(5, 5),
),
]),
child: Padding(
padding: const EdgeInsets.all(5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 100,
width: 150,
decoration: BoxDecoration(color: APPCOLOR.bgGrey, borderRadius: BorderRadius.circular(15)),
child: const Stack(
alignment: Alignment.center,
children: [
AppNetworkImage(
height: 70,
width: 70,
imageUrl: "https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
backGroundColor: Colors.transparent),
Positioned(right: 5, top: 5, child: Icon(Icons.favorite_border))
],
),
),
Text(
"Fortune Arhar Dal (Toor Dal)",
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
const SizedBox(
height: 5,
),
Text(
"500 ML",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(Colors.grey.withOpacity(0.8), 12),
),
const SizedBox(
height: 3,
),
Row(
children: [
Column(
children: [
Text(
"\$12",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customSemiBold(Colors.black, 12),
);
// Expanded(
// child: Padding(
// padding: const EdgeInsets.only(left: 10, right: 10),
// child: GridView.builder(
// itemCount: provider.products.length,
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// crossAxisCount: 2,
// childAspectRatio: MediaQuery.of(context).size.width /
// (MediaQuery.of(context).size.height / 1.1),
// crossAxisSpacing: 10,
// mainAxisSpacing: 10),
// itemBuilder: (context, index) {
// return Container(
// height: MediaQuery.of(context).size.height * 0.28,
// // width: 150,
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(15),
// boxShadow: [
// BoxShadow(
// color: Colors.grey.withOpacity(0.1),
// blurRadius: 1,
// offset: const Offset(5, 5),
// ),
// ]),
// child: Padding(
// padding: const EdgeInsets.all(5),
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Container(
// height: 100,
// width: 150,
// decoration: BoxDecoration(
// color: APPCOLOR.bgGrey,
// borderRadius: BorderRadius.circular(15)),
// child: const Stack(
// alignment: Alignment.center,
// children: [
// AppNetworkImage(
// height: 70,
// width: 70,
// imageUrl:
// "https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
// backGroundColor: Colors.transparent),
// Positioned(
// right: 5,
// top: 5,
// child: Icon(Icons.favorite_border))
// ],
// ),
// ),
// Text(
// "Fortune Arhar Dal (Toor Dal)",
// textAlign: TextAlign.left,
// maxLines: 2,
// overflow: TextOverflow.ellipsis,
// style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
// ),
// const SizedBox(
// height: 5,
// ),
// Text(
// "500 ML",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context.customMedium(
// Colors.grey.withOpacity(0.8), 12),
// ),
// const SizedBox(
// height: 3,
// ),
// Row(
// children: [
// Column(
// children: [
// Text(
// "\$12",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context.customSemiBold(Colors.black, 12),
// ),
// const SizedBox(
// width: 5,
// ),
// Text(
// "\$14",
// textAlign: TextAlign.left,
// maxLines: 1,
// overflow: TextOverflow.ellipsis,
// style: context
// .customMedium(
// Colors.grey.withOpacity(0.8), 12)
// .copyWith(
// decoration: TextDecoration.lineThrough,
// ),
// ),
// ],
// ),
// Expanded(
// child: Align(
// alignment: Alignment.centerRight,
// child: Container(
// height: 40,
// width: 60,
// decoration: BoxDecoration(
// color: APPCOLOR.lightGreen,
// borderRadius: BorderRadius.circular(5),
// ),
// child: Center(
// child: Text(
// 'Add',
// style:
// context.customRegular(Colors.white, 12),
// )),
// ),
// ),
// )
// ],
// ),
// ],
// ),
// ),
// );
// },
// ),
// ));
}
});
}
Widget filterCategory() {
final activeIndexProvider = Provider.of<ProductProvider>(context);
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.iscategroyloading) {
return Center(child: CircularProgressIndicator());
} else if (provider.categoryList.isEmpty) {
return Center(child: Text('No products available'));
} else {
return Container(
decoration: const BoxDecoration(color: Colors.white),
width: 100,
child: ListView.builder(
itemCount: provider.categoryList.length,
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
var category = provider.categoryList[index];
return InkWell(
onTap: ()
{
activeIndexProvider.setActiveIndex(index);
},
child: SizedBox(
height: 150,
child: Column(
children: [
Row(
children: [
Expanded(
child: Center(
child: Container(
decoration: BoxDecoration(
color:
activeIndexProvider.activeIndex == index
? Colors.greenAccent.withOpacity(0.1)
: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(5),
),
const SizedBox(
width: 5,
),
Text(
"\$14",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(Colors.grey.withOpacity(0.8), 12).copyWith(
decoration: TextDecoration.lineThrough,
),
),
],
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Container(
height: 40,
width: 60,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(5),
),
child: Center(
child: Text(
'Add',
style: context.customRegular(Colors.white, 12),
)),
child: AppNetworkImage(
height: 80,
width: 80,
imageUrl: category.image ??
'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
backGroundColor: APPCOLOR.bgGrey,
radius: 10,
),
),
)
],
),
],
),
),
),
Container(
width: 3,
height: 100,
color: activeIndexProvider.activeIndex == index
? APPCOLOR.lightGreen
: Colors.transparent,
),
],
),
Text(
category.name,
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: activeIndexProvider.activeIndex == index
? context.customExtraBold(APPCOLOR.balck1A1A1A, 14)
: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
],
),
);
},
),
))
],
),
);
),
);
},
),
);
}
});
}
}

View File

@@ -1,10 +1,16 @@
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:grocery_app/src/common_widget/network_image.dart';
import 'package:grocery_app/src/core/routes/routes.dart';
import 'package:grocery_app/src/logic/provider/home_provider.dart';
import 'package:grocery_app/src/ui/bestdeal/bestdeal_screen.dart';
import 'package:grocery_app/src/ui/fruitvegidetail/fruit_veggie_detail.dart';
import 'package:grocery_app/utils/constants/color_constant.dart';
import 'package:grocery_app/utils/extensions/extensions.dart';
import 'package:grocery_app/utils/extensions/uicontext.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:provider/provider.dart';
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@@ -15,6 +21,19 @@ class HomeScreen extends StatefulWidget {
class _HomeScreenState extends State<HomeScreen> {
@override
void initState() {
super.initState();
Provider.of<ProductProvider>(context, listen: false).getBanners(context);
Provider.of<ProductProvider>(context, listen: false)
.gettAllProduct(context);
Provider.of<ProductProvider>(context, listen: false)
.getBestDealProduct(context);
Provider.of<ProductProvider>(context, listen: false)
.getAllcategory(context);
}
@override
Widget build(BuildContext context) {
return SafeArea(
@@ -46,7 +65,8 @@ class _HomeScreenState extends State<HomeScreen> {
children: [
Text(
"Home",
style: context.customMedium(APPCOLOR.black333333, 18),
style: context.customMedium(
APPCOLOR.black333333, 18),
),
const SizedBox(
width: 5,
@@ -92,9 +112,11 @@ class _HomeScreenState extends State<HomeScreen> {
fillColor: Colors.transparent,
prefixIcon: Icon(MdiIcons.magnify),
hintText: 'Search',
hintStyle: context.customRegular(APPCOLOR.grey666666, 18),
hintStyle:
context.customRegular(APPCOLOR.grey666666, 18),
isCollapsed: true,
contentPadding: const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
contentPadding: const EdgeInsets.symmetric(
vertical: 10, horizontal: 10),
),
),
),
@@ -132,11 +154,13 @@ class _HomeScreenState extends State<HomeScreen> {
),
InkWell(
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) {
return const FruitVeggieDetail();
},
));
// Navigator.of(context).push(MaterialPageRoute(
// builder: (context) {
// return const FruitVeggieDetail();
// },
// ));
context.push(MyRoutes.FRUITVEGGIEDETAIL);
},
child: Text(
"See All",
@@ -148,98 +172,11 @@ class _HomeScreenState extends State<HomeScreen> {
const SizedBox(
height: 15,
),
GridView.builder(
shrinkWrap: true,
itemCount: 8,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisSpacing: 5,
mainAxisSpacing: 5,
childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 1.2),
),
itemBuilder: (context, index)
{
return InkWell(
onTap: () {},
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(5),
),
child: AppNetworkImage(
height: 80,
width: 80,
imageUrl: 'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
backGroundColor: APPCOLOR.bgGrey,
radius: 10,
),
),
const SizedBox(
height: 10,
),
Text(
"Vegitables and Fruits",
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
)
],
),
),
);
},
),
categoriesProduct(),
const SizedBox(
height: 15,
),
Container(
height: 180,
decoration: BoxDecoration(color: Colors.greenAccent.withOpacity(0.1), borderRadius: BorderRadius.circular(15)),
child: Stack(
children: [
Positioned(
top: 15,
left: 15,
child: SizedBox(
width: 200,
child: Text(
"World Food Festival, Bring the world to your Kitchen!",
style: context.customExtraBold(Colors.black, 18),
))),
Positioned(
bottom: 15,
left: 15,
child: Container(
height: 40,
width: 100,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(5),
),
child: Center(
child: Text(
'Shop now',
style: context.customRegular(Colors.white, 14),
)),
),
),
const Positioned(
right: 15,
bottom: 15,
child: AppNetworkImage(
height: 130,
width: 150,
imageUrl: 'https://e7.pngegg.com/pngimages/742/816/png-clipart-coca-cola-can-illustration-coca-cola-soft-drink-surge-pepsi-coke-sweetness-cola-thumbnail.png',
backGroundColor: Colors.transparent))
],
),
),
bannerview(),
const SizedBox(
height: 15,
),
@@ -270,119 +207,7 @@ class _HomeScreenState extends State<HomeScreen> {
const SizedBox(
height: 15,
),
SizedBox(
height: 222,
child: ListView.builder(
itemCount: 5,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
child: Container(
height: 215,
width: 150,
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15), boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 1,
offset: const Offset(5, 5),
),
]),
child: Padding(
padding: const EdgeInsets.all(5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 100,
width: 150,
decoration: BoxDecoration(color: APPCOLOR.bgGrey, borderRadius: BorderRadius.circular(15)),
child: const Stack(
alignment: Alignment.center,
children: [
AppNetworkImage(
height: 70,
width: 70,
imageUrl: "https://5.imimg.com/data5/SELLER/Default/2024/2/385126988/OL/DA/VW/8627346/1l-fortune-sunflower-oil.jpg",
backGroundColor: Colors.transparent),
Positioned(right: 5, top: 5, child: Icon(Icons.favorite_border))
],
),
),
Text(
"Fortune Arhar Dal (Toor Dal)",
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
const SizedBox(
height: 5,
),
Text(
"500 ML",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(Colors.grey.withOpacity(0.8), 12),
),
const SizedBox(
height: 3,
),
Row(
children: [
Expanded(
child: Row(
children: [
Text(
"\$12",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customSemiBold(Colors.black, 12),
),
const SizedBox(
width: 5,
),
Text(
"\$14",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(Colors.grey.withOpacity(0.8), 12).copyWith(
decoration: TextDecoration.lineThrough,
),
),
],
)),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Container(
height: 30,
width: 50,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(5),
),
child: Center(
child: Text(
'Add',
style: context.customRegular(Colors.white, 12),
)),
),
),
)
],
),
],
),
),
),
);
},
),
),
bestDeal(),
const SizedBox(
height: 20,
),
@@ -394,9 +219,371 @@ class _HomeScreenState extends State<HomeScreen> {
);
}
@override
void initState() {
// SizeConfig().init(context);
super.initState();
// Widget bannerview() {
// return Consumer<ProductProvider>(builder: (context, provider, child)
// {
// if (provider.isBannerLoading) {
// return Center(child: CircularProgressIndicator());
// } else if (provider.banner.isEmpty) {
// return Center(child: Text('No products available'));
// } else {
// return
// Container(
// height: 180,
// decoration: BoxDecoration(
// color: Colors.greenAccent.withOpacity(0.1),
// borderRadius: BorderRadius.circular(15)),
// child: Stack(
// children: [
// Positioned(
// top: 15,
// left: 15,
// child: SizedBox(
// width: 200,
// child: Text(
// "World Food Festival, Bring the world to your Kitchen!",
// style: context.customExtraBold(Colors.black, 18),
// ))),
// Positioned(
// bottom: 15,
// left: 15,
// child: Container(
// height: 40,
// width: 100,
// decoration: BoxDecoration(
// color: APPCOLOR.lightGreen,
// borderRadius: BorderRadius.circular(5),
// ),
// child: Center(
// child: Text(
// 'Shop now',
// style: context.customRegular(Colors.white, 14),
// )),
// ),
// ),
// const Positioned(
// right: 15,
// bottom: 15,
// child: AppNetworkImage(
// height: 130,
// width: 150,
// imageUrl:
// 'https://e7.pngegg.com/pngimages/742/816/png-clipart-coca-cola-can-illustration-coca-cola-soft-drink-surge-pepsi-coke-sweetness-cola-thumbnail.png',
// backGroundColor: Colors.transparent))
// ],
// ),
// );
// }
// });
// }
Widget bestDeal() {
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.isBestdealingloading) {
return Center(child: CircularProgressIndicator());
} else if (provider.bestdeal.isEmpty) {
return Center(child: Text('No products available'));
} else {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.28,
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; // Dynamic width
return Padding(
padding: const EdgeInsets.only(right: 10, bottom: 5, top: 5),
child: Container(
width: cardWidth,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 1,
offset: const Offset(5, 5),
),
],
),
child: Padding(
padding: const EdgeInsets.all(5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Container(
height: MediaQuery.of(context).size.height * 0.12,
width: cardWidth * 0.9,
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(15),
),
child: Stack(
alignment: Alignment.center,
children: [
AppNetworkImage(
height:
MediaQuery.of(context).size.height * 0.08,
width: cardWidth * 0.7,
imageUrl: bestdealproduct
.productImages?.first?.url ??
"",
backGroundColor: Colors.transparent,
),
Positioned(
right: 5,
top: 5,
child: Icon(Icons.favorite_border),
),
],
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Text(
bestdealproduct.name ?? "",
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.005,
),
Text(
bestdealproduct.unit ?? "",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context.customMedium(
Colors.grey.withOpacity(0.8),
12,
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.005,
),
Row(
children: [
Row(
children: [
Text(
"\$${bestdealproduct.discountPrice ?? ""} ",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style:
context.customSemiBold(Colors.black, 12),
),
Text(
"\$${bestdealproduct.basePrice ?? ""}",
textAlign: TextAlign.left,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: context
.customMedium(
Colors.grey.withOpacity(0.8),
12,
)
.copyWith(
decoration: TextDecoration.lineThrough,
),
),
],
),
const Spacer(),
Align(
alignment: Alignment.centerRight,
child: Container(
height:
MediaQuery.of(context).size.height * 0.035,
width: MediaQuery.of(context).size.width * 0.1,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(5),
),
child: Center(
child: Text(
'Add',
style:
context.customRegular(Colors.white, 12),
),
),
),
),
],
),
],
),
),
),
);
},
),
);
}
});
}
Widget bannerview() {
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.isBannerLoading) {
return Center(child: CircularProgressIndicator());
} else if (provider.banner.isEmpty) {
return Center(child: Text('No products available'));
} else {
return CarouselSlider(
options: CarouselOptions(
height: 180,
autoPlay: true,
enlargeCenterPage: true,
viewportFraction: 1,
aspectRatio: 16 / 9,
initialPage: 0,
enableInfiniteScroll: true,
reverse: false,
autoPlayInterval: Duration(seconds: 3),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.fastOutSlowIn,
enlargeFactor: 0.3,
//aspectRatio: 16 / 9,
//viewportFraction: 0.9,
),
items: provider.banner.map((banner) {
return Builder(
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
// margin: const EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(
color: Colors.greenAccent.withOpacity(0.1),
borderRadius: BorderRadius.circular(15),
),
child: Stack(
children: [
Positioned(
top: 15,
left: 15,
child: SizedBox(
width: 200,
child: Text(
banner.altText ?? "Special Event",
style: context.customExtraBold(Colors.black, 18),
),
),
),
Positioned(
bottom: 15,
left: 15,
child: GestureDetector(
onTap: () {
// Add your navigation or shop action here
},
child: Container(
height: 40,
width: 100,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(5),
),
child: Center(
child: Text(
'Shop now',
style: context.customRegular(Colors.white, 14),
),
),
),
),
),
Positioned(
right: 15,
bottom: 15,
child: AppNetworkImage(
height: 130,
width: 150,
imageUrl: banner.imageUrl ??
'https://e7.pngegg.com/pngimages/742/816/png-clipart-coca-cola-can-illustration-coca-cola-soft-drink-surge-pepsi-coke-sweetness-cola-thumbnail.png',
backGroundColor: Colors.transparent,
),
),
],
),
);
},
);
}).toList(),
);
}
});
}
Widget categoriesProduct() {
return Consumer<ProductProvider>(builder: (context, provider, child) {
if (provider.isLoadingg) {
return Center(child: CircularProgressIndicator());
} else if (provider.products.isEmpty) {
return Center(child: Text('No products available'));
} else {
return GridView.builder(
shrinkWrap: true,
itemCount: provider.products.length,
physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisSpacing: 5,
mainAxisSpacing: 5,
childAspectRatio: MediaQuery.of(context).size.width /
(MediaQuery.of(context).size.height / 1.2),
),
itemBuilder: (context, index) {
var product = provider.products[index];
return InkWell(
onTap: () {},
child: SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
decoration: BoxDecoration(
color: APPCOLOR.bgGrey,
borderRadius: BorderRadius.circular(5),
),
child: AppNetworkImage(
height: 80,
width: 80,
imageUrl: product.productImages!.first.url,
//'https://i.pinimg.com/originals/a5/f3/5f/a5f35fb23e942809da3df91b23718e8d.png',
backGroundColor: APPCOLOR.bgGrey,
radius: 10,
),
),
const SizedBox(
height: 10,
),
Text(
"Vegitables and Fruits",
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: context.customMedium(APPCOLOR.balck1A1A1A, 14),
)
],
),
),
);
},
);
}
});
}
}

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:grocery_app/src/common_widget/network_image.dart';
import 'package:grocery_app/src/logic/provider/home_provider.dart';
import 'package:grocery_app/src/ui/card_checkout/card_checkout_screen.dart';
import 'package:grocery_app/src/ui/edit_profile/edit_profile_screen.dart';
import 'package:grocery_app/src/ui/message/message_screen.dart';
@@ -9,6 +10,7 @@ import 'package:grocery_app/src/ui/static_page/static_page_screen.dart';
import 'package:grocery_app/utils/constants/color_constant.dart';
import 'package:grocery_app/utils/extensions/uicontext.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:provider/provider.dart';
class ProfileScreen extends StatefulWidget {
const ProfileScreen({super.key});
@@ -32,7 +34,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
pinned: true,
backgroundColor: Colors.white,
leading: const SizedBox(),
flexibleSpace: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
flexibleSpace: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
top = constraints.biggest.height;
return FlexibleSpaceBar(
@@ -44,7 +47,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
top > 100
? Text(
"My Profile",
style: context.customExtraBold(Colors.white, 14),
style:
context.customExtraBold(Colors.white, 14),
)
: const SizedBox(),
@@ -63,7 +67,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
AppNetworkImage(
height: top < 150 ? 30 : 50,
width: top < 150 ? 30 : 50,
imageUrl: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTdQLwDqDwd2JfzifvfBTFT8I7iKFFevcedYg&s",
imageUrl:
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTdQLwDqDwd2JfzifvfBTFT8I7iKFFevcedYg&s",
radius: 90,
backGroundColor: Colors.white,
boxFit: BoxFit.fill,
@@ -75,7 +80,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
child: Container(
height: 18,
width: 18,
decoration: BoxDecoration(color: APPCOLOR.lightGreen, border: Border.all(color: Colors.white), borderRadius: BorderRadius.circular(5)),
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
border: Border.all(
color: Colors.white),
borderRadius:
BorderRadius.circular(5)),
child: Center(
child: Icon(
MdiIcons.pencil,
@@ -97,11 +107,15 @@ class _ProfileScreenState extends State<ProfileScreen> {
children: [
Text(
"Smith Mate",
style: context.customExtraBold(top < 100 ? Colors.black : Colors.white, 14),
style: context.customExtraBold(
top < 100 ? Colors.black : Colors.white,
14),
),
Text(
'smithmate@example.com',
style: context.customRegular(top < 100 ? Colors.black : Colors.white, 10),
style: context.customRegular(
top < 100 ? Colors.black : Colors.white,
10),
)
],
),
@@ -114,7 +128,11 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
background: Container(
height: 200,
decoration: BoxDecoration(color: APPCOLOR.lightGreen, borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(30), bottomRight: Radius.circular(30))),
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30))),
));
}),
),
@@ -122,6 +140,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
},
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
@@ -238,27 +257,39 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
),
),
Container(
margin: const EdgeInsets.only(left: 15, right: 15, top: 10, bottom: 10),
height: 50,
width: MediaQuery.sizeOf(context).width,
decoration: BoxDecoration(color: APPCOLOR.lightGreen, borderRadius: BorderRadius.circular(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
MdiIcons.logout,
color: Colors.white,
),
const SizedBox(
width: 10,
),
Text(
"Logout",
style: context.customMedium(Colors.white, 16),
),
],
InkWell(
onTap: ()
{
print("fjnghkjfjghj");
Provider.of<ProductProvider>(context, listen: false)
.customerLogOut(context);
},
child: Container(
margin: const EdgeInsets.only(
left: 15, right: 15, top: 10, bottom: 10),
height: 50,
width: MediaQuery.sizeOf(context).width,
decoration: BoxDecoration(
color: APPCOLOR.lightGreen,
borderRadius: BorderRadius.circular(10)),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
MdiIcons.logout,
color: Colors.white,
),
const SizedBox(
width: 10,
),
Text(
"Logout",
style: context.customMedium(Colors.white, 16),
),
],
),
),
),
],