NavigatorState
-
Cmn
abstract class NavigatorState
TestNavigatorState |
An implementation of |
The NavigatorState encapsulates the state shared between the Navigator and the NavController.
Summary
Public constructors |
|
|---|---|
|
Cmn
|
Public functions |
||
|---|---|---|
abstract NavBackStackEntry |
createBackStackEntry(destination: NavDestination, arguments: SavedState?)Create a new |
Cmn
|
open Unit |
This removes the given |
Cmn
|
open Unit |
@CallSuperInformational callback indicating that the given |
Cmn
|
open Unit |
@CallSuperInformational callback indicating that the given |
Cmn
|
open Unit |
pop(popUpTo: NavBackStackEntry, saveState: Boolean)Pop all destinations up to and including |
Cmn
|
open Unit |
popWithTransition(popUpTo: NavBackStackEntry, saveState: Boolean)Pops all destinations up to and including |
Cmn
|
open Unit |
This prepares the given |
Cmn
|
open Unit |
push(backStackEntry: NavBackStackEntry)Adds the given |
Cmn
|
open Unit |
pushWithTransition(backStackEntry: NavBackStackEntry)Adds the given |
Cmn
|
Public properties |
||
|---|---|---|
StateFlow<List<NavBackStackEntry>> |
While the |
Cmn
|
StateFlow<Set<NavBackStackEntry>> |
This is the set of currently running transitions. |
Cmn
|
Public constructors
Public functions
createBackStackEntry
abstract fun createBackStackEntry(destination: NavDestination, arguments: SavedState?): NavBackStackEntry
Create a new NavBackStackEntry from a given destination and arguments.
markTransitionComplete
open fun markTransitionComplete(entry: NavBackStackEntry): Unit
This removes the given NavBackStackEntry from the set of the transitions in progress. This should be called in conjunction with pushWithTransition and popWithTransition as those call are responsible for adding entries to transitionsInProgress.
This should also always be called in conjunction with prepareForTransition to ensure all NavBackStackEntries settle into the proper state.
Failing to call this method could result in entries being prevented from reaching their final Lifecycle.State}.
| See also | |
|---|---|
pushWithTransition |
|
popWithTransition |
onLaunchSingleTop
@CallSuper
open fun onLaunchSingleTop(backStackEntry: NavBackStackEntry): Unit
Informational callback indicating that the given backStackEntry has been affected by a NavOptions.shouldLaunchSingleTop operation.
Replaces the topmost entry with same id with the new backStackEntry
| Parameters | |
|---|---|
backStackEntry: NavBackStackEntry |
the |
onLaunchSingleTopWithTransition
@CallSuper
open fun onLaunchSingleTopWithTransition(backStackEntry: NavBackStackEntry): Unit
Informational callback indicating that the given backStackEntry has been affected by a NavOptions.shouldLaunchSingleTop operation. This also adds the given and previous entry to the set of in progress transitions. Added entries have their Lifecycle capped at Lifecycle.State.STARTED until an entry is passed into the markTransitionComplete callback, when they are allowed to go to Lifecycle.State.RESUMED while previous entries have their Lifecycle held at Lifecycle.State.CREATED until an entry is passed into the markTransitionComplete callback, when they are allowed to go to Lifecycle.State.DESTROYED and have their state cleared.
Replaces the topmost entry with same id with the new backStackEntry
| Parameters | |
|---|---|
backStackEntry: NavBackStackEntry |
the |
pop
open fun pop(popUpTo: NavBackStackEntry, saveState: Boolean): Unit
Pop all destinations up to and including popUpTo. This will remove those destinations from the backStack, saving their state if saveState is true.
popWithTransition
open fun popWithTransition(popUpTo: NavBackStackEntry, saveState: Boolean): Unit
Pops all destinations up to and including popUpTo. This also adds the given and incoming entry to the set of in progress transitions. Added entries have their Lifecycle held at Lifecycle.State.CREATED until an entry is passed into the markTransitionComplete callback, when they are allowed to go to Lifecycle.State.DESTROYED and have their state cleared.
This will remove those destinations from the backStack, saving their state if saveState is true.
prepareForTransition
@CallSuper
open fun prepareForTransition(entry: NavBackStackEntry): Unit
This prepares the given NavBackStackEntry for transition. This should be called in conjunction with markTransitionComplete as that is responsible for settling the NavBackStackEntry into its final state.
| See also | |
|---|---|
markTransitionComplete |
push
open fun push(backStackEntry: NavBackStackEntry): Unit
Adds the given backStackEntry to the backStack.
pushWithTransition
open fun pushWithTransition(backStackEntry: NavBackStackEntry): Unit
Adds the given backStackEntry to the backStack. This also adds the given and previous entry to the set of in progress transitions. Added entries have their Lifecycle capped at Lifecycle.State.STARTED until an entry is passed into the markTransitionComplete callback, when they are allowed to go to Lifecycle.State.RESUMED.
Public properties
backStack
val backStack: StateFlow<List<NavBackStackEntry>>
While the NavController is responsible for the combined back stack across all Navigators, this back stack is specifically the set of destinations associated with this Navigator.
transitionsInProgress
val transitionsInProgress: StateFlow<Set<NavBackStackEntry>>
This is the set of currently running transitions. Use this set to retrieve the entry and call markTransitionComplete once the transition is complete.