Browse Source

TodoApp update Compose to build168 and Decompose to 0.1.9 (#424)

pull/433/head
Arkadii Ivanov 4 years ago committed by GitHub
parent
commit
4f19363222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      examples/todoapp/android/build.gradle.kts
  2. 4
      examples/todoapp/android/src/main/java/example/todo/android/MainActivity.kt
  3. 5
      examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt
  4. 11
      examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt
  5. 6
      tutorials/Navigation/README.md

1
examples/todoapp/android/build.gradle.kts

@ -39,6 +39,5 @@ dependencies {
implementation(Deps.ArkIvanov.Decompose.decompose) implementation(Deps.ArkIvanov.Decompose.decompose)
implementation(Deps.ArkIvanov.Decompose.extensionsCompose) implementation(Deps.ArkIvanov.Decompose.extensionsCompose)
implementation(Deps.AndroidX.AppCompat.appCompat) implementation(Deps.AndroidX.AppCompat.appCompat)
implementation(Deps.AndroidX.Activity.activityCompose) implementation(Deps.AndroidX.Activity.activityCompose)
} }

4
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.MaterialTheme
import androidx.compose.material.Surface import androidx.compose.material.Surface
import com.arkivanov.decompose.ComponentContext 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.core.store.StoreFactory
import com.arkivanov.mvikotlin.logging.store.LoggingStoreFactory import com.arkivanov.mvikotlin.logging.store.LoggingStoreFactory
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
@ -23,7 +23,7 @@ class MainActivity : AppCompatActivity() {
setContent { setContent {
ComposeAppTheme { ComposeAppTheme {
Surface(color = MaterialTheme.colors.background) { Surface(color = MaterialTheme.colors.background) {
TodoRootContent(rootComponent(::todoRoot)) TodoRootContent(rememberRootComponent(::todoRoot))
} }
} }
} }

5
examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt

@ -12,8 +12,7 @@ object Deps {
object Compose { object Compose {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
// TODO remove exclude(group = "org.jetbrains.compose.desktop") private const val VERSION = "0.4.0-build168"
private const val VERSION = "0.3.0"
const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION" const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"
} }
} }
@ -50,7 +49,7 @@ object Deps {
} }
object Decompose { 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 decompose = "com.arkivanov.decompose:decompose:$VERSION"
const val decomposeIosX64 = "com.arkivanov.decompose:decompose-iosx64:$VERSION" const val decomposeIosX64 = "com.arkivanov.decompose:decompose-iosx64:$VERSION"
const val decomposeIosArm64 = "com.arkivanov.decompose:decompose-iosarm64:$VERSION" const val decomposeIosArm64 = "com.arkivanov.decompose:decompose-iosarm64:$VERSION"

11
examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt

@ -1,6 +1,5 @@
package example.todo.desktop package example.todo.desktop
import androidx.compose.desktop.AppWindow
import androidx.compose.desktop.DesktopTheme import androidx.compose.desktop.DesktopTheme
import androidx.compose.desktop.Window import androidx.compose.desktop.Window
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
@ -8,9 +7,7 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface import androidx.compose.material.Surface
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import com.arkivanov.decompose.ComponentContext import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.extensions.compose.jetbrains.rootComponent import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent
import com.arkivanov.decompose.lifecycle.LifecycleRegistry
import com.arkivanov.decompose.lifecycle.resume
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
import com.badoo.reaktive.coroutinesinterop.asScheduler import com.badoo.reaktive.coroutinesinterop.asScheduler
import com.badoo.reaktive.scheduler.overrideSchedulers 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.common.ui.TodoRootContent
import example.todo.database.TodoDatabase import example.todo.database.TodoDatabase
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import javax.swing.SwingUtilities
fun main() { fun main() {
overrideSchedulers(main = Dispatchers.Main::asScheduler) overrideSchedulers(main = Dispatchers.Main::asScheduler)
val lifecycle = LifecycleRegistry()
lifecycle.resume()
Window("Todo") { Window("Todo") {
Surface(modifier = Modifier.fillMaxSize()) { Surface(modifier = Modifier.fillMaxSize()) {
MaterialTheme { MaterialTheme {
DesktopTheme { DesktopTheme {
TodoRootContent(rootComponent(factory = ::todoRoot)) TodoRootContent(rememberRootComponent(factory = ::todoRoot))
} }
} }
} }

6
tutorials/Navigation/README.md

@ -295,7 +295,7 @@ import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface import androidx.compose.material.Surface
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import com.arkivanov.decompose.extensions.compose.jetbrains.rootComponent import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent
fun main() { fun main() {
Window("Navigation tutorial") { Window("Navigation tutorial") {
@ -311,8 +311,8 @@ fun main() {
@Composable @Composable
private fun root(): Root = private fun root(): Root =
// The rootComponent function provides the root ComponentContext and remembers the instance or Root // The rememberRootComponent function provides the root ComponentContext and remembers the instance or Root
rootComponent { componentContext -> rememberRootComponent { componentContext ->
Root( Root(
componentContext = componentContext, componentContext = componentContext,
database = DatabaseImpl() // Supply dependencies database = DatabaseImpl() // Supply dependencies

Loading…
Cancel
Save