From 3ef71f681eeb1a832bbd0f95d01958617529bae7 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 19 Oct 2017 12:04:37 +0200 Subject: Refactoring styled component Form controls: input, password, checkbox --- src/main/kotlin/pl/treksoft/kvision/Showcase.kt | 50 +++- src/main/kotlin/pl/treksoft/kvision/core/Css.kt | 290 ++++++++++++++++++++ .../kotlin/pl/treksoft/kvision/core/KVManager.kt | 1 + .../pl/treksoft/kvision/core/StyledComponent.kt | 5 - src/main/kotlin/pl/treksoft/kvision/css/Css.kt | 291 --------------------- .../pl/treksoft/kvision/dropdown/DropDown.kt | 10 +- .../kotlin/pl/treksoft/kvision/form/CheckBox.kt | 110 ++++++++ .../pl/treksoft/kvision/form/CheckBoxInput.kt | 78 ++++++ .../kotlin/pl/treksoft/kvision/form/FieldLabel.kt | 14 + .../kotlin/pl/treksoft/kvision/form/FormField.kt | 27 ++ .../kotlin/pl/treksoft/kvision/form/Password.kt | 6 + src/main/kotlin/pl/treksoft/kvision/form/Text.kt | 75 ++++++ .../kotlin/pl/treksoft/kvision/form/TextInput.kt | 136 ++++++++++ src/main/kotlin/pl/treksoft/kvision/html/Button.kt | 13 +- src/main/kotlin/pl/treksoft/kvision/html/Tag.kt | 1 + .../kotlin/pl/treksoft/kvision/panel/SplitPanel.kt | 2 +- src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt | 4 +- 17 files changed, 792 insertions(+), 321 deletions(-) create mode 100644 src/main/kotlin/pl/treksoft/kvision/core/Css.kt delete mode 100644 src/main/kotlin/pl/treksoft/kvision/css/Css.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/CheckBox.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/CheckBoxInput.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/FieldLabel.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/FormField.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/Password.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/Text.kt create mode 100644 src/main/kotlin/pl/treksoft/kvision/form/TextInput.kt (limited to 'src/main/kotlin/pl') diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt index ab88be28..bf0691e1 100644 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt @@ -1,18 +1,15 @@ package pl.treksoft.kvision import pl.treksoft.kvision.basic.Label -import pl.treksoft.kvision.core.Container -import pl.treksoft.kvision.core.Img -import pl.treksoft.kvision.core.Root -import pl.treksoft.kvision.css.BGATTACH -import pl.treksoft.kvision.css.BGREPEAT -import pl.treksoft.kvision.css.BGSIZE -import pl.treksoft.kvision.css.BORDERSTYLE -import pl.treksoft.kvision.css.Background -import pl.treksoft.kvision.css.Border -import pl.treksoft.kvision.css.COLOR +import pl.treksoft.kvision.core.* import pl.treksoft.kvision.dropdown.DD.* import pl.treksoft.kvision.dropdown.DropDown +import pl.treksoft.kvision.form.CHECKBOXSTYLE +import pl.treksoft.kvision.form.CheckBox +import pl.treksoft.kvision.form.INPUTSIZE +import pl.treksoft.kvision.form.TEXTINPUTTYPE +import pl.treksoft.kvision.form.Text +import pl.treksoft.kvision.form.TextInput import pl.treksoft.kvision.html.* import pl.treksoft.kvision.html.TAG.DIV import pl.treksoft.kvision.html.TAG.H1 @@ -44,6 +41,37 @@ class Showcase : ApplicationBase() { link.add(Tag(TAG.P, "Cośtam")) root.add(link) + val textField = TextInput(placeholder = "Wprowadź hasło ...", value = "abc") + root.add(textField) + textField.setEventListener { + input = { e -> + println("i" + self.value) + } + change = { e -> + println("c" + self.value) + } + } + val passwordField = TextInput(TEXTINPUTTYPE.PASSWORD) + root.add(passwordField) + + val textField2 = TextInput(placeholder = "Disabled") + textField2.disabled = true + textField2.size = INPUTSIZE.LARGE + root.add(textField2) + + val checkbox = CheckBox(true, label = "Kliknij aby przetestować", rich = true, circled = true, + style = CHECKBOXSTYLE.DANGER) + root.add(checkbox) + checkbox.setEventListener { + click = { e -> + println("click" + self.value) + } + change = { e -> println("change" + self.value) } + } + + val text = Text(placeholder = "Pole formularza", maxlength = 5, label = "To jest pole") + root.add(text) + val dd = DropDown("Dropdown", listOf("abc" to "#!/x", "def" to "#!/y"), "flag") root.add(dd) dd.setEventListener { @@ -206,6 +234,8 @@ class Showcase : ApplicationBase() { button.setEventListener