scoop:scoop.ui.component:0.1.0
src/conversation/scroll_options.scoop
Selected production source · src/conversation/scroll_options.scoop
1
package scoop.ui.component3
import scoop.ui.*4
import scoop.ui.style.*6
public enum MessageInitialPosition {7
Start, End, LastAnchor8
}10
public enum MessageScrollMode {11
Holding, Anchoring, Following12
}14
public enum MessageScrollDirection {15
Start, End16
}18
public class MessageScrollOptions public constructor(19
public val autoScroll: Boolean = false,20
public val initialPosition: MessageInitialPosition = MessageInitialPosition.End,21
public val edgeThreshold: Double = 8.0,22
public val scrollMargin: Double = 0.0,23
public val previousItemPeek: Double = 64.0,24
public val preserveOnPrepend: Boolean = true25
) {26
init {27
nonnegative(edgeThreshold, "invalid message edge threshold")28
nonnegative(scrollMargin, "invalid message scroll margin")29
nonnegative(previousItemPeek, "invalid message previous item peek")30
}31
}33
public class MessageReadingSnapshot public constructor(34
public val visibleKeys: Array<ViewKey>,35
public val anchor: VirtualReadingAnchor?,36
public val currentAnchor: ViewKey?,37
public val atStart: Boolean,38
public val atEnd: Boolean39
)41
public class MessageScrollerProps public constructor(42
public val source: TranscriptSource,43
public val state: MessageScrollState,44
public val itemExtent: ItemExtent = ItemExtent.Variable(160.0),45
public val spacing: Double = 24.0,46
public val overscan: Double = 160.0,47
public val width: Double? = None,48
public val height: Double? = Some(480.0),49
public val scrollbars: ScrollbarVisibility = ScrollbarVisibility.Auto,50
public val scrollbar: ScrollbarOptions = scrollbarOptions(),51
public val enabled: Boolean = true,52
public val focus: FocusOptions = FocusOptions(),53
public val theme: ThemeSource? = None,54
public val controls: View? = None,55
public val showControls: Boolean = true,56
public val placeholder: View? = None,57
public val scrollbarBehavior: ScrollbarBehavior = scrollbarBehavior(),58
public val scrollPhysics: ScrollPhysicsOptions = ScrollPhysicsOptions(),59
public val itemSemantics: ItemSemantics? = None,60
public val semantics: ComponentSemantics = ComponentSemantics(),61
public val collectionSemantics: ComponentSemantics = ComponentSemantics()62
) {63
init {64
nonnegative(spacing, "invalid message spacing")65
nonnegative(overscan, "invalid message overscan")66
when (width) {67
case Some(val value) -> nonnegative(value, "invalid message width");68
case None -> {}69
}70
when (height) {71
case Some(val value) -> nonnegative(value, "invalid message height");72
case None -> {}73
}74
itemEstimate(itemExtent)75
when (itemSemantics) {76
case Some(val items) -> requireComponent(77
items.source === source,78
"message semantics must describe the same transcript snapshot"79
)80
case None -> {}81
}82
}83
}85
public class MessageScrollerBuilder internal constructor() {86
public var itemExtent: ItemExtent = ItemExtent.Variable(160.0)87
public var spacing: Double = 24.088
public var overscan: Double = 160.089
public var width: Double? = None90
public var height: Double? = Some(480.0)91
public var scrollbars: ScrollbarVisibility = ScrollbarVisibility.Auto92
public var scrollbar: ScrollbarOptions = scrollbarOptions()93
public var enabled: Boolean = true94
public var focus: FocusOptions = FocusOptions()95
public var theme: ThemeSource? = None96
public var controls: View? = None97
public var showControls: Boolean = true98
public var placeholder: View? = None99
public var scrollbarBehavior: ScrollbarBehavior = scrollbarBehavior()100
public var scrollPhysics: ScrollPhysicsOptions = ScrollPhysicsOptions()101
public var key: ViewKey = ViewKey.Position102
public var itemSemantics: ItemSemantics? = None103
public var semantics: ComponentSemantics = ComponentSemantics()104
public var collectionSemantics: ComponentSemantics = ComponentSemantics()105
public fun scrollbar(configure: ScrollbarOptionsBuilder.() -> Unit) {106
scrollbar = scrollbar.copy(configure)107
}108
public fun scrollbarBehavior(configure: ScrollbarBehaviorBuilder.() -> Unit): Unit {109
scrollbarBehavior = scrollbarBehavior.copy(configure)110
}111
public fun focus(configure: FocusOptionsBuilder.() -> Unit) {112
focus = focus.copy(configure)113
}114
internal fun snapshot(115
source: TranscriptSource,116
state: MessageScrollState117
): MessageScrollerProps =118
MessageScrollerProps(119
source,120
state,121
itemExtent,122
spacing,123
overscan,124
width,125
height,126
scrollbars,127
scrollbar,128
enabled,129
focus,130
theme,131
controls,132
showControls,133
placeholder,134
scrollbarBehavior,135
scrollPhysics,136
itemSemantics,137
semantics,138
collectionSemantics139
)140
}