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.extensionsCompose)
implementation(Deps.AndroidX.AppCompat.appCompat)
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.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))
}
}
}

5
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"

11
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))
}
}
}

6
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

Loading…
Cancel
Save