-
public final class BaseNavHostKt
-
-
Method Summary
Modifier and Type Method Description final static <T extends Any, S extends Any> UnitBaseNavHost(ScopingNavHostState<T, S> state, NavTransitionQueueing transitionQueueing, Function1<NavSnapshot<T, S>, Set<NavSnapshotItem<T, S>>> visibleItems, Function1<NavSnapshot<T, S>, NavSnapshot<T, S>> transition)Allows you to create new NavHosts with different custom layouts and transitions, reusing the whole internal state and architecture components management intact. -
-
Method Detail
-
BaseNavHost
@Composable() final static <T extends Any, S extends Any> Unit BaseNavHost(ScopingNavHostState<T, S> state, NavTransitionQueueing transitionQueueing, Function1<NavSnapshot<T, S>, Set<NavSnapshotItem<T, S>>> visibleItems, Function1<NavSnapshot<T, S>, NavSnapshot<T, S>> transition)
Allows you to create new NavHosts with different custom layouts and transitions, reusing the whole internal state and architecture components management intact.
BaseNavHost gives you access to the entire backstack of entries through NavSnapshot, so it is possible to lay out and display several or all entries at the same time.
BaseNavHost uses NavSnapshots as anchor points of navigation. The transition between two NavSnapshots is defined with transition. BaseNavHost passes you the snapshot changes as an input parameter of
transition. You may choose to switch to the passed target snapshot immediately as in NavHost or with some animation as in AnimatedNavHost. The returned snapshot is what notifies BaseNavHost of when the current transition to the requested snapshot ends: simply return the previous snapshot until you finish transitioning to the new target snapshot. When you are done, return the target snapshot.This is similar to how updateTransition treats its
targetStateandcurrentState:currentStateis set totargetStateonly when transition ends. You may think of the input parameter of transition astargetStateand the returned value ascurrentState.Queueing:
BaseNavHost does the internal queueing depending on transitionQueueing:
If the parameter is either QueueAll or ConflateQueued, then BaseNavHost would not send you the next target snapshot unless you finish the current transition and return the target snapshot back as a result of transition. Only then the next target snapshot will be passed into
transition.If the parameter is InterruptCurrent then BaseNavHost will send you any new target snapshot as soon as possible. It is up to the implementation to resolve and animate the interruption correctly. When the last uninterrupted transition finishes you must return the most recent target snapshot.
All library's default NavHosts use BaseNavHost internally, so you may explore their sources as examples.
Note: this is still an early public version of the API. It may get some changes in the future.
- Parameters:
state- the holder of all internal BaseNavHost state.transitionQueueing- the strategy of processing incoming transitions when transition animations run slower than being addedvisibleItems- controls the lifecycle states of NavHostEntries.
-
-
-
-