Browse Source

Update TodoApp dependencies (#1001)

pull/1037/head
Arkadii Ivanov 3 years ago committed by GitHub
parent
commit
696d20c931
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      examples/todoapp/android/src/main/java/example/todo/android/MainActivity.kt
  2. 6
      examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt
  3. 4
      examples/todoapp/common/main/src/commonTest/kotlin/example/todo/common/main/integration/TodoMainTest.kt
  4. 2
      examples/todoapp/common/main/src/commonTest/kotlin/example/todo/common/main/store/TodoMainStoreTest.kt
  5. 1
      examples/todoapp/common/root/build.gradle.kts
  6. 4
      examples/todoapp/common/root/src/commonMain/kotlin/example/todo/common/root/integration/TodoRootComponent.kt
  7. 4
      examples/todoapp/common/root/src/commonTest/kotlin/example/todo/common/root/integration/TodoRootTest.kt
  8. 4
      examples/todoapp/common/utils/src/commonMain/kotlin/example/todo/common/utils/InstanceKeeperExt.kt
  9. 31
      examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt
  10. 6
      examples/todoapp/web/src/jsMain/kotlin/example/todo/web/App.kt

8
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.rememberRootComponent
import com.arkivanov.decompose.defaultComponentContext
import com.arkivanov.mvikotlin.logging.store.LoggingStoreFactory
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
import com.arkivanov.mvikotlin.timetravel.store.TimeTravelStoreFactory
@ -20,10 +20,12 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val root = todoRoot(defaultComponentContext())
setContent {
ComposeAppTheme {
Surface(color = MaterialTheme.colors.background) {
TodoRootContent(rememberRootComponent(::todoRoot))
TodoRootContent(root)
}
}
}
@ -32,7 +34,7 @@ class MainActivity : AppCompatActivity() {
private fun todoRoot(componentContext: ComponentContext): TodoRoot =
TodoRootComponent(
componentContext = componentContext,
storeFactory = LoggingStoreFactory(TimeTravelStoreFactory(DefaultStoreFactory)),
storeFactory = LoggingStoreFactory(TimeTravelStoreFactory(DefaultStoreFactory())),
database = DefaultTodoSharedDatabase(TodoDatabaseDriver(context = this))
)
}

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

@ -13,7 +13,7 @@ object Deps {
object Compose {
// __LATEST_COMPOSE_RELEASE_VERSION__
private const val VERSION = "1.0.0-alpha1"
private const val VERSION = "1.0.0-alpha2"
const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"
}
}
@ -38,7 +38,7 @@ object Deps {
object ArkIvanov {
object MVIKotlin {
private const val VERSION = "2.0.3"
private const val VERSION = "3.0.0-alpha01"
const val rx = "com.arkivanov.mvikotlin:rx:$VERSION"
const val mvikotlin = "com.arkivanov.mvikotlin:mvikotlin:$VERSION"
const val mvikotlinMain = "com.arkivanov.mvikotlin:mvikotlin-main:$VERSION"
@ -48,7 +48,7 @@ object Deps {
}
object Decompose {
private const val VERSION = "0.2.6"
private const val VERSION = "0.3.1"
const val decompose = "com.arkivanov.decompose:decompose:$VERSION"
const val extensionsCompose = "com.arkivanov.decompose:extensions-compose-jetbrains:$VERSION"
}

4
examples/todoapp/common/main/src/commonTest/kotlin/example/todo/common/main/integration/TodoMainTest.kt

@ -1,7 +1,7 @@
package example.todo.common.main.integration
import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.decompose.lifecycle.LifecycleRegistry
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
import com.badoo.reaktive.scheduler.overrideSchedulers
import com.badoo.reaktive.subject.publish.PublishSubject
@ -32,7 +32,7 @@ class TodoMainTest {
private val impl by lazy {
TodoMainComponent(
componentContext = DefaultComponentContext(lifecycle = lifecycle),
storeFactory = DefaultStoreFactory,
storeFactory = DefaultStoreFactory(),
database = database,
output = outputSubject
)

2
examples/todoapp/common/main/src/commonTest/kotlin/example/todo/common/main/store/TodoMainStoreTest.kt

@ -15,7 +15,7 @@ import kotlin.test.assertTrue
class TodoMainStoreTest {
private val database = TestTodoMainStoreDatabase()
private val provider = TodoMainStoreProvider(storeFactory = DefaultStoreFactory, database = database)
private val provider = TodoMainStoreProvider(storeFactory = DefaultStoreFactory(), database = database)
@BeforeTest
fun before() {

1
examples/todoapp/common/root/build.gradle.kts

@ -11,6 +11,7 @@ kotlin {
binaries {
framework {
baseName = "Todo"
transitiveExport = true
linkerOpts.add("-lsqlite3")
export(project(":common:database"))
export(project(":common:main"))

4
examples/todoapp/common/root/src/commonMain/kotlin/example/todo/common/root/integration/TodoRootComponent.kt

@ -5,9 +5,9 @@ import com.arkivanov.decompose.RouterState
import com.arkivanov.decompose.pop
import com.arkivanov.decompose.push
import com.arkivanov.decompose.router
import com.arkivanov.decompose.statekeeper.Parcelable
import com.arkivanov.decompose.statekeeper.Parcelize
import com.arkivanov.decompose.value.Value
import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
import com.arkivanov.mvikotlin.core.store.StoreFactory
import com.badoo.reaktive.base.Consumer
import example.todo.common.database.TodoSharedDatabase

4
examples/todoapp/common/root/src/commonTest/kotlin/example/todo/common/root/integration/TodoRootTest.kt

@ -1,8 +1,8 @@
package example.todo.common.root.integration
import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.decompose.lifecycle.LifecycleRegistry
import com.arkivanov.decompose.lifecycle.resume
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
import com.arkivanov.essenty.lifecycle.resume
import com.badoo.reaktive.base.invoke
import example.todo.common.edit.TodoEdit
import example.todo.common.main.TodoMain

4
examples/todoapp/common/utils/src/commonMain/kotlin/example/todo/common/utils/InstanceKeeperExt.kt

@ -1,7 +1,7 @@
package example.todo.common.utils
import com.arkivanov.decompose.instancekeeper.InstanceKeeper
import com.arkivanov.decompose.instancekeeper.getOrCreate
import com.arkivanov.essenty.instancekeeper.InstanceKeeper
import com.arkivanov.essenty.instancekeeper.getOrCreate
import com.arkivanov.mvikotlin.core.store.Store
fun <T : Store<*, *, *>> InstanceKeeper.getStore(key: Any, factory: () -> T): T =

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

@ -1,13 +1,18 @@
package example.todo.desktop
import androidx.compose.desktop.DesktopTheme
import androidx.compose.desktop.Window
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.ui.Modifier
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.decompose.extensions.compose.jetbrains.lifecycle.LifecycleController
import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
import com.badoo.reaktive.coroutinesinterop.asScheduler
import com.badoo.reaktive.scheduler.overrideSchedulers
@ -21,11 +26,23 @@ import kotlinx.coroutines.Dispatchers
fun main() {
overrideSchedulers(main = Dispatchers.Main::asScheduler)
Window("Todo") {
Surface(modifier = Modifier.fillMaxSize()) {
MaterialTheme {
DesktopTheme {
TodoRootContent(rememberRootComponent(factory = ::todoRoot))
val lifecycle = LifecycleRegistry()
val root = todoRoot(DefaultComponentContext(lifecycle = lifecycle))
application {
val windowState = rememberWindowState()
LifecycleController(lifecycle, windowState)
Window(
onCloseRequest = ::exitApplication,
state = windowState,
title = "Todo"
) {
Surface(modifier = Modifier.fillMaxSize()) {
MaterialTheme {
DesktopTheme {
TodoRootContent(root)
}
}
}
}
@ -35,6 +52,6 @@ fun main() {
private fun todoRoot(componentContext: ComponentContext): TodoRoot =
TodoRootComponent(
componentContext = componentContext,
storeFactory = DefaultStoreFactory,
storeFactory = DefaultStoreFactory(),
database = DefaultTodoSharedDatabase(TodoDatabaseDriver())
)

6
examples/todoapp/web/src/jsMain/kotlin/example/todo/web/App.kt

@ -1,8 +1,8 @@
package example.todo.web
import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.decompose.lifecycle.LifecycleRegistry
import com.arkivanov.decompose.lifecycle.resume
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
import com.arkivanov.essenty.lifecycle.resume
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
import example.todo.common.database.DefaultTodoSharedDatabase
import example.todo.common.database.todoDatabaseDriver
@ -21,7 +21,7 @@ fun main() {
val root =
TodoRootComponent(
componentContext = DefaultComponentContext(lifecycle = lifecycle),
storeFactory = DefaultStoreFactory,
storeFactory = DefaultStoreFactory(),
database = DefaultTodoSharedDatabase(todoDatabaseDriver())
)

Loading…
Cancel
Save