From 4f193632225924346d736b1bc7aebf984ee8e679 Mon Sep 17 00:00:00 2001 From: Arkadii Ivanov Date: Fri, 26 Feb 2021 06:16:59 +0000 Subject: [PATCH] TodoApp update Compose to build168 and Decompose to 0.1.9 (#424) --- examples/todoapp/android/build.gradle.kts | 1 - .../main/java/example/todo/android/MainActivity.kt | 4 ++-- .../todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt | 5 ++--- .../src/jvmMain/kotlin/example/todo/desktop/Main.kt | 11 ++--------- tutorials/Navigation/README.md | 6 +++--- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/examples/todoapp/android/build.gradle.kts b/examples/todoapp/android/build.gradle.kts index d1f74184a4..db65529e29 100755 --- a/examples/todoapp/android/build.gradle.kts +++ b/examples/todoapp/android/build.gradle.kts @@ -39,6 +39,5 @@ dependencies { implementation(Deps.ArkIvanov.Decompose.decompose) implementation(Deps.ArkIvanov.Decompose.extensionsCompose) implementation(Deps.AndroidX.AppCompat.appCompat) - implementation(Deps.AndroidX.Activity.activityCompose) } diff --git a/examples/todoapp/android/src/main/java/example/todo/android/MainActivity.kt b/examples/todoapp/android/src/main/java/example/todo/android/MainActivity.kt index 08bdad60cb..1b4a00d86a 100755 --- a/examples/todoapp/android/src/main/java/example/todo/android/MainActivity.kt +++ b/examples/todoapp/android/src/main/java/example/todo/android/MainActivity.kt @@ -6,7 +6,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import com.arkivanov.decompose.ComponentContext -import com.arkivanov.decompose.extensions.compose.jetbrains.rootComponent +import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent import com.arkivanov.mvikotlin.core.store.StoreFactory import com.arkivanov.mvikotlin.logging.store.LoggingStoreFactory import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory @@ -23,7 +23,7 @@ class MainActivity : AppCompatActivity() { setContent { ComposeAppTheme { Surface(color = MaterialTheme.colors.background) { - TodoRootContent(rootComponent(::todoRoot)) + TodoRootContent(rememberRootComponent(::todoRoot)) } } } diff --git a/examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt b/examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt index 705fa02dfc..bdefd86ead 100644 --- a/examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt +++ b/examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt @@ -12,8 +12,7 @@ object Deps { object Compose { // __LATEST_COMPOSE_RELEASE_VERSION__ - // TODO remove exclude(group = "org.jetbrains.compose.desktop") - private const val VERSION = "0.3.0" + private const val VERSION = "0.4.0-build168" const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION" } } @@ -50,7 +49,7 @@ object Deps { } object Decompose { - private const val VERSION = "0.1.8" + private const val VERSION = "0.1.9" const val decompose = "com.arkivanov.decompose:decompose:$VERSION" const val decomposeIosX64 = "com.arkivanov.decompose:decompose-iosx64:$VERSION" const val decomposeIosArm64 = "com.arkivanov.decompose:decompose-iosarm64:$VERSION" diff --git a/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt b/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt index a89355d1e0..64cd6e2a01 100644 --- a/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt +++ b/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt @@ -1,6 +1,5 @@ package example.todo.desktop -import androidx.compose.desktop.AppWindow import androidx.compose.desktop.DesktopTheme import androidx.compose.desktop.Window import androidx.compose.foundation.layout.fillMaxSize @@ -8,9 +7,7 @@ import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.ui.Modifier import com.arkivanov.decompose.ComponentContext -import com.arkivanov.decompose.extensions.compose.jetbrains.rootComponent -import com.arkivanov.decompose.lifecycle.LifecycleRegistry -import com.arkivanov.decompose.lifecycle.resume +import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory import com.badoo.reaktive.coroutinesinterop.asScheduler import com.badoo.reaktive.scheduler.overrideSchedulers @@ -19,19 +16,15 @@ import example.todo.common.root.TodoRoot import example.todo.common.ui.TodoRootContent import example.todo.database.TodoDatabase import kotlinx.coroutines.Dispatchers -import javax.swing.SwingUtilities fun main() { overrideSchedulers(main = Dispatchers.Main::asScheduler) - val lifecycle = LifecycleRegistry() - lifecycle.resume() - Window("Todo") { Surface(modifier = Modifier.fillMaxSize()) { MaterialTheme { DesktopTheme { - TodoRootContent(rootComponent(factory = ::todoRoot)) + TodoRootContent(rememberRootComponent(factory = ::todoRoot)) } } } diff --git a/tutorials/Navigation/README.md b/tutorials/Navigation/README.md index 12b6ff040e..2932fb432d 100644 --- a/tutorials/Navigation/README.md +++ b/tutorials/Navigation/README.md @@ -295,7 +295,7 @@ import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import com.arkivanov.decompose.extensions.compose.jetbrains.rootComponent +import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent fun main() { Window("Navigation tutorial") { @@ -311,8 +311,8 @@ fun main() { @Composable private fun root(): Root = - // The rootComponent function provides the root ComponentContext and remembers the instance or Root - rootComponent { componentContext -> + // The rememberRootComponent function provides the root ComponentContext and remembers the instance or Root + rememberRootComponent { componentContext -> Root( componentContext = componentContext, database = DatabaseImpl() // Supply dependencies