From 9bdbaa85e1b61deeb22b96e5f2d38085d8587064 Mon Sep 17 00:00:00 2001
From: Mikkel Troels Kongsted <mtkongsted@gmail.com>
Date: Wed, 5 Feb 2025 11:15:33 +0100
Subject: [PATCH] add more products

---
 mobile/lib/pages/all_products_page.dart | 30 +++++-----
 mobile/lib/pages/cart_page.dart         |  2 +-
 mobile/lib/pages/product_page.dart      |  4 +-
 mobile/lib/repos/product.dart           | 76 ++++++++++++++++++-------
 4 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/mobile/lib/pages/all_products_page.dart b/mobile/lib/pages/all_products_page.dart
index 0f525a6..06041be 100644
--- a/mobile/lib/pages/all_products_page.dart
+++ b/mobile/lib/pages/all_products_page.dart
@@ -45,7 +45,7 @@ class ProductListItem extends StatelessWidget {
                       topRight: Radius.circular(10),
                       bottomRight: Radius.circular(10)),
                   child: Ink.image(
-                    image: AssetImage(imagePath),
+                    image: const AssetImage("assets/boykisser.png"),
                     fit: BoxFit.contain,
                     width: 100,
                   ))
@@ -76,19 +76,21 @@ class AllProductsPage extends StatelessWidget {
                 ),
               ],
             ),
-            Consumer<ProductRepo>(builder: (_, productRepo, __) {
-              final products = productRepo.allProducts();
-              return ListView.builder(
-                shrinkWrap: true,
-                itemBuilder: (_, idx) => ProductListItem(
-                  name: products[idx].name,
-                  price: products[idx].price,
-                  imagePath: "assets/${products[idx].name}.png",
-                  productPage: ProductPage(product: products[idx]),
-                ),
-                itemCount: products.length,
-              );
-            }),
+            Expanded(
+              child: Consumer<ProductRepo>(builder: (_, productRepo, __) {
+                final products = productRepo.allProducts();
+                return ListView.builder(
+                  shrinkWrap: true,
+                  itemBuilder: (_, idx) => ProductListItem(
+                    name: products[idx].name,
+                    price: products[idx].price,
+                    imagePath: "assets/${products[idx].name}.png",
+                    productPage: ProductPage(product: products[idx]),
+                  ),
+                  itemCount: products.length,
+                );
+              }),
+            ),
           ]),
         ),
       ],
diff --git a/mobile/lib/pages/cart_page.dart b/mobile/lib/pages/cart_page.dart
index 51c11f3..96818a6 100644
--- a/mobile/lib/pages/cart_page.dart
+++ b/mobile/lib/pages/cart_page.dart
@@ -148,7 +148,7 @@ class CartPage extends StatelessWidget {
                     productId: cart[idx].product.id,
                     name: cart[idx].product.name,
                     price: cart[idx].product.price,
-                    imagePath: "assets/${cart[idx].product.name}.png",
+                    imagePath: "assets/boykisser.png",
                     amount: cart[idx].amount),
                 itemCount: cart.length,
               );
diff --git a/mobile/lib/pages/product_page.dart b/mobile/lib/pages/product_page.dart
index 60c4c73..3834c67 100644
--- a/mobile/lib/pages/product_page.dart
+++ b/mobile/lib/pages/product_page.dart
@@ -52,8 +52,8 @@ class ProductPage extends StatelessWidget {
                 child: Column(
                   crossAxisAlignment: CrossAxisAlignment.stretch,
                   children: [
-                    Image(
-                      image: AssetImage("assets/${product.name}.png"),
+                    const Image(
+                      image: AssetImage("assets/boykisser.png"),
                       height: 250,
                       fit: BoxFit.fitHeight,
                     ),
diff --git a/mobile/lib/repos/product.dart b/mobile/lib/repos/product.dart
index 2d80715..08db4f0 100644
--- a/mobile/lib/repos/product.dart
+++ b/mobile/lib/repos/product.dart
@@ -1,33 +1,69 @@
 import 'package:flutter/material.dart';
 
 class ProductRepo extends ChangeNotifier {
-  final List<Product> _products = [
-    Product(
-        id: 0,
-        name: "Minimælk",
-        price: 12,
-        description: "Konventionel minimælk med fedtprocent på 0,4%"),
-    Product(
-        id: 1,
-        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 💪")
-  ];
+  int _nextId = 0;
+  List<Product> products = [];
+  ProductRepo() {
+    _addAllProducts();
+  }
+
+  int getNextId() {
+    return _nextId++;
+  }
 
   List<Product> allProducts() {
-    return _products;
+    return products;
   }
 
   void changePrice(int idx, int price) {
-    _products[idx].price = price;
+    products[idx].price = price;
     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 {