scoop:scoop.ui.component:0.1.0
src/builders/hover_popup.scoop
Selected production source · src/builders/hover_popup.scoop
1
package scoop.ui.component3
import scoop.graphics.text.*4
import scoop.surface.AnimationSpec5
import scoop.time.Duration6
import scoop.ui.*7
import scoop.ui.style.*9
public open class HoverPopupBuilder internal constructor() {10
public var open: Binding<Boolean>? = None11
public var side: OverlaySide = OverlaySide.Top12
public var alignment: OverlayAlignment = OverlayAlignment.Center13
public var gap: Double = 4.014
public var viewportPadding: Double = 8.015
public var openDelay: Duration = Duration.ZERO16
public var closeDelay: Duration = Duration.ZERO17
public var transitDelay: Duration = Duration.milliseconds(350L)18
public var corridorPadding: Double = 6.019
public var focus: Boolean = true20
public var longPress: LongPressOptions = LongPressOptions()21
public var enabled: Boolean = true22
public var arrow: PopupArrow? = Some(PopupArrow())23
public var handle: OverlayHandle? = None24
public var transition: StyleValue<AnimationSpec?> = StyleValue.Inherit25
public var onOpenChange: (Boolean) -> Unit = {}26
public var onClosed: (OverlayCloseReason) -> Unit = {}27
public var fonts: FontCollection? = None28
public var theme: ThemeSource? = None29
public var style: StyleOverride = styleOverride()30
public var semantics: ComponentSemantics = ComponentSemantics()31
public var key: ViewKey = ViewKey.Position32
public fun style(configure: StyleOverrideBuilder.() -> Unit) {33
style = style.copy(configure)34
}35
public fun transition(value: AnimationSpec?) {36
transition = StyleValue.Set(value)37
}38
}40
public class TooltipBuilder internal constructor(): HoverPopupBuilder() {41
public var maxWidth: Double = 320.042
internal fun snapshot(trigger: View, content: PanelContent): TooltipProps =43
TooltipProps(44
trigger,45
content,46
open,47
side,48
alignment,49
gap,50
viewportPadding,51
maxWidth,52
openDelay,53
closeDelay,54
transitDelay,55
corridorPadding,56
focus,57
enabled,58
arrow,59
handle,60
transition,61
onOpenChange,62
onClosed,63
fonts,64
theme,65
style,66
semantics,67
longPress68
)69
}71
public class HoverCardBuilder internal constructor(): HoverPopupBuilder() {72
public var width: Double = 256.073
init {74
side = OverlaySide.Bottom75
openDelay = Duration.milliseconds(600L)76
closeDelay = Duration.milliseconds(300L)77
arrow = None78
}79
internal fun snapshot(trigger: View, content: View): HoverCardProps =80
HoverCardProps(81
trigger,82
content,83
open,84
side,85
alignment,86
gap,87
viewportPadding,88
width,89
openDelay,90
closeDelay,91
transitDelay,92
corridorPadding,93
focus,94
enabled,95
arrow,96
handle,97
transition,98
onOpenChange,99
onClosed,100
fonts,101
theme,102
style,103
semantics,104
longPress105
)106
}108
public fun tooltip(trigger: View, text: String, configure: TooltipBuilder.() -> Unit = {}): View =109
makeTooltip(trigger, PanelContent.Label(LabelProps(LabelText.Plain(text, None))), configure)111
public fun tooltip(112
trigger: View,113
text: StyledText,114
configure: TooltipBuilder.() -> Unit = {}115
): View = makeTooltip(trigger, PanelContent.Label(LabelProps(LabelText.Styled(text))), configure)117
public fun tooltip(trigger: View, content: View, configure: TooltipBuilder.() -> Unit = {}): View =118
makeTooltip(trigger, PanelContent.Custom(content), configure)120
internal fun makeTooltip(121
trigger: View,122
content: PanelContent,123
configure: TooltipBuilder.() -> Unit124
): View {125
val builder = TooltipBuilder()126
builder.configure()127
return component(128
builder.snapshot(trigger, content),129
{ current, mount -> Tooltip(current, scope = mount) },130
builder.key131
)132
}134
public fun hoverCard(135
trigger: View,136
content: View,137
configure: HoverCardBuilder.() -> Unit = {}138
): View = makeHoverCard(trigger, content, configure)140
internal fun makeHoverCard(141
trigger: View,142
content: View,143
configure: HoverCardBuilder.() -> Unit144
): View {145
val builder = HoverCardBuilder()146
builder.configure()147
return component(148
builder.snapshot(trigger, content),149
{ current, mount -> HoverCard(current, scope = mount) },150
builder.key151
)152
}