Skip to content

Commit

Permalink
Update index.md and usage.md
Browse files Browse the repository at this point in the history
  • Loading branch information
serbelga committed Mar 23, 2024
1 parent f482342 commit ef5af32
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Overview

Navigation Compose Extended is a complementary library for AndroidX Jetpack Navigation Compose to
improve creation of navigation elements, as destination routes, arguments, deep links, … in a
more idiomatic way than using literals.
Expand Down
21 changes: 18 additions & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ NavHost(
}
```

We can navigate to some destination using the `NavAction`. In the following code,
we navigate to the `SearchResultNavDestination` using the `navigate` function that receives
a `NavRoute`:
We can navigate to some destination using the actions functions provided by the `NavAction` class.
The `NavAction.navigate` function receive a `NavRoute` instance to navigate to some destination.
This `NavRoute` associated with a destination can be obtained using the `navRoute()` function in the `NavDestination` class.
In the following code, we navigate to the `SearchResultNavDestination`:

```kotlin
val navController = rememberNavController()
Expand Down Expand Up @@ -160,3 +161,17 @@ Trigger the deep link using adb:
```shell
adb shell am start -a android.intent.action.VIEW -d "sample://searchresult"
```

## Create Top Level Destinations

There's a special kind of destination to represent the top level destinations in the navigation graph.
This is useful for destinations associated to items in a BottomNavigationBar where we can navigate to
different screens by clicking on each navigation bar item. To avoid building up a large stack of destinations
on the back stack when we click on navigation items and to avoid multiple copies of the same destination
when we reselect the same item, we can use this kind of destination.

```kotlin
object SearchNavDestination : TopLevelNavDestination<NavArgumentKey>() {
override val destinationId: String = "search"
}
```

0 comments on commit ef5af32

Please sign in to comment.