package org.hso.texturesyncclient.view.mainView

import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXChipView
import javafx.geometry.Insets
import javafx.geometry.Orientation
import javafx.geometry.Pos
import javafx.scene.control.Label
import javafx.scene.image.Image
import javafx.scene.layout.Background
import javafx.scene.layout.BackgroundFill
import javafx.scene.layout.CornerRadii
import javafx.scene.paint.Paint
import tornadofx.*

class DetailView: View() {

    val preview = Preview3D()
    val metaLabel = Label("Auflösung: 8MP\nName: Texture.png\nAndere: was anderes")
    val cvTags = JFXChipView<String>()
    val btnImport = JFXButton("+")

    init {
        // set a default texture
        preview.setTexture(Image("textures/sample_texture_1.jpg"))
    }

    override val root = form {
        minWidth = 250.0
        background = Background(BackgroundFill(Paint.valueOf("#9f9f9f"), CornerRadii.EMPTY, Insets.EMPTY))

        fieldset(labelPosition = Orientation.VERTICAL) {

            field{
                vbox(7) {
                    add(preview)
                }
            }

            field("Meta") {
                add(metaLabel)
            }

            field {
                minHeight = 145.0
                add(cvTags)

            }

            field {
                hbox(alignment = Pos.CENTER_RIGHT) {
                    add(btnImport)
                }
            }

            // TODO add "Import" Btn
        }

        style {
            cvTags.minHeight = 135.0
            cvTags.paddingAll = 3.0
            cvTags.style = "-fx-background-color: #3c3f41; -fx-text-inner-color: #b15b2e;"

            btnImport.buttonType = JFXButton.ButtonType.RAISED
            // TODO move this to a css file
            btnImport.style = "-fx-background-color: #F1F1F1;\n" +
                    "    -fx-background-radius: 50px;\n" +
                    "    -fx-pref-height: 50px;\n" +
                    "    -fx-pref-width: 50px;\n" +
                    "    -fx-min-width: -fx-pref-width;\n" +
                    "    -fx-max-width: -fx-pref-width;\n" +
                    "    -fx-min-height: -fx-pref-height;\n" +
                    "    -fx-max-height: -fx-pref-height;\n" +
                    "-jfx-button-type: RAISED;"
        }

        btnImport.setOnAction {

        }

    }
}