scoop:scoop.ui.component:0.1.0
src/calendar/builder.scoop
Selected production source · src/calendar/builder.scoop
1
package scoop.ui.component3
import scoop.datetime.*4
import scoop.graphics.text.FontCollection5
import scoop.ui.*6
import scoop.ui.style.*8
public open class CalendarOptionsBuilder internal constructor(value: CalendarOptions) {9
public var rules: CalendarRules = value.rules10
public var locale: CalendarLocale = value.locale11
public var source: CalendarPageSource = value.source12
public var monthCount: Long = value.monthCount13
public var pagedNavigation: Boolean = value.pagedNavigation14
public var showOutsideDays: Boolean = value.showOutsideDays15
public var fixedWeeks: Boolean = value.fixedWeeks16
public var weekNumbers: CalendarWeekNumbers = value.weekNumbers17
public var caption: CalendarCaption = value.caption18
public var cellSize: Double = value.cellSize19
public var monthGap: Double = value.monthGap20
public var syncSelection: Boolean = value.syncSelection21
public var today: LocalDate? = value.today22
public var years: Array<Int> = value.years23
internal fun options(): CalendarOptions =24
CalendarOptions(25
rules,26
locale,27
source,28
monthCount,29
pagedNavigation,30
showOutsideDays,31
fixedWeeks,32
weekNumbers,33
caption,34
cellSize,35
monthGap,36
syncSelection,37
today,38
years39
)40
}42
public fun calendarOptions(configure: CalendarOptionsBuilder.() -> Unit = {}): CalendarOptions =43
defaultCalendarOptions.copy(configure)45
public fun CalendarOptions.copy(46
configure: CalendarOptionsBuilder.() -> Unit = {}47
): CalendarOptions {48
val b = CalendarOptionsBuilder(this)49
b.configure()50
return b.options()51
}53
public class CalendarBuilder internal constructor(): CalendarOptionsBuilder(54
defaultCalendarOptions55
) {56
public var key: ViewKey = ViewKey.Position57
public var enabled: Boolean = true58
public var handle: CalendarHandle? = None59
public var fonts: FontCollection? = None60
public var theme: ThemeSource? = None61
public var style: StyleOverride = styleOverride()62
public var dayStyle: ButtonStyle = defaultButtonStyle63
public var dayFocus: (CalendarPage, CalendarDayData) -> FocusOptions =64
{ _, _ -> FocusOptions() }65
public var header: ((CalendarHeaderParts) -> View)? = None66
public var monthGrid: ((CalendarPage, View) -> View)? = None67
public var day: ((CalendarDay, ActionContentStyle) -> View)? = None68
public var weekNumber: ((String) -> View)? = None69
public var footer: View? = None70
public var onValueChange: (CalendarValue) -> Unit = {}71
public var onPageChange: (LocalDate) -> Unit = {}72
public var semantics: ComponentSemantics = ComponentSemantics()73
public var daySemantics: (CalendarDay) -> ComponentSemantics =74
{ day -> ComponentSemantics(name = Some(day.data.date.toString())) }75
public fun style(configure: StyleOverrideBuilder.() -> Unit) {76
style = style.copy(configure)77
}78
public fun dayStyle(configure: ButtonStyleBuilder.() -> Unit) {79
dayStyle = dayStyle.copy(configure)80
}81
internal fun snapshot(selection: CalendarSelection, initialPage: LocalDate): CalendarProps =82
CalendarProps(83
selection,84
initialPage,85
options(),86
enabled,87
handle,88
fonts,89
theme,90
style,91
dayStyle,92
dayFocus,93
header,94
monthGrid,95
day,96
weekNumber,97
footer,98
onValueChange,99
onPageChange,100
semantics,101
daySemantics102
)103
}105
public fun calendar(106
selection: CalendarSelection,107
initialPage: LocalDate,108
configure: CalendarBuilder.() -> Unit = {}109
): View {110
val b = CalendarBuilder()111
b.configure()112
return component(113
b.snapshot(selection, initialPage),114
{ props, scope -> Calendar(props, scope) },115
b.key116
)117
}119
public fun calendar(120
value: Binding<LocalDate?>,121
initialPage: LocalDate,122
configure: CalendarBuilder.() -> Unit = {}123
): View = calendar(CalendarSelection.Single(value), initialPage, configure)125
public fun calendarMultiple(126
value: Binding<Array<LocalDate>>,127
initialPage: LocalDate,128
configure: CalendarBuilder.() -> Unit = {}129
): View = calendar(CalendarSelection.Multiple(value), initialPage, configure)131
public fun calendarRange(132
value: Binding<DateRange?>,133
initialPage: LocalDate,134
configure: CalendarBuilder.() -> Unit = {}135
): View = calendar(CalendarSelection.Range(value), initialPage, configure)