Remember the view morph scope across recompositions (#184)

This commit is contained in:
2026-09-27 12:01:41 +02:00
parent f7805cb0b5
commit dc841a91e0
@@ -383,13 +383,12 @@ fun CalendarHost(
transitionSpec = { viewSwitch }, transitionSpec = { viewSwitch },
label = "view-switch", label = "view-switch",
) { currentView -> ) { currentView ->
CompositionLocalProvider( val sharedScope = this@SharedTransitionLayout
LocalViewMorph provides if (reduceMotion) { val visibilityScope = this@AnimatedContent
null val viewMorph = remember(reduceMotion, sharedScope, visibilityScope, morphBounds, morphFade) {
} else { if (reduceMotion) null else ViewMorphScope(sharedScope, visibilityScope, morphBounds, morphFade)
ViewMorphScope(this@SharedTransitionLayout, this@AnimatedContent, morphBounds, morphFade) }
}, CompositionLocalProvider(LocalViewMorph provides viewMorph) {
) {
when (currentView) { when (currentView) {
CalendarView.Week -> WeekScreen( CalendarView.Week -> WeekScreen(
selectedView = currentView, selectedView = currentView,