Skip to content

Commit

Permalink
[Navigation Material] Update Docs and Sample to use new API for addin…
Browse files Browse the repository at this point in the history
…g custom Navigators (#746)

* Update Navigation to 2.4.0-alpha10

* Update Docs and Sample to use new API for adding custom Navigators

Fixes #744

* Remove unneeded add statement
  • Loading branch information
jossiwolf committed Sep 30, 2021
1 parent bbab100 commit a285f41
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
9 changes: 3 additions & 6 deletions docs/navigation-material.md
Expand Up @@ -18,9 +18,8 @@ This features composable bottom sheet destinations.
```kotlin
@Composable
fun MyApp() {
val navController = rememberNavController()
val bottomSheetNavigator = rememberBottomSheetNavigator()
navController.navigatorProvider += bottomSheetNavigator
val navController = rememberNavController(bottomSheetNavigator)
}
```

Expand All @@ -29,9 +28,8 @@ This features composable bottom sheet destinations.
```kotlin
@Composable
fun MyApp() {
val navController = rememberNavController()
val bottomSheetNavigator = rememberBottomSheetNavigator()
navController.navigatorProvider += bottomSheetNavigator
val navController = rememberNavController(bottomSheetNavigator)
ModalBottomSheetLayout(bottomSheetNavigator) {
NavHost(navController, Destinations.Home) {
// We'll define our graph here in a bit!
Expand All @@ -45,9 +43,8 @@ This features composable bottom sheet destinations.
```kotlin
@Composable
fun MyApp() {
val navController = rememberNavController()
val bottomSheetNavigator = rememberBottomSheetNavigator()
navController.navigatorProvider += bottomSheetNavigator
val navController = rememberNavController(bottomSheetNavigator)
ModalBottomSheetLayout(bottomSheetNavigator) {
NavHost(navController, Destinations.Home) {
composable(route = "home") {
Expand Down
Expand Up @@ -198,10 +198,9 @@ internal class BottomSheetNavigatorTest {
val sheetState = ModalBottomSheetState(ModalBottomSheetValue.Hidden)

composeTestRule.setContent {
navController = rememberNavController()
navigator = remember { BottomSheetNavigator(sheetState) }
navController = rememberNavController(navigator)
if (savedState != null) navController.restoreState(savedState)
navigator = remember(navController) { BottomSheetNavigator(sheetState) }
navController.navigatorProvider += navigator
if (compositionState == 0) {
ModalBottomSheetLayout(
bottomSheetNavigator = navigator
Expand Down
Expand Up @@ -58,9 +58,8 @@ private object Destinations {
@OptIn(ExperimentalMaterialNavigationApi::class)
@Composable
fun BottomSheetNavDemo() {
val navController = rememberNavController()
val bottomSheetNavigator = rememberBottomSheetNavigator()
navController.navigatorProvider += bottomSheetNavigator
val navController = rememberNavController(bottomSheetNavigator)

ModalBottomSheetLayout(bottomSheetNavigator) {
NavHost(navController, Destinations.Home) {
Expand Down

0 comments on commit a285f41

Please sign in to comment.