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 @@ + + + + + + + + + + + + + + + + + + +