From dc841a91e0da60f564b38725a4d75fc59fea1ba0 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sun, 27 Sep 2026 12:01:41 +0200 Subject: [PATCH] Remember the view morph scope across recompositions (#184) --- .../de/jeanlucmakiola/calendula/ui/CalendarHost.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/CalendarHost.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/CalendarHost.kt index 887e615c..22ff57bd 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/CalendarHost.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/CalendarHost.kt @@ -383,13 +383,12 @@ fun CalendarHost( transitionSpec = { viewSwitch }, label = "view-switch", ) { currentView -> - CompositionLocalProvider( - LocalViewMorph provides if (reduceMotion) { - null - } else { - ViewMorphScope(this@SharedTransitionLayout, this@AnimatedContent, morphBounds, morphFade) - }, - ) { + val sharedScope = this@SharedTransitionLayout + val visibilityScope = this@AnimatedContent + val viewMorph = remember(reduceMotion, sharedScope, visibilityScope, morphBounds, morphFade) { + if (reduceMotion) null else ViewMorphScope(sharedScope, visibilityScope, morphBounds, morphFade) + } + CompositionLocalProvider(LocalViewMorph provides viewMorph) { when (currentView) { CalendarView.Week -> WeekScreen( selectedView = currentView,