A library which provides Compose Material support for Jetpack Navigation Compose. This features composable bottom sheet destinations.
!!! warning The navigation APIs are currently experimental and they could change at any time. All of the APIs are marked with the @ExperimentalMaterialNavigationApi
annotation.
Create a BottomSheetNavigator
and add it to the NavController
:
@Composable fun MyApp() { val bottomSheetNavigator = rememberBottomSheetNavigator() val navController = rememberNavController(bottomSheetNavigator) }
Wrap your NavHost
in the ModalBottomSheetLayout
composable that accepts a BottomSheetNavigator
.
@Composable fun MyApp() { val bottomSheetNavigator = rememberBottomSheetNavigator() val navController = rememberNavController(bottomSheetNavigator) ModalBottomSheetLayout(bottomSheetNavigator) { NavHost(navController, "home") { // We'll define our graph here in a bit! } } }
Register a bottom sheet destination
@Composable fun MyApp() { val bottomSheetNavigator = rememberBottomSheetNavigator() val navController = rememberNavController(bottomSheetNavigator) ModalBottomSheetLayout(bottomSheetNavigator) { NavHost(navController, "home") { composable(route = "home") { ... } bottomSheet(route = "sheet") { Text("This is a cool bottom sheet!") } } } }
For more examples, refer to the samples.
repositories { mavenCentral() } dependencies { implementation "com.google.accompanist:accompanist-navigation-material:<version>" }
Snapshots of the development version are available in Sonatype's snapshots
repository. These are updated on every commit.