From f6dae92f1d2b2850a70d1b2db450ed03a4fd655f Mon Sep 17 00:00:00 2001
From: Lukas Karsch <lk224@hdm-stuttgart.de>
Date: Thu, 11 May 2023 14:02:37 +0200
Subject: [PATCH] idk

---
 src/main/java/mi/hdm/TastyPages.java          |  5 +-
 .../hdm/controllers/RecipeViewController.java |  3 +
 src/main/java/mi/hdm/controllers/View.java    |  2 +-
 src/main/java/module-info.java                |  1 +
 src/main/resources/fxml/recipe-view.fxml      |  2 +-
 .../resources/fxml/shoppingList-view.fxml     | 57 +++++++++++--------
 6 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/src/main/java/mi/hdm/TastyPages.java b/src/main/java/mi/hdm/TastyPages.java
index 4c95697..66532d8 100644
--- a/src/main/java/mi/hdm/TastyPages.java
+++ b/src/main/java/mi/hdm/TastyPages.java
@@ -24,6 +24,7 @@ public class TastyPages extends Application {
         log.info("Starting TastyPages");
 
         recipeManager.addRecipe(new Recipe("Mein erstes Rezept", Map.of(new Ingredient(Measurement.GRAM, "Mehl", new NutritionTable(100, 20, 8, 14, 2.5, 3)), 100), "Description", List.of("joa"), List.of(), 40));
+        recipeManager.addRecipe(new Recipe("Mein letztes Rezept", Map.of(new Ingredient(Measurement.GRAM, "Zucker", new NutritionTable(100, 500, 8, 14, 2.5, 3)), 100), "Description", List.of("joa"), List.of(), 40));
 
         launch(args);
     }
