From bafcdb6fc3f1d4ec4f1a0f4fcce776ba10d8136c Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 12 Feb 2018 10:50:42 +0100 Subject: Type safe DSL builders --- src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt') diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt index 823ab66f..a0eccb50 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt @@ -21,6 +21,8 @@ */ package pl.treksoft.kvision.panel +import pl.treksoft.kvision.core.Container + /** * The container with vertical layout. * @@ -44,5 +46,19 @@ open class VPanel( @Suppress("LeakingThis") init?.invoke(this) } + + companion object { + /** + * DSL builder extension function + * + * It takes the same parameters as the constructor of the built component. + */ + fun Container.vPanel( + justify: FLEXJUSTIFY? = null, alignItems: FLEXALIGNITEMS? = null, spacing: Int? = null, + classes: Set = setOf(), init: (VPanel.() -> Unit)? = null + ) { + this.add(VPanel(justify, alignItems, spacing, classes, init)) + } + } } -- cgit