initialConfiguration = Configuration.List, // Starting with List
initialConfiguration = Configuration.List, // Starting with List
componentFactory = ::createChild // The Router calls this function, providing the child Configuration and ComponentContext
childFactory = ::createChild // The Router calls this function, providing the child Configuration and ComponentContext
)
)
val routerState = router.state
val routerState = router.state
@ -279,8 +279,8 @@ class Root(
@Composable
@Composable
fun RootUi(root: Root) {
fun RootUi(root: Root) {
Children(root.routerState) { child, _ ->
Children(root.routerState) { child ->
child()
child.instance()
}
}
}
}
```
```
@ -326,47 +326,38 @@ By using this pattern, the navigation logic is kept and managed inside `@Composa
This pattern should be chosen if you prefer to use Compose for more than just UI, and none of the first pattern's points apply.
This pattern should be chosen if you prefer to use Compose for more than just UI, and none of the first pattern's points apply.
Decompose does not provide an out-of-the-box `Navigator` for pure `@Composable` world. But it is pretty easy to write your own with it. You can experiment and come up with your own API.
Decompose does not provide any out-of-the-box `@Composable` navigation API. But it is pretty easy to write your own with it. You can experiment and come up with your own API.
Please refer to the following article for an implementation of the `Navigator`: "[A comprehensive hundred-line navigation for Jetpack/Desktop Compose](https://proandroiddev.com/a-comprehensive-hundred-line-navigation-for-jetpack-desktop-compose-5b723c4f256e)". It also explains some additional features, like back button handling, transition animations, etc.
Please refer to the following article for implementation details: "[A comprehensive hundred-line navigation for Jetpack/Desktop Compose](https://proandroiddev.com/a-comprehensive-hundred-line-navigation-for-jetpack-desktop-compose-5b723c4f256e)". It also explains some additional features, like back button handling, transition animations, etc.
TODO("See the article mentioned above for the implementation")
val router = router<C>()
Children(router.state) { _, configuration ->
router.content(configuration)
}
}
@Composable
private fun <C:Parcelable> router(): Router<C,C> =
TODO("See the article mentioned above for an implementation")
```
```
First of all we need the `Router` from the Decompose library. Once we have it, all we need to do is to use the `Children` function. The `Children` function listens for the `Router` state changes, and renders the currently active child using the provided callback. The article mentioned above explains the implementation details.
First of all we need the `Router` from the Decompose library. Once we have it, all we need to do is to use the `Children` function. The `Children` function listens for the `Router` state changes, and renders the currently active child using the provided callback. The article mentioned above explains the implementation details.