NepaliDayDecorator

Decides how a day is drawn beyond what the theme already says, which is what puts holidays, festivals and an app's own events on the calendar.

The picker calls this once per visible cell, so keep it a lookup rather than a computation: read from a map or a memoized source, as NepaliDatePickerDefaults.eventDecorator and NepaliDatePickerDefaults.dayDecorator do. Hoist the decorator itself into a remember too, so a new lambda identity on every recomposition does not defeat the grid's own caching.

decorate runs outside composition, so read the theme before building the decorator rather than inside it: MaterialTheme.colorScheme is not available in the lambda.

Example:

val eventColor = MaterialTheme.colorScheme.primary
val decorator = remember(events, eventColor) {
NepaliDayDecorator { day ->
val onThatDay = events[day.date.toSimpleDate()] ?: return@NepaliDayDecorator null
NepaliDayDecoration(
indicators = onThatDay.map { eventColor },
contentDescription = onThatDay.joinToString { it.title }
)
}
}
NepaliDatePicker(state = state, dayDecorator = decorator)

Functions

Link copied to clipboard

How to draw day, or null to leave the cell exactly as the theme draws it.

Link copied to clipboard

Lays other's marks over this decorator's, which is how a day that is both a holiday and a working day with two meetings on it gets drawn.