diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-09-25 10:30:25 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-09-25 10:31:27 +0200 |
commit | 089447dd370314276531836e39afa2224eb8f6b8 (patch) | |
tree | ce26e9cee19bcdae06fb7c39a1b1fab344dce95d /src/main/kotlin/pl/treksoft/kvision/html | |
parent | 726a42ad5643840f84c289c9a6b56d6c3c9067b4 (diff) | |
download | kvision-089447dd370314276531836e39afa2224eb8f6b8.tar.gz kvision-089447dd370314276531836e39afa2224eb8f6b8.tar.bz2 kvision-089447dd370314276531836e39afa2224eb8f6b8.zip |
Code style fixes
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Image.kt | 10 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Link.kt | 8 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/List.kt | 27 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Tag.kt | 3 |
4 files changed, 23 insertions, 25 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt index a03d673a..c9566531 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Image.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Image.kt @@ -14,27 +14,27 @@ enum class IMAGESHAPE(val className: String) { open class Image(src: ResString, alt: String? = null, responsive: Boolean = false, shape: IMAGESHAPE? = null, centered: Boolean = false, classes: Set<String> = setOf()) : Widget(classes) { - var src = src + private var src = src set(value) { field = value refresh() } - var alt = alt + private var alt = alt set(value) { field = value refresh() } - var responsive = responsive + private var responsive = responsive set(value) { field = value refresh() } - var shape = shape + private var shape = shape set(value) { field = value refresh() } - var centered = centered + private var centered = centered set(value) { field = value refresh() diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt index 4f333482..dc93d0e7 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt @@ -7,22 +7,22 @@ import pl.treksoft.kvision.snabbdom.StringPair open class Link(label: String, url: String, icon: String? = null, image: ResString? = null, classes: Set<String> = setOf()) : Container(classes) { - var label = label + private var label = label set(value) { field = value refresh() } - var url = url + private var url = url set(value) { field = value refresh() } - var icon = icon + private var icon = icon set(value) { field = value refresh() } - var image = image + private var image = image set(value) { field = value refresh() diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt index 24978f8d..c6298ddf 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt @@ -22,12 +22,12 @@ open class ListTag(type: LIST, elements: List<String>? = null, rich: Boolean = f field = value refresh() } - var elements = elements + private var elements = elements set(value) { field = value refresh() } - var rich = rich + private var rich = rich set(value) { field = value refresh() @@ -40,10 +40,10 @@ open class ListTag(type: LIST, elements: List<String>? = null, rich: Boolean = f element(if (index % 2 == 0) "dt" else "dd", el, rich) } }?.toTypedArray() - if (childrenElements != null) { - return kvh(type.tagName, childrenElements + childrenVNodes()) + return if (childrenElements != null) { + kvh(type.tagName, childrenElements + childrenVNodes()) } else { - return kvh(type.tagName, childrenVNodes()) + kvh(type.tagName, childrenVNodes()) } } @@ -69,21 +69,20 @@ open class ListTag(type: LIST, elements: List<String>? = null, rich: Boolean = f } private fun element(name: String, value: String, rich: Boolean): VNode { - if (rich) { - return h(name, arrayOf(KVManager.virtualize("<span>$value</span>"))) + return if (rich) { + h(name, arrayOf(KVManager.virtualize("<span>$value</span>"))) } else { - return h(name, value) + h(name, value) } } override fun getSnClass(): List<StringBoolPair> { val cl = super.getSnClass().toMutableList() - if (type == LIST.UNSTYLED) { - cl.add("list-unstyled" to true) - } else if (type == LIST.INLINE) { - cl.add("list-inline" to true) - } else if (type == LIST.DL_HORIZ) { - cl.add("dl-horizontal" to true) + @Suppress("NON_EXHAUSTIVE_WHEN") + when (type) { + LIST.UNSTYLED -> cl.add("list-unstyled" to true) + LIST.INLINE -> cl.add("list-inline" to true) + LIST.DL_HORIZ -> cl.add("dl-horizontal" to true) } return cl } diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt index 109e5509..cb8330ac 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt @@ -73,7 +73,7 @@ open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: AL } override fun render(): VNode { - val ret = if (text != null) { + return if (text != null) { if (rich) { kvh(type.tagName, arrayOf(KVManager.virtualize("<span>$text</span>")) + childrenVNodes()) } else { @@ -82,7 +82,6 @@ open class Tag(type: TAG, text: String? = null, rich: Boolean = false, align: AL } else { kvh(type.tagName, childrenVNodes()) } - return ret } override fun getSnClass(): List<StringBoolPair> { |