From 8fc31d9aa512627a75b08512c9b97610a5ff1547 Mon Sep 17 00:00:00 2001 From: Natalia Cholewa Date: Tue, 25 Nov 2025 21:14:57 +0100 Subject: [PATCH] feat: ingredients list stub, ingredients list fxml --- .../scenes/recipe/IngredientListCtrl.java | 41 +++++++++++++++++++ .../client/scenes/recipe/IngredientList.fxml | 26 ++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 client/src/main/java/client/scenes/recipe/IngredientListCtrl.java create mode 100644 client/src/main/resources/client/scenes/recipe/IngredientList.fxml diff --git a/client/src/main/java/client/scenes/recipe/IngredientListCtrl.java b/client/src/main/java/client/scenes/recipe/IngredientListCtrl.java new file mode 100644 index 0000000..63cd5e5 --- /dev/null +++ b/client/src/main/java/client/scenes/recipe/IngredientListCtrl.java @@ -0,0 +1,41 @@ +package client.scenes.recipe; + +import client.utils.ServerUtils; +import commons.Recipe; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.ListView; + +import java.net.URL; +import java.util.ResourceBundle; + +public class IngredientListCtrl implements Initializable { + private Recipe recipe; + + @FXML + ListView ingredientListView; + + public IngredientListCtrl() {} + + public void setRecipe(Recipe recipe) { + this.recipe = recipe; + this.refresh(); + } + + private void refresh() { + if (recipe == null) { + return; + } + + var ingredients = recipe.getIngredients(); + ingredientListView.setItems(FXCollections.observableList(ingredients)); + ingredientListView.refresh(); + } + + @FXML + public void initialize(URL location, ResourceBundle resources) { + this.refresh(); + } +} diff --git a/client/src/main/resources/client/scenes/recipe/IngredientList.fxml b/client/src/main/resources/client/scenes/recipe/IngredientList.fxml new file mode 100644 index 0000000..840f55b --- /dev/null +++ b/client/src/main/resources/client/scenes/recipe/IngredientList.fxml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + +