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)Content copied to clipboard