I have a Custom Composable Calendar
, here
I try to add a functionality to switch between month view and week view.
The point of the code is below:
LazyRow {
items(
key = { page -> state.getKey(page) },
) { page ->
monthFiled(
date = state.getDateByPage(page),
)
}
}
And here is the point:
- In monthView mode,
state.getKey(page)
return a key likesYearMonth
(or page or else). - In week mode,
state.getKey(page)
return a key likesyear_weeks
(or page or else).
They are different.
To ensure that the animation works correctly, I want the keys for the month view and the week view to be consistent when switching between them.
However, the relationship between month and week views is not one-to-one but one-to-many (1:5).
Is there anything that can help me switch between month and week views, as well as switch back and forth between month and week views smoothly?