Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xxfast committed Sep 27, 2023
1 parent b9eef78 commit 0e312d5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,21 @@ class DetailInstance(savedState: SavedStateHandle, detail: String) : InstanceKee
<details>
<summary>iOS</summary>

**build.gradle.kts**
Make sure to create your root router context outside of `ComposeUIViewController`'s composable lambda and pass it in to `LocalRouterContext`

**build.gradle.kts**
```kotlin
fun main(): UIViewController = ComposeUIViewController {
val lifecycle = LifecycleRegistry()
val rootRouterContext = RouterContext(lifecycle = lifecycle)
fun MainUIController(rootRouterContext: RouterContext): UIViewController = ComposeUIViewController {
CompositionLocalProvider(LocalRouterContext provides rootRouterContext) {
MaterialTheme {
ListDetailScreen()
}
}
}

```
> [!IMPORTANT]
> You will need to tie root `RouterContext`'s lifecycle to an `AppDelegate`. See example kotlin app delegate [here](https://github.com/xxfast/Decompose-Router/blob/main/app/src/iosMain/kotlin/io/github/xxfast/decompose/router/app/AppDelegate.kt), or swift delegate https://github.com/xxfast/Decompose-Router/blob/main/app/ios/ios/AppDelegate.swift. Read more on the docs [here](https://arkivanov.github.io/Decompose/getting-started/quick-start/#ios-with-swiftui)
</details>

<details>
Expand Down

0 comments on commit 0e312d5

Please sign in to comment.