Skip to content

Commit

Permalink
update precompose
Browse files Browse the repository at this point in the history
  • Loading branch information
a187839 committed Jan 18, 2024
1 parent 785d1fb commit b45a308
Show file tree
Hide file tree
Showing 2 changed files with 449 additions and 37 deletions.
51 changes: 14 additions & 37 deletions docs/src/more/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,14 @@ For this Hands-on Lab we will mainly focus on navigation feature of PreCompose.
val commonMain by getting {
dependencies {
...
api("moe.tlaster:precompose:1.5.7")
api("moe.tlaster:precompose:1.5.10")
...

```
:::

#### Replace `AndroidApp`, `desktopApp` root view by precompose view

::: details MaintActivity.kt (module : androidApp)
```kotlin
...
import moe.tlaster.precompose.lifecycle.PreComposeActivity
import moe.tlaster.precompose.lifecycle.setContent

class MainActivity : PreComposeActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AndroidApp()
...
```
:::

::: details Maint.kt (module : desktopApp)
```kotlin
...
import moe.tlaster.precompose.PreComposeWindow

fun main() = application { // kotlin application
PreComposeWindow(onCloseRequest = ::exitApplication, title = "QuizzApp") {
DesktopApp()
...
```
:::

::: details IosApp.kt (module : iosMain)
```kotlin
import moe.tlaster.precompose.PreComposeApplication
fun MainViewController(): UIViewController =
PreComposeApplication() {
App()
}
```
:::
#### Create your navigation host

The navigation host is the configuration class that defines routes
Expand Down Expand Up @@ -137,6 +101,19 @@ internal fun welcomeScreen(navigator: Navigator){
```
:::

### Declare your App composable as a PrecomposeApp
::: details App.kt (module : shared)
```kotlin

@Composable
fun App(){
MaterialApp{
PreComposeApp {
rootNavHost()
}
```
:::

#### Use the navigation host

##### instantiate the navHost on the App main composable.
Expand Down
Loading

0 comments on commit b45a308

Please sign in to comment.