Skip to content
Snippets Groups Projects
Commit 043ab5b2 authored by Aayush's avatar Aayush
Browse files

Changes Home Screen Firebase

parent d5180020
No related branches found
No related tags found
1 merge request!3Main product
......@@ -4,14 +4,12 @@ import 'package:food_app/models/product_model.dart';
class ProductProvider with ChangeNotifier {
List<ProductModel> herbsProductList = [];
List<ProductModel> freshProductList = [];
List<ProductModel> rootProductList = [];
ProductModel productModel;
fetchHerbsProductData() async {
List<ProductModel> newList = [];
QuerySnapshot value =
await FirebaseFirestore.instance.collection("HerbsProduct ").get();
await FirebaseFirestore.instance.collection("HerbsProduct").get();
value.docs.forEach(
(element) {
productModel = ProductModel(
......@@ -30,12 +28,13 @@ class ProductProvider with ChangeNotifier {
return herbsProductList;
}
List<ProductModel> freshProductList = [];
fetchFreshProductData() async {
List<ProductModel> newList = [];
QuerySnapshot value = await FirebaseFirestore.instance
.collection("FreshFruitsProduct ")
.get();
QuerySnapshot value =
await FirebaseFirestore.instance.collection("FreshFruitsProduct").get();
value.docs.forEach(
(element) {
......@@ -55,11 +54,13 @@ class ProductProvider with ChangeNotifier {
return freshProductList;
}
List<ProductModel> rootProductList = [];
fetchRootProductData() async {
List<ProductModel> newList = [];
QuerySnapshot value = await FirebaseFirestore.instance
.collection("RootVegetablesProduct ")
.collection("RootVegetablesProduct")
.get();
value.docs.forEach(
......
......@@ -37,27 +37,28 @@ class _HomeScreenState extends State<HomeScreen> {
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: productProvider.getHerbsProductDataList.map((herbsProductData) {
return SingleProduct(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ProductOverview(
productPrice: herbsProductData.productPrice,
productName: herbsProductData.productName,
productImage:
herbsProductData.productImage,
children: productProvider.getHerbsProductDataList.map(
(herbsProductData) {
return SingleProduct(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ProductOverview(
productImage: herbsProductData.productImage,
productName: herbsProductData.productName,
productPrice: herbsProductData.productPrice,
),
),
),
);
},
productPrice: herbsProductData.productPrice,
productImage:
herbsProductData.productImage,
productName: herbsProductData.productName,
);
},
).toList(),
);
},
productImage: herbsProductData.productImage,
productName: herbsProductData.productName,
productPrice: herbsProductData.productPrice,
);
},
).toList(),
// children: [
// ],
......@@ -87,27 +88,27 @@ class _HomeScreenState extends State<HomeScreen> {
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: productProvider.getFreshProductDataList.map((freshProductData) {
return SingleProduct(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ProductOverview(
productPrice: freshProductData.productPrice,
productName: freshProductData.productName,
productImage:
freshProductData.productImage,
children: productProvider.getFreshProductDataList.map(
(freshProductData) {
return SingleProduct(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ProductOverview(
productImage: freshProductData.productImage,
productName: freshProductData.productName,
productPrice: freshProductData.productPrice,
),
),
),
);
},
productPrice: freshProductData.productPrice,
productImage:
freshProductData.productImage,
productName: freshProductData.productName,
);
},
).toList(),
);
},
productImage: freshProductData.productImage,
productName: freshProductData.productName,
productPrice: freshProductData.productPrice,
);
},
).toList(),
),
),
],
......@@ -134,27 +135,27 @@ class _HomeScreenState extends State<HomeScreen> {
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: productProvider.getRootProductDataList.map((rootProductData) {
return SingleProduct(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ProductOverview(
productPrice: rootProductData.productPrice,
productName: rootProductData.productName,
productImage:
rootProductData.productImage,
children: productProvider.getRootProductDataList.map(
(rootProductData) {
return SingleProduct(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ProductOverview(
productImage: rootProductData.productImage,
productName: rootProductData.productName,
productPrice: rootProductData.productPrice,
),
),
),
);
},
productPrice: rootProductData.productPrice,
productImage:
rootProductData.productImage,
productName: rootProductData.productName,
);
},
).toList(),
);
},
productImage: rootProductData.productImage,
productName: rootProductData.productName,
productPrice: rootProductData.productPrice,
);
},
).toList(),
),
),
],
......@@ -165,6 +166,8 @@ class _HomeScreenState extends State<HomeScreen> {
void initState() {
ProductProvider productProvider = Provider.of(context, listen: false);
productProvider.fetchHerbsProductData();
productProvider.fetchFreshProductData();
productProvider.fetchRootProductData();
super.initState();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment