Deprecated Deprecated in favor of NavDisplay that supports sharedTransitionScope and takes a List
NavDisplay
@Composable
public fun <T : Any> NavDisplay(
backStack: List<T>,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
onBack: () -> Unit = {
if (backStack is MutableList<T>) {
backStack.removeLastOrNull()
}
},
entryDecorators: List<NavEntryDecorator<T>> =
listOf(rememberSaveableStateHolderNavEntryDecorator()),
sceneStrategy: SceneStrategy<T> = SinglePaneSceneStrategy(),
sizeTransform: SizeTransform? = null,
transitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultTransitionSpec(),
popTransitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultPopTransitionSpec(),
predictivePopTransitionSpec:
AnimatedContentTransitionScope<Scene<T>>.(
@NavigationEvent.SwipeEdge Int
) -> ContentTransform =
defaultPredictivePopTransitionSpec(),
entryProvider: (key: T) -> NavEntry<T>,
)
A nav display that renders and animates between different Scenes, each of which can render one or more NavEntrys.
The Scenes are calculated with the given SceneStrategy, which may be an assembled delegated chain of SceneStrategys. If no Scene is calculated, the fallback will be to a SinglePaneSceneStrategy.
It is allowable for different Scenes to render the same NavEntrys, perhaps on some conditions as determined by the sceneStrategy based on window size, form factor, other arbitrary logic.
If this happens, and these Scenes are rendered at the same time due to animation or predictive back, then the content for the NavEntry will only be rendered in the most recent Scene that is the target for being the current scene as determined by sceneStrategy. This enforces a unique invocation of each NavEntry, even if it is displayable by two different Scenes.
By default, AnimatedContent transitions are prioritized in this order:
transitioning [NavEntry.metadata] > current [Scene.metadata] > NavDisplay defaults
However, a Scene.metadata does have the ability to override NavEntry.metadata. Nevertheless, the final fallback will always be the NavDisplay's default transitions.
Parameters
| backStack | the collection of keys that represents the state that needs to be handled |
| modifier | the modifier to be applied to the layout. |
| contentAlignment | The Alignment of the AnimatedContent |
| onBack | a callback for handling system back press. By default, this pops a single item off of the given back stack if it is a MutableList, otherwise you should provide this parameter. |
| entryDecorators | list of NavEntryDecorator to add information to the entry content |
| sceneStrategy | the SceneStrategy to determine which scene to render a list of entries. |
| sizeTransform | the SizeTransform for the AnimatedContent. |
| transitionSpec | Default ContentTransform when navigating to NavEntrys. |
| popTransitionSpec | Default ContentTransform when popping NavEntrys. |
| predictivePopTransitionSpec | Default ContentTransform when popping with predictive back NavEntrys. |
| entryProvider | lambda used to construct each possible NavEntry |
NavDisplay
@Composable
public fun <T : Any> NavDisplay(
backStack: List<T>,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
onBack: () -> Unit = {
if (backStack is MutableList<T>) {
backStack.removeLastOrNull()
}
},
entryDecorators: List<NavEntryDecorator<T>> =
listOf(rememberSaveableStateHolderNavEntryDecorator()),
sceneStrategies: List<SceneStrategy<T>> = listOf(SinglePaneSceneStrategy()),
sceneDecoratorStrategies: List<SceneDecoratorStrategy<T>> = emptyList(),
sharedTransitionScope: SharedTransitionScope? = null,
sizeTransform: SizeTransform? = null,
transitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultTransitionSpec(),
popTransitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultPopTransitionSpec(),
predictivePopTransitionSpec:
AnimatedContentTransitionScope<Scene<T>>.(
@NavigationEvent.SwipeEdge Int
) -> ContentTransform =
defaultPredictivePopTransitionSpec(),
entryProvider: (key: T) -> NavEntry<T>,
)
A nav display that renders and animates between different Scenes, each of which can render one or more NavEntrys.
The Scenes are calculated with the given list of SceneStrategy in the order of the list. If no Scene is calculated, the fallback will be to a SinglePaneSceneStrategy.
It is allowable for different Scenes to render the same NavEntrys, perhaps on some conditions as determined by the sceneStrategies based on window size, form factor, other arbitrary logic.
If this happens, and these Scenes are rendered at the same time due to animation or predictive back, then the content for the NavEntry will only be rendered in the most recent Scene that is the target for being the current scene as determined by sceneStrategies. This enforces a unique invocation of each NavEntry, even if it is displayable by two different Scenes.
By default, AnimatedContent transitions are prioritized in this order:
transitioning [NavEntry.metadata] > current [Scene.metadata] > NavDisplay defaults
However, a Scene.metadata does have the ability to override NavEntry.metadata. Nevertheless, the final fallback will always be the NavDisplay's default transitions.
Parameters
| backStack | the collection of keys that represents the state that needs to be handled |
| modifier | the modifier to be applied to the layout. |
| contentAlignment | The Alignment of the AnimatedContent |
| onBack | a callback for handling system back press. By default, this pops a single item off of the given back stack if it is a MutableList, otherwise you should provide this parameter. |
| entryDecorators | list of NavEntryDecorator to add information to the entry content |
| sceneStrategies | the list of SceneStrategy to determine which scene to render a list of entries. |
| sceneDecoratorStrategies | list of SceneDecoratorStrategy to add content to the scene. |
| sharedTransitionScope | the SharedTransitionScope to allow transitions between scenes. |
| sizeTransform | the SizeTransform for the AnimatedContent. |
| transitionSpec | Default ContentTransform when navigating to NavEntrys. |
| popTransitionSpec | Default ContentTransform when popping NavEntrys. |
| predictivePopTransitionSpec | Default ContentTransform when popping with predictive back NavEntrys. |
| entryProvider | lambda used to construct each possible NavEntry |
Deprecated Deprecated in favor of NavDisplay that supports sharedTransitionScope and takes a List
NavDisplay
@Composable
public fun <T : Any> NavDisplay(
entries: List<NavEntry<T>>,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
sceneStrategy: SceneStrategy<T> = SinglePaneSceneStrategy(),
sizeTransform: SizeTransform? = null,
transitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultTransitionSpec(),
popTransitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultPopTransitionSpec(),
predictivePopTransitionSpec:
AnimatedContentTransitionScope<Scene<T>>.(
@NavigationEvent.SwipeEdge Int
) -> ContentTransform =
defaultPredictivePopTransitionSpec(),
onBack: () -> Unit,
)
A nav display that renders and animates between different Scenes, each of which can render one or more NavEntrys.
The Scenes are calculated with the given SceneStrategy, which may be an assembled delegated chain of SceneStrategys. If no Scene is calculated, the fallback will be to a SinglePaneSceneStrategy.
It is allowable for different Scenes to render the same NavEntrys, perhaps on some conditions as determined by the sceneStrategy based on window size, form factor, other arbitrary logic.
If this happens, and these Scenes are rendered at the same time due to animation or predictive back, then the content for the NavEntry will only be rendered in the most recent Scene that is the target for being the current scene as determined by sceneStrategy. This enforces a unique invocation of each NavEntry, even if it is displayable by two different Scenes.
By default, AnimatedContent transitions are prioritized in this order:
transitioning [NavEntry.metadata] > current [Scene.metadata] > NavDisplay defaults
However, a Scene.metadata does have the ability to override NavEntry.metadata. Nevertheless, the final fallback will always be the NavDisplay's default transitions.
WHEN TO USE This overload can be used when you need to switch between different backStacks and each with their own separate decorator states, or when you want to concatenate backStacks and their states to form a larger backstack.
HOW TO USE The entries can first be created via rememberDecoratedNavEntries in order to associate a backStack with a particular set of states.
Parameters
| entries | the list of NavEntry built from a backStack. The entries can be created from a backStack decorated with NavEntryDecorator via rememberDecoratedNavEntries. |
| modifier | the modifier to be applied to the layout. |
| contentAlignment | The Alignment of the AnimatedContent |
| sceneStrategy | the SceneStrategy to determine which scene to render a list of entries. |
| sizeTransform | the SizeTransform for the AnimatedContent. |
| transitionSpec | Default ContentTransform when navigating to NavEntrys. |
| popTransitionSpec | Default ContentTransform when popping NavEntrys. |
| predictivePopTransitionSpec | Default ContentTransform when popping with predictive back NavEntrys. |
| onBack | a callback for handling system back press. |
NavDisplay
@Composable
public fun <T : Any> NavDisplay(
entries: List<NavEntry<T>>,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
sceneStrategies: List<SceneStrategy<T>> = listOf(SinglePaneSceneStrategy()),
sceneDecoratorStrategies: List<SceneDecoratorStrategy<T>> = emptyList(),
sharedTransitionScope: SharedTransitionScope? = null,
sizeTransform: SizeTransform? = null,
transitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultTransitionSpec(),
popTransitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultPopTransitionSpec(),
predictivePopTransitionSpec:
AnimatedContentTransitionScope<Scene<T>>.(
@NavigationEvent.SwipeEdge Int
) -> ContentTransform =
defaultPredictivePopTransitionSpec(),
onBack: () -> Unit,
)
A nav display that renders and animates between different Scenes, each of which can render one or more NavEntrys.
The Scenes are calculated with the given list of SceneStrategy in the order of the list. If no Scene is calculated, the fallback will be to a SinglePaneSceneStrategy.
It is allowable for different Scenes to render the same NavEntrys, perhaps on some conditions as determined by the sceneStrategies based on window size, form factor, other arbitrary logic.
If this happens, and these Scenes are rendered at the same time due to animation or predictive back, then the content for the NavEntry will only be rendered in the most recent Scene that is the target for being the current scene as determined by sceneStrategies. This enforces a unique invocation of each NavEntry, even if it is displayable by two different Scenes.
By default, AnimatedContent transitions are prioritized in this order:
transitioning [NavEntry.metadata] > current [Scene.metadata] > NavDisplay defaults
However, a Scene.metadata does have the ability to override NavEntry.metadata. Nevertheless, the final fallback will always be the NavDisplay's default transitions.
WHEN TO USE This overload can be used when you need to switch between different backStacks and each with their own separate decorator states, or when you want to concatenate backStacks and their states to form a larger backstack.
HOW TO USE The entries can first be created via rememberDecoratedNavEntries in order to associate a backStack with a particular set of states.
Parameters
| entries | the list of NavEntry built from a backStack. The entries can be created from a backStack decorated with NavEntryDecorator via rememberDecoratedNavEntries. |
| modifier | the modifier to be applied to the layout. |
| contentAlignment | The Alignment of the AnimatedContent |
| sceneStrategies | the list of SceneStrategy to determine which scene to render a list of entries. |
| sceneDecoratorStrategies | list of SceneDecoratorStrategy to add content to the scene. |
| sharedTransitionScope | the SharedTransitionScope to allow transitions between scenes. |
| sizeTransform | the SizeTransform for the AnimatedContent. |
| transitionSpec | Default ContentTransform when navigating to NavEntrys. |
| popTransitionSpec | Default ContentTransform when popping NavEntrys. |
| predictivePopTransitionSpec | Default ContentTransform when popping with predictive back NavEntrys. |
| onBack | a callback for handling system back press. |
NavDisplay
@Composable
public fun <T : Any> NavDisplay(
sceneState: SceneState<T>,
navigationEventState: NavigationEventState<SceneInfo<T>>,
modifier: Modifier = Modifier,
contentAlignment: Alignment = Alignment.TopStart,
sizeTransform: SizeTransform? = null,
transitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultTransitionSpec(),
popTransitionSpec: AnimatedContentTransitionScope<Scene<T>>.() -> ContentTransform =
defaultPopTransitionSpec(),
predictivePopTransitionSpec:
AnimatedContentTransitionScope<Scene<T>>.(
@NavigationEvent.SwipeEdge Int
) -> ContentTransform =
defaultPredictivePopTransitionSpec(),
)
A nav display that renders and animates between different Scenes, each of which can render one or more NavEntrys.
By default, AnimatedContent transitions are prioritized in this order:
transitioning [NavEntry.metadata] > current [Scene.metadata] > NavDisplay defaults
However, a Scene.metadata does have the ability to override NavEntry.metadata. Nevertheless, the final fallback will always be the NavDisplay's default transitions.
Parameters
| sceneState | the state that determines what current scene of the NavDisplay. |
| modifier | the modifier to be applied to the layout. |
| contentAlignment | The Alignment of the AnimatedContent |
| navigationEventState | the NavigationEventState responsible for handling back navigation |
| sizeTransform | the SizeTransform for the AnimatedContent. |
| transitionSpec | Default ContentTransform when navigating to NavEntrys. |
| popTransitionSpec | Default ContentTransform when popping NavEntrys. |
| predictivePopTransitionSpec | Default ContentTransform when popping with predictive back NavEntrys. |