Skip to content

Commit

Permalink
Add contentZIndex for AnimatedNavHost
Browse files Browse the repository at this point in the history
  • Loading branch information
ommiao committed Sep 11, 2022
1 parent e69b0bf commit 2dda12b
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ public fun AnimatedNavHost(
val backStackEntry = visibleEntries.lastOrNull()

if (backStackEntry != null) {
var contentZIndex = 0
val finalEnter: AnimatedContentScope<NavBackStackEntry>.() -> EnterTransition = {
val targetDestination = targetState.destination as AnimatedComposeNavigator.Destination

targetDestination.hierarchy.firstNotNullOfOrNull { destination ->
contentZIndex = navController.backQueue.indexOfFirst { it.destination.route == destination.route }
}

if (composeNavigator.isPop.value) {
targetDestination.hierarchy.firstNotNullOfOrNull { destination ->
popEnterTransitions[destination.route]?.invoke(this)
Expand Down Expand Up @@ -202,6 +207,8 @@ public fun AnimatedNavHost(
finalEnter(this) with finalExit(this)
} else {
EnterTransition.None with ExitTransition.None
}.apply {
targetContentZIndex = contentZIndex.toFloat()
}
},
contentAlignment,
Expand Down

0 comments on commit 2dda12b

Please sign in to comment.