Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import android.util.Log
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.ContentTransform
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
Expand Down Expand Up @@ -415,13 +418,9 @@ private fun Nav3SampleApp(
}
},
sceneStrategies = listOf(dialogSceneStrategy, bottomSheetSceneStrategy),
transitionSpec = {
fadeIn(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS))
.togetherWith(fadeOut(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS)))
},
transitionSpec = { nav3RouteTransition(animate = !performanceState.performanceRunActive) },
popTransitionSpec = {
fadeIn(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS))
.togetherWith(fadeOut(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS)))
nav3RouteTransition(animate = !performanceState.performanceRunActive)
},
entryProvider =
entryProvider {
Expand Down Expand Up @@ -620,4 +619,16 @@ private fun Nav3SampleApp(
}

private const val NAV3_TAG = "Nav3Activity"

// Performance runs navigate every two frames, so fades never finish and every outgoing route stays
// composed; when the run ends, they all recompose into the full panel at once and run out of
// memory.
private fun nav3RouteTransition(animate: Boolean): ContentTransform =
if (animate) {
fadeIn(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS))
.togetherWith(fadeOut(animationSpec = tween(COMPOSE_ROUTE_TRANSITION_MILLIS)))
} else {
ContentTransform(EnterTransition.None, ExitTransition.None, sizeTransform = null)
}

private const val COMPOSE_ROUTE_TRANSITION_MILLIS = 350
Loading