mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-28 00:34:06 +02:00
add more products
This commit is contained in:
parent
a5502810cd
commit
9bdbaa85e1
@ -45,7 +45,7 @@ class ProductListItem extends StatelessWidget {
|
|||||||
topRight: Radius.circular(10),
|
topRight: Radius.circular(10),
|
||||||
bottomRight: Radius.circular(10)),
|
bottomRight: Radius.circular(10)),
|
||||||
child: Ink.image(
|
child: Ink.image(
|
||||||
image: AssetImage(imagePath),
|
image: const AssetImage("assets/boykisser.png"),
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
width: 100,
|
width: 100,
|
||||||
))
|
))
|
||||||
@ -76,19 +76,21 @@ class AllProductsPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Consumer<ProductRepo>(builder: (_, productRepo, __) {
|
Expanded(
|
||||||
final products = productRepo.allProducts();
|
child: Consumer<ProductRepo>(builder: (_, productRepo, __) {
|
||||||
return ListView.builder(
|
final products = productRepo.allProducts();
|
||||||
shrinkWrap: true,
|
return ListView.builder(
|
||||||
itemBuilder: (_, idx) => ProductListItem(
|
shrinkWrap: true,
|
||||||
name: products[idx].name,
|
itemBuilder: (_, idx) => ProductListItem(
|
||||||
price: products[idx].price,
|
name: products[idx].name,
|
||||||
imagePath: "assets/${products[idx].name}.png",
|
price: products[idx].price,
|
||||||
productPage: ProductPage(product: products[idx]),
|
imagePath: "assets/${products[idx].name}.png",
|
||||||
),
|
productPage: ProductPage(product: products[idx]),
|
||||||
itemCount: products.length,
|
),
|
||||||
);
|
itemCount: products.length,
|
||||||
}),
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -148,7 +148,7 @@ class CartPage extends StatelessWidget {
|
|||||||
productId: cart[idx].product.id,
|
productId: cart[idx].product.id,
|
||||||
name: cart[idx].product.name,
|
name: cart[idx].product.name,
|
||||||
price: cart[idx].product.price,
|
price: cart[idx].product.price,
|
||||||
imagePath: "assets/${cart[idx].product.name}.png",
|
imagePath: "assets/boykisser.png",
|
||||||
amount: cart[idx].amount),
|
amount: cart[idx].amount),
|
||||||
itemCount: cart.length,
|
itemCount: cart.length,
|
||||||
);
|
);
|
||||||
|
@ -52,8 +52,8 @@ class ProductPage extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Image(
|
const Image(
|
||||||
image: AssetImage("assets/${product.name}.png"),
|
image: AssetImage("assets/boykisser.png"),
|
||||||
height: 250,
|
height: 250,
|
||||||
fit: BoxFit.fitHeight,
|
fit: BoxFit.fitHeight,
|
||||||
),
|
),
|
||||||
|
@ -1,33 +1,69 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ProductRepo extends ChangeNotifier {
|
class ProductRepo extends ChangeNotifier {
|
||||||
final List<Product> _products = [
|
int _nextId = 0;
|
||||||
Product(
|
List<Product> products = [];
|
||||||
id: 0,
|
ProductRepo() {
|
||||||
name: "Minimælk",
|
_addAllProducts();
|
||||||
price: 12,
|
}
|
||||||
description: "Konventionel minimælk med fedtprocent på 0,4%"),
|
|
||||||
Product(
|
int getNextId() {
|
||||||
id: 1,
|
return _nextId++;
|
||||||
name: "Letmælk",
|
}
|
||||||
price: 13,
|
|
||||||
description: "Konventionel letmælk med fedtprocent på 1,5%"),
|
|
||||||
Product(
|
|
||||||
id: 2,
|
|
||||||
name: "Frilands Øko Supermælk",
|
|
||||||
price: 20,
|
|
||||||
description:
|
|
||||||
"Økologisk mælk af frilandskøer med fedtprocent på 3,5%. Ikke homogeniseret eller pasteuriseret. Skaber store muskler og styrker knoglerne 💪")
|
|
||||||
];
|
|
||||||
|
|
||||||
List<Product> allProducts() {
|
List<Product> allProducts() {
|
||||||
return _products;
|
return products;
|
||||||
}
|
}
|
||||||
|
|
||||||
void changePrice(int idx, int price) {
|
void changePrice(int idx, int price) {
|
||||||
_products[idx].price = price;
|
products[idx].price = price;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _addAllProducts() {
|
||||||
|
products = [
|
||||||
|
Product(
|
||||||
|
id: _nextId++,
|
||||||
|
name: "Minimælk",
|
||||||
|
price: 12,
|
||||||
|
description: "Konventionel minimælk med fedtprocent på 0,4%"),
|
||||||
|
Product(
|
||||||
|
id: _nextId++,
|
||||||
|
name: "Letmælk",
|
||||||
|
price: 13,
|
||||||
|
description: "Konventionel letmælk med fedtprocent på 1,5%"),
|
||||||
|
Product(
|
||||||
|
id: _nextId++,
|
||||||
|
name: "Frilands Øko Supermælk",
|
||||||
|
price: 20,
|
||||||
|
description:
|
||||||
|
"Økologisk mælk af frilandskøer med fedtprocent på 3,5%. Ikke homogeniseret eller pasteuriseret. Skaber store muskler og styrker knoglerne 💪"),
|
||||||
|
Product(
|
||||||
|
id: _nextId++,
|
||||||
|
name: "Øko Gulerødder 1 kg",
|
||||||
|
price: 10,
|
||||||
|
description: ""),
|
||||||
|
Product(id: _nextId++, name: "Øko Agurk", price: 10, description: ""),
|
||||||
|
Product(id: _nextId++, name: "Æbler 1 kg", price: 10, description: ""),
|
||||||
|
Product(id: _nextId++, name: "Basmati Ris", price: 20, description: ""),
|
||||||
|
Product(id: _nextId++, name: "Haribo Mix", price: 30, description: ""),
|
||||||
|
Product(id: _nextId++, name: "Smør", price: 30, description: ""),
|
||||||
|
Product(id: _nextId++, name: "Harboe Cola", price: 5, description: ""),
|
||||||
|
Product(
|
||||||
|
id: _nextId++,
|
||||||
|
name: "Monster Energi Drik",
|
||||||
|
price: 20,
|
||||||
|
description: ""),
|
||||||
|
Product(id: _nextId++, name: "Spaghetti", price: 10, description: ""),
|
||||||
|
Product(id: _nextId++, name: "Æbler 1 kg", price: 20, description: ""),
|
||||||
|
Product(id: _nextId++, name: "Rød Cecil", price: 60, description: ""),
|
||||||
|
Product(
|
||||||
|
id: _nextId++,
|
||||||
|
name: "Jägermeister 750 ml",
|
||||||
|
price: 60,
|
||||||
|
description: ""),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Product {
|
class Product {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user