diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f743c2..9e7978e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Fixed a bug where managed flows (`registerForFlowResult`) that launch embedded flows (`deliverResultFromPush/Present`) were not correctly handling the result of the embedded flow * Added `FragmentSharedElements` to provide a way to define shared elements for Fragment navigation, including a compatibility layer for Composable NavigationDestinations that want to use AndroidViews as shared elements with Fragments. See `FragmentsWithSharedElements.kt` in the test application for examples of how to use `FragmentSharedElements` * Added `acceptFromFlow` as a `NavigationContainerFilter` for use on screens that build managed flows using `registerForFlowResult`. This filter will cause the `NavigationContainer` to only accept instructions that have been created as part a managed flow, and will reject instructions that are not part of a managed flow. +* Removed `isAnimating` from `ComposableNavigationContainer`, as it was unused internally, did not appear to be useful for external use cases, and was complicating Compose animation code. If this functionality *was* important to your use case, please create a Github issue to discuss your use case. * ⚠️ Updated result channel identifiers in preparation for Kotlin 2.0 ⚠️ * Kotlin 2.0 changes the way that lambdas are compiled, which has implications for `registerForNavigationResult` and how result channels are uniquely identified. Activites, Fragments, Composables and ViewModels that use `by registerForNavigationResult` directly will not be affected by this change. However, if you are creating result channels inside of other objects, such as delegates, helper objects, or extension functions, you should verify that these cases continue to work as expected. It is not expected that there will be issues, but if this does result in bugs in your application, please raise them on the Enro GitHub repository. diff --git a/enro-core/src/main/java/dev/enro/destination/compose/container/ComposableNavigationContainer.kt b/enro-core/src/main/java/dev/enro/destination/compose/container/ComposableNavigationContainer.kt index a7105c07..ee34bdd9 100644 --- a/enro-core/src/main/java/dev/enro/destination/compose/container/ComposableNavigationContainer.kt +++ b/enro-core/src/main/java/dev/enro/destination/compose/container/ComposableNavigationContainer.kt @@ -4,7 +4,6 @@ import android.os.Bundle import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.key import androidx.compose.runtime.movableContentOf @@ -71,10 +70,6 @@ public class ComposableNavigationContainer internal constructor( override val isVisible: Boolean get() = true - public val isAnimating: Boolean by derivedStateOf { - destinationOwners.any { it.animations.isAnimating } - } - private val onDestroyLifecycleObserver = LifecycleEventObserver { _, event -> if (event != Lifecycle.Event.ON_DESTROY) return@LifecycleEventObserver destroy() diff --git a/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationAnimations.kt b/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationAnimations.kt index ebd8a702..ec2938e1 100644 --- a/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationAnimations.kt +++ b/enro-core/src/main/java/dev/enro/destination/compose/destination/ComposableDestinationAnimations.kt @@ -12,9 +12,7 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.NonSkippableComposable -import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue -import androidx.compose.runtime.key import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -37,20 +35,11 @@ internal class ComposableDestinationAnimations( private val owner: ComposableDestinationOwner, ) { private var currentAnimationEvent by mutableStateOf(AnimationEvent.SnapTo(false)) - private val visibilityState = SeekableTransitionState(false) internal var animationOverride by mutableStateOf(null) internal lateinit var enterExitTransition: Transition - val isAnimating by derivedStateOf { - when (currentAnimationEvent) { - is AnimationEvent.AnimateTo -> visibilityState.targetState != visibilityState.currentState - is AnimationEvent.SnapTo -> false - is AnimationEvent.Seek -> true - } - } - internal fun setAnimationEvent(event: AnimationEvent) { currentAnimationEvent = event } @@ -59,10 +48,12 @@ internal class ComposableDestinationAnimations( @Composable @NonSkippableComposable fun Animate(content: @Composable () -> Unit) { - val targetState = visibilityState.targetState val instruction = owner.instruction val parentContainer = owner.parentContainer + val visibilityState = remember(instruction.instructionId) { SeekableTransitionState(false) } + val targetState = visibilityState.targetState + val animation = remember( instruction, targetState, @@ -99,9 +90,7 @@ internal class ComposableDestinationAnimations( currentAnimationEvent = AnimationEvent.SnapTo(event.visible) } } - val visibleTransition = key(instruction.instructionId) { - rememberTransition(visibilityState, "ComposableDestination Visibility") - } + val visibleTransition = rememberTransition(visibilityState, "ComposableDestination Visibility") animation.Animate( visible = visibleTransition, ) {