Open kopoh opened 1 month ago
I looked at the source code
@OptIn(markerClass = {androidx. compose. foundation. ExperimentalFoundationApi::class})
@Composable
public fun WeekView(
startDate: LocalDate = Clock.System. now() .toLocalDateTime(TimeZone. currentSystemDefault()) .toLocalDate(),
minDate: LocalDate = startDate.copy(day = 1).minus(3, DateTimeUnit. MONTH),
maxDate: LocalDate = startDate.copy(day = monthLength(startDate. month, startDate. year)) .plus(3, DateTimeUnit. MONTH),
daysOffset: Int = 0,
showDaysBesideRange: Boolean = true,
calendarAnimator: CalendarAnimator = CalendarAnimator(startDate),
isActive: (LocalDate) -> Boolean = { val today = Clock. System. now().toLocalDateTime(TimeZone. currentSystemDefault()).toLocalDate() today == it },
modifier: Modifier = Modifier,
firstVisibleDate: (LocalDate) -> Unit = {},
day: @Composable (dayState: DayState) -> Unit = { state -> weekDay(state) { CalendarDay( state, modifier = Modifier. width(58.dp), ) } }
): Unit
It seems that the problem with state is in this place
day: @Composable (dayState: DayState) -> Unit = { state -> weekDay(state) { CalendarDay( state, modifier = Modifier. width(58.dp), ) }
I found root of problems. It's Kotlin 2.0 bug. You can track it here https://youtrack.jetbrains.com/issue/CMP-4809. Now, you can fix it by adding the following lines to your gradle.properties file:
kotlin.native.cacheKind=none
compose.kotlin.native.manageCacheKind=false
I use kotlin 2.0.0 (+ tested on 1.9.23 same error), compose multiplatform 1.6.10, and last version of calendar 1.0.1
On android, desktop and js all working pretty fine
All error code
Through trial and error, I identified a problem in passing the state in the Webview component, because if I copy the DayState exactly, and just redefine the values via
This code is from this library repo (I just change data class and colors to MaterialTheme)
To display my weekview I use example from docs
Then everything starts to build, but the choice of the day and its background do not work (with this it is clear, the values are simply not returned back to the function above)
https://github.com/user-attachments/assets/6b502f11-1549-4340-8178-1e03b4b8b6c8