scoop:scoop.ui.component:0.1.0
src/builders/layout.scoop
Selected production source · src/builders/layout.scoop
1
package scoop.ui.component3
import scoop.graphics.*4
import scoop.collections.HashMap5
import scoop.ui.*6
import scoop.ui.style.*8
public open class LinearBuilder internal constructor(): ChildrenBuilder() {9
public var spacing: Double = 0.010
public var alignment: CrossAlignment = CrossAlignment.Start11
public var justify: MainAlignment = MainAlignment.Start12
public var padding: Insets = Insets()13
public var logicalPadding: LogicalInsets? = None14
public var clip: Boolean = false15
private val options = HashMap<Long, FlexItemOptions>()17
public fun item(content: View, configure: FlexItemBuilder.() -> Unit = {}): Unit {18
val value = flexItem(content, configure)19
val index = childCount20
add(content)21
options.put(index, value.options)22
}23
internal fun snapshot(): LinearProps {24
val children = childrenSnapshot()25
return LinearProps(26
Array<FlexItem>(children.size) {27
index -> FlexItem(children[index], options[index] ?: FlexItemOptions())28
},29
spacing,30
alignment,31
justify,32
padding,33
clip,34
logicalPadding35
)36
}37
}39
public class StackBuilder internal constructor(): ChildrenBuilder() {40
public var alignment: Alignment = Alignment()41
internal fun snapshot(): StackProps = StackProps(childrenSnapshot(), alignment)42
}44
internal fun makeRow(configure: LinearBuilder.() -> Unit): View {45
val builder = LinearBuilder()46
builder.configure()47
return component(builder.snapshot(), { props, mount -> Row(props, scope = mount) }, builder.key)48
}50
internal fun makeColumn(configure: LinearBuilder.() -> Unit): View {51
val builder = LinearBuilder()52
builder.configure()53
return component(54
builder.snapshot(),55
{ props, mount -> Column(props, scope = mount) },56
builder.key57
)58
}60
internal fun makeStack(configure: StackBuilder.() -> Unit): View {61
val builder = StackBuilder()62
builder.configure()63
return component(64
builder.snapshot(),65
{ props, mount -> Stack(props, scope = mount) },66
builder.key67
)68
}