Jetpack Navigation Compose Material¶
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.
Usage¶
Bottom Sheet Destinations¶
-
Create a
BottomSheetNavigator
and add it to theNavController
:@Composable fun MyApp() { val bottomSheetNavigator = rememberBottomSheetNavigator() val navController = rememberNavController(bottomSheetNavigator) }
-
Wrap your
NavHost
in theModalBottomSheetLayout
composable that accepts aBottomSheetNavigator
.@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.
Download¶
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.