package ch.zhaw.gartenverwaltung;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

import java.net.URL;
import java.util.ResourceBundle;

/**
 * Controller class for the Home.fxml file
 */
public class HomeController implements Initializable {

    @FXML
    private ImageView imageViewDavid;

    @FXML
    private ImageView imageViewElias;

    @FXML
    private ImageView imageViewGian;

    @FXML
    private ImageView imageViewPhilippe;

    @FXML
    private ImageView imageViewRoman;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        setImages(imageViewDavid, "");
        setImages(imageViewElias, "");
        setImages(imageViewGian, "");
        setImages(imageViewRoman, "");
        setImages(imageViewPhilippe, "");
    }

    /**
     * set image to image view
     * @param imageView the imageView to update
     * @param photoName the file name of the photo
     */
    private void setImages(ImageView imageView, String photoName) {
        Image img;
        if (photoName.equals("")) {
            img = new Image(String.valueOf(getClass().getResource("icons/userIcon.png")));
        } else {
            img = new Image(String.valueOf(getClass().getResource("icons/" + photoName)));
        }
        imageView.setImage(img);
    }
}

