Browse Source

TodoApp. Updated Kotlin to 1.7.10, Compose to 1.2.0, and other libs. (#2191)

pull/2407/head
Arkadii Ivanov 2 years ago committed by GitHub
parent
commit
d457a520d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      examples/todoapp/android/build.gradle.kts
  2. 1
      examples/todoapp/android/src/main/java/example/todo/android/MainActivity.kt
  3. 7
      examples/todoapp/build.gradle.kts
  4. 13
      examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt
  5. 2
      examples/todoapp/buildSrc/gradle.properties
  6. 6
      examples/todoapp/buildSrc/src/main/kotlin/android-setup.gradle.kts
  7. 32
      examples/todoapp/buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts
  8. 7
      examples/todoapp/common/compose-ui/build.gradle.kts
  9. 12
      examples/todoapp/common/compose-ui/src/commonMain/kotlin/example/todo/common/ui/TodoRootUi.kt
  10. 2
      examples/todoapp/common/database/build.gradle.kts
  11. 2
      examples/todoapp/common/edit/build.gradle.kts
  12. 2
      examples/todoapp/common/main/build.gradle.kts
  13. 10
      examples/todoapp/common/root/build.gradle.kts
  14. 4
      examples/todoapp/common/root/src/commonMain/kotlin/example/todo/common/root/TodoRoot.kt
  15. 22
      examples/todoapp/common/root/src/commonMain/kotlin/example/todo/common/root/integration/TodoRootComponent.kt
  16. 2
      examples/todoapp/common/root/src/commonTest/kotlin/example/todo/common/root/integration/TodoRootTest.kt
  17. 2
      examples/todoapp/common/utils/build.gradle.kts
  18. 7
      examples/todoapp/common/utils/src/commonMain/kotlin/example/todo/common/utils/StoreExt.kt
  19. 3
      examples/todoapp/gradle.properties
  20. BIN
      examples/todoapp/gradle/wrapper/gradle-wrapper.jar
  21. 263
      examples/todoapp/gradlew
  22. 33
      examples/todoapp/gradlew.bat
  23. 10
      examples/todoapp/ios/TodoApp.xcodeproj/project.pbxproj
  24. 10
      examples/todoapp/ios/ios/RootView.swift
  25. 6
      examples/todoapp/ios/ios/SimpleChildStack.swift
  26. 3047
      examples/todoapp/kotlin-js-store/yarn.lock
  27. 1
      examples/todoapp/web/build.gradle.kts
  28. 6
      examples/todoapp/web/src/jsMain/kotlin/example/todo/web/TodoRootUi.kt
  29. 3
      examples/todoapp/web/src/jsMain/kotlin/example/todo/web/ValueExt.kt

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

@ -5,11 +5,11 @@ plugins {
}
android {
compileSdk = 32
compileSdk = 33
defaultConfig {
minSdk = 26
targetSdk = 32
targetSdk = 33
versionCode = 1
versionName = "1.0"
}
@ -38,4 +38,7 @@ dependencies {
implementation(Deps.ArkIvanov.Decompose.extensionsCompose)
implementation(Deps.AndroidX.AppCompat.appCompat)
implementation(Deps.AndroidX.Activity.activityCompose)
// Workaround for https://github.com/JetBrains/compose-jb/issues/2340
implementation("androidx.compose.material:material:${Deps.JetpackComposeWorkaround.VERSION}")
}

1
examples/todoapp/android/src/main/java/example/todo/android/MainActivity.kt

@ -8,7 +8,6 @@ import androidx.compose.material.Surface
import com.arkivanov.decompose.ComponentContext
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
import example.todo.common.database.DefaultTodoSharedDatabase
import example.todo.common.database.TodoDatabaseDriver

7
examples/todoapp/build.gradle.kts

@ -9,4 +9,11 @@ allprojects {
mavenLocal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
afterEvaluate {
// Workaround for https://youtrack.jetbrains.com/issue/KT-52776
rootProject.extensions.findByType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>()?.apply {
versions.webpackCli.version = "4.10.0"
}
}
}

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

@ -10,6 +10,11 @@ fun initDeps(project: Project) {
}
object Deps {
object JetpackComposeWorkaround {
// Workaround for https://github.com/JetBrains/compose-jb/issues/2340
val VERSION: String = "1.2.1"
}
object JetBrains {
object Kotlin {
private val VERSION get() = properties["kotlin.version"]
@ -34,7 +39,7 @@ object Deps {
object Android {
object Tools {
object Build {
const val gradlePlugin = "com.android.tools.build:gradle:7.0.4"
const val gradlePlugin = "com.android.tools.build:gradle:7.2.0"
}
}
}
@ -51,7 +56,7 @@ object Deps {
object ArkIvanov {
object MVIKotlin {
private const val VERSION = "3.0.0-beta01"
private const val VERSION = "3.0.0"
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"
@ -61,13 +66,13 @@ object Deps {
}
object Decompose {
private const val VERSION = "0.5.1"
private const val VERSION = "1.0.0-alpha-05"
const val decompose = "com.arkivanov.decompose:decompose:$VERSION"
const val extensionsCompose = "com.arkivanov.decompose:extensions-compose-jetbrains:$VERSION"
}
object Essenty {
private const val VERSION = "0.2.2"
private const val VERSION = "0.6.0"
const val lifecycle = "com.arkivanov.essenty:lifecycle:$VERSION"
}
}

2
examples/todoapp/buildSrc/gradle.properties

@ -1,3 +1,3 @@
# TODO can we get rid of duplication with root gradle.properties?
kotlin.version=1.7.10
compose.version=1.2.0-rc02
compose.version=1.2.0

6
examples/todoapp/buildSrc/src/main/kotlin/android-setup.gradle.kts

@ -5,11 +5,11 @@ plugins {
initDeps(project)
android {
compileSdkVersion(31)
compileSdk = 33
defaultConfig {
minSdkVersion(23)
targetSdkVersion(31)
minSdk = 23
targetSdk = 33
}
compileOptions {

32
examples/todoapp/buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts

@ -8,13 +8,43 @@ initDeps(project)
kotlin {
jvm("desktop")
android()
ios()
iosX64()
iosArm64()
iosSimulatorArm64()
js(IR) {
browser()
}
sourceSets {
create("iosMain") {
dependsOn(getByName("commonMain"))
}
create("iosTest") {
dependsOn(getByName("commonTest"))
}
getByName("iosX64Main") {
dependsOn(getByName("iosMain"))
}
getByName("iosX64Test") {
dependsOn(getByName("iosTest"))
}
getByName("iosArm64Main") {
dependsOn(getByName("iosMain"))
}
getByName("iosArm64Test") {
dependsOn(getByName("iosTest"))
}
getByName("iosSimulatorArm64Main") {
dependsOn(getByName("iosMain"))
}
getByName("iosSimulatorArm64Test") {
dependsOn(getByName("iosTest"))
}
named("commonTest") {
dependencies {
implementation(Deps.JetBrains.Kotlin.testCommon)

7
examples/todoapp/common/compose-ui/build.gradle.kts

@ -14,5 +14,12 @@ kotlin {
implementation(Deps.ArkIvanov.Decompose.extensionsCompose)
}
}
named("androidMain") {
dependencies {
// Workaround for https://github.com/JetBrains/compose-jb/issues/2340
implementation("androidx.compose.foundation:foundation:${Deps.JetpackComposeWorkaround.VERSION}")
}
}
}
}

12
examples/todoapp/common/compose-ui/src/commonMain/kotlin/example/todo/common/ui/TodoRootUi.kt

@ -3,14 +3,20 @@
package example.todo.common.ui
import androidx.compose.runtime.Composable
import com.arkivanov.decompose.extensions.compose.jetbrains.Children
import com.arkivanov.decompose.extensions.compose.jetbrains.animation.child.crossfadeScale
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.Children
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.fade
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.plus
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.scale
import com.arkivanov.decompose.extensions.compose.jetbrains.stack.animation.stackAnimation
import example.todo.common.root.TodoRoot
import example.todo.common.root.TodoRoot.Child
@Composable
fun TodoRootContent(component: TodoRoot) {
Children(routerState = component.routerState, animation = crossfadeScale()) {
Children(
stack = component.childStack,
animation = stackAnimation(fade() + scale()),
) {
when (val child = it.instance) {
is Child.Main -> TodoMainContent(child.component)
is Child.Edit -> TodoEditContent(child.component)

2
examples/todoapp/common/database/build.gradle.kts

@ -11,8 +11,6 @@ sqldelight {
}
kotlin {
iosWorkaroundSupportArm64Simulator {}
sourceSets {
commonMain {
dependencies {

2
examples/todoapp/common/edit/build.gradle.kts

@ -4,8 +4,6 @@ plugins {
}
kotlin {
iosWorkaroundSupportArm64Simulator {}
sourceSets {
named("commonMain") {
dependencies {

2
examples/todoapp/common/main/build.gradle.kts

@ -4,8 +4,6 @@ plugins {
}
kotlin {
iosWorkaroundSupportArm64Simulator {}
sourceSets {
named("commonMain") {
dependencies {

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

@ -1,3 +1,6 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.konan.target.Family
plugins {
id("multiplatform-setup")
id("android-setup")
@ -5,8 +8,11 @@ plugins {
}
kotlin {
iosWorkaroundSupportArm64Simulator {
binaries {
targets
.filterIsInstance<KotlinNativeTarget>()
.filter { it.konanTarget.family == Family.IOS }
.forEach { target ->
target.binaries {
framework {
baseName = "Todo"
linkerOpts.add("-lsqlite3")

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

@ -1,13 +1,13 @@
package example.todo.common.root
import com.arkivanov.decompose.router.RouterState
import com.arkivanov.decompose.router.stack.ChildStack
import com.arkivanov.decompose.value.Value
import example.todo.common.edit.TodoEdit
import example.todo.common.main.TodoMain
interface TodoRoot {
val routerState: Value<RouterState<*, Child>>
val childStack: Value<ChildStack<*, Child>>
sealed class Child {
data class Main(val component: TodoMain) : Child()

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

@ -1,10 +1,11 @@
package example.todo.common.root.integration
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.router.RouterState
import com.arkivanov.decompose.router.pop
import com.arkivanov.decompose.router.push
import com.arkivanov.decompose.router.router
import com.arkivanov.decompose.router.stack.ChildStack
import com.arkivanov.decompose.router.stack.StackNavigation
import com.arkivanov.decompose.router.stack.childStack
import com.arkivanov.decompose.router.stack.pop
import com.arkivanov.decompose.router.stack.push
import com.arkivanov.decompose.value.Value
import com.arkivanov.essenty.parcelable.Parcelable
import com.arkivanov.essenty.parcelable.Parcelize
@ -50,14 +51,17 @@ class TodoRootComponent internal constructor(
}
)
private val router =
router<Configuration, Child>(
private val navigation = StackNavigation<Configuration>()
private val stack =
childStack(
source = navigation,
initialConfiguration = Configuration.Main,
handleBackButton = true,
childFactory = ::createChild
)
override val routerState: Value<RouterState<*, Child>> = router.state
override val childStack: Value<ChildStack<*, Child>> = stack
private fun createChild(configuration: Configuration, componentContext: ComponentContext): Child =
when (configuration) {
@ -67,12 +71,12 @@ class TodoRootComponent internal constructor(
private fun onMainOutput(output: TodoMain.Output): Unit =
when (output) {
is TodoMain.Output.Selected -> router.push(Configuration.Edit(itemId = output.id))
is TodoMain.Output.Selected -> navigation.push(Configuration.Edit(itemId = output.id))
}
private fun onEditOutput(output: TodoEdit.Output): Unit =
when (output) {
is TodoEdit.Output.Finished -> router.pop()
is TodoEdit.Output.Finished -> navigation.pop()
}
private sealed class Configuration : Parcelable {

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

@ -51,7 +51,7 @@ class TodoRootTest {
todoEdit = { _, itemId, output -> TodoEditFake(itemId, output) }
)
private val TodoRoot.activeChild: Child get() = routerState.value.activeChild.instance
private val TodoRoot.activeChild: Child get() = childStack.value.active.instance
private val Child.component: Any
get() =

2
examples/todoapp/common/utils/build.gradle.kts

@ -4,8 +4,6 @@ plugins {
}
kotlin {
iosWorkaroundSupportArm64Simulator {}
sourceSets {
named("commonMain") {
dependencies {

7
examples/todoapp/common/utils/src/commonMain/kotlin/example/todo/common/utils/StoreExt.kt

@ -1,21 +1,20 @@
package example.todo.common.utils
import com.arkivanov.decompose.value.Value
import com.arkivanov.decompose.value.ValueObserver
import com.arkivanov.mvikotlin.core.store.Store
import com.arkivanov.mvikotlin.rx.Disposable
fun <T : Any> Store<*, T, *>.asValue(): Value<T> =
object : Value<T>() {
override val value: T get() = state
private var disposables = emptyMap<ValueObserver<T>, Disposable>()
private var disposables = emptyMap<(T) -> Unit, Disposable>()
override fun subscribe(observer: ValueObserver<T>) {
override fun subscribe(observer: (T) -> Unit) {
val disposable = states(com.arkivanov.mvikotlin.rx.observer(onNext = observer))
this.disposables += observer to disposable
}
override fun unsubscribe(observer: ValueObserver<T>) {
override fun unsubscribe(observer: (T) -> Unit) {
val disposable = disposables[observer] ?: return
this.disposables -= observer
disposable.dispose()

3
examples/todoapp/gradle.properties

@ -23,6 +23,9 @@ org.gradle.parallel=true
org.gradle.caching=true
kotlin.native.disableCompilerDaemon=true
#TODO remove workaround after upgrading to AGP 7.3
# After updating Compose Multiplatform version, update corresponding Jetpack Compose versions
# in Android module (search "Workaround for https://github.com/JetBrains/compose-jb/issues/2340")
#TODO also change version in buildSrc/gradle.properties
kotlin.version=1.7.10
compose.version=1.2.0

BIN
examples/todoapp/gradle/wrapper/gradle-wrapper.jar vendored

Binary file not shown.

263
examples/todoapp/gradlew vendored

@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,67 +17,101 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -106,80 +140,101 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
i=`expr $i + 1`
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

33
examples/todoapp/gradlew.bat vendored

@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
@ -86,17 +71,19 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

10
examples/todoapp/ios/TodoApp.xcodeproj/project.pbxproj

@ -18,7 +18,7 @@
1F00F3B02575ADB500CFAF97 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F00F3AF2575ADB500CFAF97 /* MainView.swift */; };
1F00F3B22575B07700CFAF97 /* EditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F00F3B12575B07700CFAF97 /* EditView.swift */; };
1F00F3B42575B18200CFAF97 /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F00F3B32575B18200CFAF97 /* RootView.swift */; };
1F00F3B62575B41900CFAF97 /* SimpleRouterState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F00F3B52575B41900CFAF97 /* SimpleRouterState.swift */; };
1F00F3B62575B41900CFAF97 /* SimpleChildStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F00F3B52575B41900CFAF97 /* SimpleChildStack.swift */; };
1F00F3B82575B4F800CFAF97 /* ComponentHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F00F3B72575B4F800CFAF97 /* ComponentHolder.swift */; };
/* End PBXBuildFile section */
@ -37,7 +37,7 @@
1F00F3AF2575ADB500CFAF97 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
1F00F3B12575B07700CFAF97 /* EditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditView.swift; sourceTree = "<group>"; };
1F00F3B32575B18200CFAF97 /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = "<group>"; };
1F00F3B52575B41900CFAF97 /* SimpleRouterState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleRouterState.swift; sourceTree = "<group>"; };
1F00F3B52575B41900CFAF97 /* SimpleChildStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleChildStack.swift; sourceTree = "<group>"; };
1F00F3B72575B4F800CFAF97 /* ComponentHolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComponentHolder.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -84,7 +84,7 @@
1F00F3AF2575ADB500CFAF97 /* MainView.swift */,
1F00F3B12575B07700CFAF97 /* EditView.swift */,
1F00F3B32575B18200CFAF97 /* RootView.swift */,
1F00F3B52575B41900CFAF97 /* SimpleRouterState.swift */,
1F00F3B52575B41900CFAF97 /* SimpleChildStack.swift */,
1F00F3B72575B4F800CFAF97 /* ComponentHolder.swift */,
);
path = ios;
@ -187,7 +187,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd $SRCROOT/..\n./gradlew :common:root:embedAndSignAppleFrameworkForXcode";
shellScript = "cd $SRCROOT/..\n./gradlew :common:root:embedAndSignAppleFrameworkForXcode\n";
};
/* End PBXShellScriptBuildPhase section */
@ -203,7 +203,7 @@
1F00F3AC2575AA4500CFAF97 /* ListView.swift in Sources */,
1F00F3B82575B4F800CFAF97 /* ComponentHolder.swift in Sources */,
1F00F3B42575B18200CFAF97 /* RootView.swift in Sources */,
1F00F3B62575B41900CFAF97 /* SimpleRouterState.swift in Sources */,
1F00F3B62575B41900CFAF97 /* SimpleChildStack.swift in Sources */,
1F00F3AE2575AC6A00CFAF97 /* InputView.swift in Sources */,
1F00F3AA2575A71000CFAF97 /* MutableStateBuilder.swift in Sources */,
1F00F3A82575A16400CFAF97 /* ObservableValue.swift in Sources */,

10
examples/todoapp/ios/ios/RootView.swift

@ -3,14 +3,14 @@ import Todo
struct RootView: View {
@ObservedObject
private var routerStates: ObservableValue<RouterState<AnyObject, TodoRootChild>>
private var childStack: ObservableValue<ChildStack<AnyObject, TodoRootChild>>
init(_ component: TodoRoot) {
self.routerStates = ObservableValue(component.routerState)
self.childStack = ObservableValue(component.childStack)
}
var body: some View {
let child = self.routerStates.value.activeChild.instance
let child = self.childStack.value.active.instance
switch child {
case let main as TodoRootChild.Main:
@ -37,7 +37,7 @@ struct RootView_Previews: PreviewProvider {
}
class StubTodoRoot : TodoRoot {
let routerState: Value<RouterState<AnyObject, TodoRootChild>> =
simpleRouterState(TodoRootChild.Main(component: MainView_Previews.StubTodoMain()))
let childStack: Value<ChildStack<AnyObject, TodoRootChild>> =
simpleChildStack(.Main(component: MainView_Previews.StubTodoMain()))
}
}

6
examples/todoapp/ios/ios/SimpleRouterState.swift → examples/todoapp/ios/ios/SimpleChildStack.swift

@ -1,9 +1,9 @@
import Todo
func simpleRouterState<T : AnyObject>(_ child: T) -> Value<RouterState<AnyObject, T>> {
func simpleChildStack<T : AnyObject>(_ child: T) -> Value<ChildStack<AnyObject, T>> {
return valueOf(
RouterState(
activeChild: ChildCreated(
ChildStack(
active: ChildCreated(
configuration: "config" as AnyObject,
instance: child
),

3047
examples/todoapp/kotlin-js-store/yarn.lock

File diff suppressed because it is too large Load Diff

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

@ -1,5 +1,4 @@
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.compose.compose
plugins {
kotlin("multiplatform")

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

@ -4,9 +4,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import example.todo.common.root.TodoRoot
import org.jetbrains.compose.web.css.Position
import org.jetbrains.compose.web.css.keywords.auto
import org.jetbrains.compose.web.css.bottom
import org.jetbrains.compose.web.css.height
import org.jetbrains.compose.web.css.keywords.auto
import org.jetbrains.compose.web.css.left
import org.jetbrains.compose.web.css.percent
import org.jetbrains.compose.web.css.position
@ -31,10 +31,10 @@ fun TodoRootUi(component: TodoRoot) {
}
}
) {
val routerState by component.routerState.subscribeAsState()
val childStack by component.childStack.subscribeAsState()
Crossfade(
target = routerState.activeChild.instance,
target = childStack.active.instance,
attrs = {
style {
width(100.percent)

3
examples/todoapp/web/src/jsMain/kotlin/example/todo/web/ValueExt.kt

@ -6,14 +6,13 @@ import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import com.arkivanov.decompose.value.Value
import com.arkivanov.decompose.value.ValueObserver
@Composable
fun <T : Any> Value<T>.subscribeAsState(): State<T> {
val state = remember(this) { mutableStateOf(value) }
DisposableEffect(this) {
val observer: ValueObserver<T> = { state.value = it }
val observer: (T) -> Unit = { state.value = it }
subscribe(observer)

Loading…
Cancel
Save