package org.hso.texturesyncclient.view.importView

import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXChipView
import com.jfoenix.controls.JFXTextField
import javafx.geometry.Pos
import javafx.scene.layout.Background
import javafx.geometry.Insets
import javafx.scene.layout.BackgroundFill
import javafx.scene.layout.CornerRadii
import javafx.scene.paint.Paint
import javafx.scene.control.Label
import javafx.scene.layout.Priority
import javafx.scene.text.Font
import javafx.scene.text.FontWeight
import tornadofx.*

class ImportView : View() {

    val labelHeading = Label("Textur hinzufügen")
    val tfFilePath = JFXTextField()
    val btnFileChooser = JFXButton("Datei öffnen")
    val labelName = Label("Name")
    val tfName = JFXTextField()
    val labelTags = Label("Tags")
    val cvTags = JFXChipView<String>()

    private val ivc: ImportViewController by inject()

    override val root = borderpane {
        minWidth = 1000.0
        minHeight = 500.0
        background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))

        center = vbox(50) {
            maxWidth = 350.0
            alignment = Pos.CENTER

            add(labelHeading)

            vbox(20) {
                hbox(10) {
                    add(tfFilePath)
                    add(btnFileChooser)
                }

                vbox(5) {
                    add(labelName)
                    add(tfName)
                }

                vbox(5) {
                    add(labelTags)
                    add(cvTags)
                }
            }
        }

        style {
            labelHeading.font = Font.font("Verdana", FontWeight.MEDIUM, 40.0)
            labelHeading.textFill = Paint.valueOf("#2b7bbb")

            tfFilePath.promptText = "Pfad zur Datei"
            tfFilePath.hgrow = Priority.ALWAYS
            tfFilePath.style = "-fx-text-fill: #b15b2e;"

            btnFileChooser.style = "-fx-button-type: RAISED; -fx-background-color: #3c3f41; -fx-text-fill: #2b7bbb;"

            labelName.style = "-fx-font: 14px Verdana; -fx-text-fill: #2b7bbb;"

            tfName.promptText = "Name eingeben"
            tfName.style = "-fx-text-fill: #b15b2e;"

            labelTags.style = "-fx-font: 14px Verdana; -fx-text-fill: #2b7bbb;"

            cvTags.style = "-fx-background-color: #3c3f41; -fx-text-inner-color: #b15b2e;"
            //TODO change color of Chip´s

        }

        btnFileChooser.setOnAction {
            ivc.btnFileChooserAction()
        }

    }

}