A library which provides Compose Material3 support for Jetpack Navigation Compose. This features composable bottom sheet destinations.
- Create a
ModalBottomSheetNavigator
and add it to theNavController
:
@Composable
fun MyApp() {
val bottomSheetNavigator = rememberModalBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)
}
- Wrap your
NavHost
in theModalBottomSheetLayout
composable that accepts aModalBottomSheetNavigator
.
@Composable
fun MyApp() {
val bottomSheetNavigator = rememberModalBottomSheetNavigator()
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 = rememberModalBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)
ModalBottomSheetLayout(bottomSheetNavigator) {
NavHost(navController, "home") {
composable(route = "home") {
...
}
bottomSheet(route = "sheet") {
Text("This is a cool bottom sheet!")
}
}
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("com.eygraber:compose-material3-navigation:0.0.7")
}
Snapshots can be found here.