package GUI;

import javafx.fxml.FXML;
import javafx.geometry.HPos;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import model.SOMLayout;

/**
 * Controller for upload.fxml UI
 * Created by Simon on 10.05.2016.
 */
public class UploadCtl {


    @FXML
    public ProgressBar folderProgressBar;
    @FXML
    public ProgressBar pictureProgressBar;
    @FXML
    public ProgressBar cleanProgressBar;
    @FXML
    public ImageView folderImageView;
    @FXML
    public ImageView pictureImageView;
    @FXML
    public ImageView cleanImageView;
    @FXML
    public Label headLabel;
    @FXML
    public Label folderLabel;
    @FXML
    public Label picLabel;
    @FXML
    public Label cleanLabel;
    @FXML
    private Pane pane;
    @FXML
    private GridPane grid;

    public UploadCtl() {

    }

    /**
     * Set Up the UI
     * each part of the UI is accessed via the Setter
     */
    public void initialize() {
//        Set up the Upload UI parts

//        basic structure
        setPane();
        setGrid();

//        headline
        setHeadLbl();

//        folder row
        setFolderIV();
        setFolderLbl();
        setFolderProg();

//        picture row
        setPicIV();
        setPicLbl();
        setPicProg();

//        cleanup row
        setCleanIV();
        setCleanLbl();
        setCleanProg();
    }

    private void setPane() {
        pane.setPrefSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
        pane.setBackground(SOMLayout.BLACK_BG);
    }

    private void setGrid() {
        grid.setPrefSize(SOMLayout.screenWidth, SOMLayout.screenHeight);
        GridPane.setHalignment(folderImageView, HPos.CENTER);
        GridPane.setHalignment(folderLabel, HPos.CENTER);
        GridPane.setHalignment(folderProgressBar, HPos.CENTER);

        GridPane.setHalignment(pictureImageView, HPos.CENTER);
        GridPane.setHalignment(picLabel, HPos.CENTER);
        GridPane.setHalignment(pictureProgressBar, HPos.CENTER);

        GridPane.setHalignment(cleanImageView, HPos.CENTER);
        GridPane.setHalignment(cleanLabel, HPos.CENTER);
        GridPane.setHalignment(cleanProgressBar, HPos.CENTER);

        GridPane.setHalignment(headLabel, HPos.CENTER);
    }

    private void setFolderProg() {
        folderProgressBar.setPrefSize(SOMLayout.screenWidth, 3);
    }

    private void setPicProg() {
        pictureProgressBar.setPrefSize(SOMLayout.screenWidth, 3);
    }

    private void setCleanProg() {
        cleanProgressBar.setPrefSize(SOMLayout.screenWidth, 3);
    }

    private void setFolderIV() {
        folderImageView.setImage(SOMLayout.GALLERY_IMAGE);
    }

    private void setPicIV() {
        folderImageView.setImage(SOMLayout.GALLERY_IMAGE);
    }

    private void setCleanIV() {
        folderImageView.setImage(SOMLayout.GALLERY_IMAGE);
    }

    private void setHeadLbl() {
        headLabel.setTextFill(Color.web("#ffffff"));
    }

    private void setFolderLbl() {
        folderLabel.setTextFill(Color.web("#ffffff"));
    }

    private void setPicLbl() {
        picLabel.setTextFill(Color.web("#ffffff"));
    }

    private void setCleanLbl() {
        cleanLabel.setTextFill(Color.web("#ffffff"));
    }

    //    set the progress
//    public void setFolderProgress(double value) {
//        folderProgressBar.setProgress(value);
//        System.out.println("Folder Progress set to: "+ value);
//    }

    public void setPicProgress(double value) {
        pictureProgressBar.setProgress(value);
    }

    public void setCleanProgress(double value) {
        pictureProgressBar.setProgress(value);
    }
}
