scoop:scoop.ui.component:0.1.0
src/builders/tabs.scoop
Selected production source · src/builders/tabs.scoop
1
package scoop.ui.component3
import scoop.graphics.text.*4
import scoop.ui.*5
import scoop.ui.style.*7
public class TabItemBuilder internal constructor() {8
public var semantics: ComponentSemantics = ComponentSemantics()9
public var trigger: ButtonContent? = None10
public var focus: FocusOptions = FocusOptions()11
public var retention: ContentRetention? = None12
public var triggerStyle: ButtonStyle? = None13
public var panelStyle: StyleOverride = styleOverride()14
public fun trigger(text: String) {15
trigger = Some(ButtonContent.Label(LabelProps(LabelText.Plain(text, None))))16
}17
public fun trigger(text: StyledText) {18
trigger = Some(ButtonContent.Label(LabelProps(LabelText.Styled(text))))19
}20
public fun trigger(content: View) {21
trigger = Some(ButtonContent.Custom(content))22
}23
public fun trigger(content: (ActionContentStyle) -> View) {24
trigger = Some(ButtonContent.Resolved(content))25
}26
public fun focus(configure: FocusOptionsBuilder.() -> Unit) {27
focus = focus.copy(configure)28
}29
public fun triggerStyle(configure: ButtonStyleBuilder.() -> Unit) {30
triggerStyle =31
Some((triggerStyle ?: buttonStyle { this.kind = SurfaceKind.Plain }).copy(configure))32
}33
public fun panelStyle(configure: StyleOverrideBuilder.() -> Unit) {34
panelStyle = panelStyle.copy(configure)35
}36
}38
public class TabsBuilder<T: Equals<T>> internal constructor() {39
public var semantics: ComponentSemantics = ComponentSemantics()40
private val entries = ArrayList<TabEntry<T>>()41
public var activation: TabActivation = TabActivation.Auto42
public var axis: FlexAxis = FlexAxis.Horizontal43
public var variant: TabsVariant = TabsVariant.Default44
public var retention: ContentRetention = ContentRetention.Dispose45
public var enabled: Boolean = true46
public var loop: Boolean = true47
public var spacing: Double = 8.048
public var fonts: FontCollection? = None49
public var theme: ThemeSource? = None50
public var style: StyleOverride = styleOverride()51
public var listStyle: StyleOverride = styleOverride()52
public var onValueChange: (T?) -> Unit = {}53
public var key: ViewKey = ViewKey.Position54
public fun add(entry: TabEntry<T>) {55
entries.add(entry)56
}57
public fun item(choice: Choice<T>, content: View, configure: TabItemBuilder.() -> Unit = {}) {58
val builder = TabItemBuilder()59
builder.configure()60
add(61
TabEntry(62
choice,63
content,64
builder.trigger,65
builder.focus,66
builder.retention,67
builder.triggerStyle,68
builder.panelStyle,69
builder.semantics70
)71
)72
}73
public fun style(configure: StyleOverrideBuilder.() -> Unit) {74
style = style.copy(configure)75
}76
public fun listStyle(configure: StyleOverrideBuilder.() -> Unit) {77
listStyle = listStyle.copy(configure)78
}79
internal fun snapshot(selected: Binding<T?>): TabsProps<T> =80
TabsProps(81
entries.toArray(),82
selected,83
activation,84
axis,85
variant,86
retention,87
enabled,88
loop,89
spacing,90
fonts,91
theme,92
style,93
listStyle,94
onValueChange,95
semantics96
)97
}99
public fun <T: Equals<T>> tabs(100
selected: Binding<T?>,101
configure: TabsBuilder<T>.() -> Unit = {}102
): View = makeTabs(selected, configure)104
internal fun <T: Equals<T>> makeTabs(105
selected: Binding<T?>,106
configure: TabsBuilder<T>.() -> Unit107
): View {108
val builder = TabsBuilder<T>()109
builder.configure()110
return component(111
builder.snapshot(selected),112
{ current, mount -> Tabs(current, scope = mount) },113
builder.key114
)115
}