@@ -40,10 +41,10 @@ public class TastyPages extends Application {
     public void start(Stage stage) throws IOException {
         TastyPages.stage = stage;
 
-        Parent parent = View.RECIPE_VIEW.getScene();
+        Parent parent = View.SHOPPINGLIST_VIEW.getScene();
         final Scene scene = new Scene(parent, 1400, 800);
 
-        stage.setTitle("View Recipe");
+        stage.setTitle("Shopping List");
         stage.setMaximized(true); //open scene in full screen
         stage.setScene(scene);
         stage.show();
diff --git a/src/main/java/mi/hdm/controllers/RecipeViewController.java b/src/main/java/mi/hdm/controllers/RecipeViewController.java
index fb6d2ec..86802c3 100644
--- a/src/main/java/mi/hdm/controllers/RecipeViewController.java
+++ b/src/main/java/mi/hdm/controllers/RecipeViewController.java
@@ -43,6 +43,9 @@ public class RecipeViewController extends BaseController {
             Label recipeDescription = new Label(recipe.getDescription());
             VBox currentRecipeBox = new VBox(recipeName, recipeDescription);
 
+            currentRecipeBox.setPrefWidth(180);
+            currentRecipeBox.setPrefHeight(250);
+
             recipeTilePane.getChildren().add(currentRecipeBox);
         }
     }
diff --git a/src/main/java/mi/hdm/controllers/View.java b/src/main/java/mi/hdm/controllers/View.java
index cefb870..043c04c 100644
--- a/src/main/java/mi/hdm/controllers/View.java
+++ b/src/main/java/mi/hdm/controllers/View.java
@@ -12,7 +12,6 @@ import org.apache.logging.log4j.Logger;
 import java.io.IOException;
 
 public enum View {
-
     MAIN("/fxml/hello.fxml", "Tasty Pages"),
     RECIPE_VIEW("/fxml/recipe-view.fxml", "Tasty Pages - Recipe View"),
     SHOPPINGLIST_VIEW("/fxml/shoppingList-view.fxml", "Tasty Pages - Shopping List View");
@@ -35,6 +34,7 @@ public enum View {
         final FXMLLoader loader = new FXMLLoader(getClass().getResource(path));
         log.debug("Successfully retrieved resource from {}", path);
 
+        //set the correct controller factory for views (necessary to enable dependency injection)
         switch (this) {
             case MAIN -> loader.setControllerFactory((callback) ->
                     new HelloController()
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index 88136f3..8f11b3e 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -8,5 +8,6 @@ module gui {
 
     exports mi.hdm;
     exports mi.hdm.controllers;
+    exports mi.hdm.shoppingList;
     exports mi.hdm.recipes;
 }
\ No newline at end of file
diff --git a/src/main/resources/fxml/recipe-view.fxml b/src/main/resources/fxml/recipe-view.fxml
index fd7870a..2ea9e1f 100644
--- a/src/main/resources/fxml/recipe-view.fxml
+++ b/src/main/resources/fxml/recipe-view.fxml
@@ -31,7 +31,7 @@
         </GridPane>
 
 
-        <TilePane fx:id="recipeTilePane" alignment="TOP_CENTER" prefHeight="333.0" prefWidth="675.0">
+        <TilePane fx:id="recipeTilePane" prefHeight="333.0" prefWidth="675.0">
             <padding>
                 <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
             </padding>
diff --git a/src/main/resources/fxml/shoppingList-view.fxml b/src/main/resources/fxml/shoppingList-view.fxml
index 514b958..287a8cf 100644
--- a/src/main/resources/fxml/shoppingList-view.fxml
+++ b/src/main/resources/fxml/shoppingList-view.fxml
@@ -2,35 +2,44 @@
 
 <?import javafx.scene.control.*?>
 <?import javafx.scene.layout.*?>
-<?import javafx.scene.text.*?>
-
-<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="mi.hdm.controllers.ShoppingListViewController">
-   <children>
-      <ToolBar prefHeight="40.0" prefWidth="606.0" style="-fx-background-color: FFFFFF;">
-         <items>
-            <MenuButton contentDisplay="CENTER" mnemonicParsing="false" style="-fx-background-color: FFFFFF; -fx-border-color: D91C1C; -fx-border-radius: 10; -fx-border-width: 2;" text="Menu">
-              <items>
-                <MenuItem mnemonicParsing="false" text="Meal Plan" />
-                <MenuItem mnemonicParsing="false" text="Shopping List" />
-              </items>
-               <font>
-                  <Font name="Inter Regular" size="12.0" />
-               </font>
-            </MenuButton>
+<?import javafx.scene.text.Font?>
+<AnchorPane prefHeight="540.0" prefWidth="872.0" xmlns="http://javafx.com/javafx/17.0.2-ea"
+            xmlns:fx="http://javafx.com/fxml/1" fx:controller="mi.hdm.controllers.ShoppingListViewController">
+    <children>
+        <ToolBar prefHeight="40.0" prefWidth="606.0" style="-fx-background-color: FFFFFF;" AnchorPane.leftAnchor="0.0"
+                 AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
+            <items>
+                <MenuButton contentDisplay="CENTER" mnemonicParsing="false"
+                            style="-fx-background-color: FFFFFF; -fx-border-color: D91C1C; -fx-border-radius: 10; -fx-border-width: 2;"
+                            text="Menu">
+                    <items>
+                        <MenuItem mnemonicParsing="false" text="Meal Plan"/>
+                        <MenuItem mnemonicParsing="false" text="Shopping List"/>
+                    </items>
+                    <font>
+                        <Font name="Inter Regular" size="12.0"/>
+                    </font>
+                </MenuButton>
             <TextField alignment="CENTER" editable="false" style="-fx-background-color: FFFFFF;" text="Tasty Pages">
                <font>
                   <Font name="Inter Regular" size="12.0" />
                </font>
             </TextField>
          </items></ToolBar>
-      <SplitPane fx:id="shoppingListSplitPane" dividerPositions="0.6341059602649006" layoutY="40.0" mouseTransparent="true" prefHeight="360.0" prefWidth="606.0" style="-fx-background-color: FFFFFF;">
-        <items>
-          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="360.0" prefWidth="379.0" style="-fx-background-color: FFFFFF; -fx-border-color: D91C1C; -fx-border-radius: 10; -fx-border-width: 4; -fx-border-insets: 15;">
-               <children>
-                  <CheckBox layoutX="78.0" layoutY="42.0" mnemonicParsing="false" prefHeight="17.0" prefWidth="199.0" text="Ingredient1" />
-               </children></AnchorPane>
-          <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="259.0" prefWidth="223.0" style="-fx-background-color: FFFFFF; -fx-border-color: D91C1C; -fx-border-width: 4; -fx-border-radius: 10; -fx-border-insets: 15;" />
-        </items>
-      </SplitPane>
+        <SplitPane fx:id="shoppingListSplitPane" dividerPositions="0.6341059602649006" layoutY="40.0"
+                   mouseTransparent="true" prefHeight="360.0" prefWidth="606.0" style="-fx-background-color: FFFFFF;"
+                   AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
+            <items>
+                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="360.0" prefWidth="379.0"
+                            style="-fx-background-color: FFFFFF; -fx-border-color: D91C1C; -fx-border-radius: 10; -fx-border-width: 4; -fx-border-insets: 15;">
+                    <children>
+                        <CheckBox layoutX="78.0" layoutY="42.0" mnemonicParsing="false" prefHeight="17.0"
+                                  prefWidth="199.0" text="Ingredient1"/>
+                    </children>
+                </AnchorPane>
+                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="259.0" prefWidth="223.0"
+                            style="-fx-background-color: FFFFFF; -fx-border-color: D91C1C; -fx-border-width: 4; -fx-border-radius: 10; -fx-border-insets: 15;"/>
+            </items>
+        </SplitPane>
    </children>
 </AnchorPane>
-- 
GitLab