BottomSheetNavigator

@Navigator.Name(value = "bottomSheet")
class BottomSheetNavigator : Navigator


Navigator that drives a ModalBottomSheetState for use of ModalBottomSheetLayouts with the navigation library. Every destination using this Navigator must set a valid Composable by setting it directly on an instantiated Destination or calling androidx.compose.material.navigation.bottomSheet.

The sheetContent will always host the latest entry of the back stack. When navigating from a BottomSheetNavigator.Destination to another BottomSheetNavigator.Destination, the content of the sheet will be replaced instead of a new bottom sheet being shown.

When the sheet is dismissed by the user, the state's NavigatorState.backStack will be popped.

Summary

Public constructors

Public functions

open BottomSheetNavigator.Destination

Construct a new NavDestination associated with this Navigator.

open Unit
navigate(
    entries: List<NavBackStackEntry>,
    navOptions: NavOptions?,
    navigatorExtras: Navigator.Extras?
)

Navigate to a destination.

open Unit

Indicator that this Navigator is actively being used by a NavController.

open Unit
popBackStack(popUpTo: NavBackStackEntry, savedState: Boolean)

Attempt to pop this navigator's back stack, performing the appropriate navigation.

Inherited functions

From androidx.navigation.Navigator
open NavDestination?
navigate(
    destination: BottomSheetNavigator.Destination,
    args: SavedState?,
    navOptions: NavOptions?,
    navigatorExtras: Navigator.Extras?
)

Navigate to a destination.

open Unit

Informational callback indicating that the given backStackEntry has been affected by a NavOptions.shouldLaunchSingleTop operation.

open Unit

Restore any state previously saved in onSaveState.

open SavedState?

Called to ask for a SavedState representing the Navigator's state.

open Boolean

Attempt to pop this navigator's back stack, performing the appropriate navigation.

Inherited properties

From androidx.navigation.Navigator
Boolean

Whether this Navigator is actively being used by a NavController.

NavigatorState

The state of the Navigator is the communication conduit between the Navigator and the NavController that has called onAttach.

Public constructors

BottomSheetNavigator

Added in 1.7.0
BottomSheetNavigator(sheetState: ModalBottomSheetState)
Parameters
sheetState: ModalBottomSheetState

The ModalBottomSheetState that the BottomSheetNavigator will use to drive the sheet state

Public functions

createDestination

Added in 1.7.0
open fun createDestination(): BottomSheetNavigator.Destination

Construct a new NavDestination associated with this Navigator.

Any initialization of the destination should be done in the destination's constructor as it is not guaranteed that every destination will be created through this method.

Returns
BottomSheetNavigator.Destination

a new NavDestination

open fun navigate(
    entries: List<NavBackStackEntry>,
    navOptions: NavOptions?,
    navigatorExtras: Navigator.Extras?
): Unit

Navigate to a destination.

Requests navigation to a given destination associated with this navigator in the navigation graph. This method generally should not be called directly; NavController will delegate to it when appropriate.

Parameters
entries: List<NavBackStackEntry>

destination(s) to navigate to

navOptions: NavOptions?

additional options for navigation

navigatorExtras: Navigator.Extras?

extras unique to your Navigator.

onAttach

open fun onAttach(state: NavigatorState): Unit

Indicator that this Navigator is actively being used by a NavController. This is called when the NavController's state is ready to be restored.

popBackStack

open fun popBackStack(popUpTo: NavBackStackEntry, savedState: Boolean): Unit

Attempt to pop this navigator's back stack, performing the appropriate navigation.

All destinations back to popUpTo should be popped off the back stack.

Parameters
popUpTo: NavBackStackEntry

the entry that should be popped off the NavigatorState.backStack along with all entries above this entry.

savedState: Boolean

whether any Navigator specific state associated with popUpTo should be saved to later be restored by a call to navigate with NavOptions.shouldRestoreState.

Public properties

Added in 1.7.0
val navigatorSheetStateBottomSheetNavigatorSheetState

Access properties of the ModalBottomSheetLayout's ModalBottomSheetState