feat: ingredients list stub, ingredients list fxml

This commit is contained in:
Natalia Cholewa 2025-11-25 21:14:57 +01:00
commit 8fc31d9aa5
2 changed files with 67 additions and 0 deletions

View file

@ -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<String> 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();
}
}

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<AnchorPane xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="client.scenes.recipe.IngredientListCtrl">
<children>
<VBox minHeight="200.0" minWidth="200.0">
<children>
<Label text="Ingredients">
<padding>
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
</padding>
<font>
<Font name="System Bold" size="16.0" />
</font>
</Label>
<ListView fx:id="ingredientListView" prefHeight="200.0" prefWidth="200.0" />
</children>
</VBox>
</children>
</AnchorPane>