From 581b5f0b0af764c855adb53bf2aa75bc2ca6972f Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Wed, 21 Jul 2021 11:24:17 +0300 Subject: [PATCH 1/3] Update Compose + Migrate to 0.5.0-build262 / Kotlin 1.5.21 (#916) --- ci/compose-uber-jar/gradle.properties | 2 +- components/build.gradle.kts | 2 +- components/gradle.properties | 2 +- compose/frameworks/support | 2 +- .../compose/test/TestKotlinVersion.kt | 2 +- gradle-plugins/gradle.properties | 2 +- templates/desktop-template/build.gradle.kts | 4 +- .../multiplatform-template/build.gradle.kts | 4 +- tutorials/Desktop_Components/README.md | 7 +- tutorials/Getting_Started/README.md | 10 +- web/build.gradle.kts | 7 +- .../main-template/build.gradle.kts | 3 +- .../web/attributes/PredefinedAttrValues.kt | 4 +- .../org/jetbrains/compose/web/css/CSSEnums.kt | 34 +++---- .../org/jetbrains/compose/web/css/CSSUnits.kt | 98 +++++++++---------- .../src/jsTest/kotlin/FailingTestCases.kt | 40 ++++++++ web/gradle.properties | 5 +- web/settings.gradle.kts | 3 +- 18 files changed, 140 insertions(+), 91 deletions(-) create mode 100644 web/core/src/jsTest/kotlin/FailingTestCases.kt diff --git a/ci/compose-uber-jar/gradle.properties b/ci/compose-uber-jar/gradle.properties index f1668b0fe5..256f3d0886 100644 --- a/ci/compose-uber-jar/gradle.properties +++ b/ci/compose-uber-jar/gradle.properties @@ -1,3 +1,3 @@ # __LATEST_COMPOSE_RELEASE_VERSION__ -compose.version=0.4.0 +compose.version=0.5.0-build262 kotlin.code.style=official diff --git a/components/build.gradle.kts b/components/build.gradle.kts index e1ad7a7bfd..b24228ee1d 100644 --- a/components/build.gradle.kts +++ b/components/build.gradle.kts @@ -10,7 +10,7 @@ buildscript { dependencies { classpath("org.jetbrains.compose:compose-gradle-plugin:$composeVersion") // __KOTLIN_COMPOSE_VERSION__ - classpath(kotlin("gradle-plugin", version = "1.5.10")) + classpath(kotlin("gradle-plugin", version = "1.5.21")) } } diff --git a/components/gradle.properties b/components/gradle.properties index 3e1cd60f44..67d1d922fa 100644 --- a/components/gradle.properties +++ b/components/gradle.properties @@ -4,4 +4,4 @@ android.enableJetifier=true kotlin.code.style=official # __LATEST_COMPOSE_RELEASE_VERSION__ -compose.version=0.4.0 \ No newline at end of file +compose.version=0.5.0-build262 \ No newline at end of file diff --git a/compose/frameworks/support b/compose/frameworks/support index 9b5ede8dc4..3de47bade6 160000 --- a/compose/frameworks/support +++ b/compose/frameworks/support @@ -1 +1 @@ -Subproject commit 9b5ede8dc435293ac09419421528921b8fed27fb +Subproject commit 3de47bade63fae3a9ee0b7b5a5d9028ccaf0e3ef diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt index 8694aa6738..ceac76b168 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt @@ -8,6 +8,6 @@ package org.jetbrains.compose.test @Suppress("EnumEntryName") enum class TestKotlinVersion(val versionString: String) { // __KOTLIN_COMPOSE_VERSION__ - Default("1.5.10"), + Default("1.5.21"), V1_5_20("1.5.20") } \ No newline at end of file diff --git a/gradle-plugins/gradle.properties b/gradle-plugins/gradle.properties index 456860be35..c1419cc009 100644 --- a/gradle-plugins/gradle.properties +++ b/gradle-plugins/gradle.properties @@ -6,7 +6,7 @@ kotlin.code.style=official # unless overridden by COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION env var. # # __LATEST_COMPOSE_RELEASE_VERSION__ -compose.version=0.4.0 +compose.version=0.5.0-build262 compose.with.web=false # A version of Gradle plugin, that will be published, diff --git a/templates/desktop-template/build.gradle.kts b/templates/desktop-template/build.gradle.kts index 1557e31860..9255c3f0da 100644 --- a/templates/desktop-template/build.gradle.kts +++ b/templates/desktop-template/build.gradle.kts @@ -3,9 +3,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { // __KOTLIN_COMPOSE_VERSION__ - kotlin("jvm") version "1.5.10" + kotlin("jvm") version "1.5.21" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build226") + id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build262") } repositories { diff --git a/templates/multiplatform-template/build.gradle.kts b/templates/multiplatform-template/build.gradle.kts index d608a85cf3..7114839f1c 100644 --- a/templates/multiplatform-template/build.gradle.kts +++ b/templates/multiplatform-template/build.gradle.kts @@ -1,6 +1,6 @@ buildscript { // __LATEST_COMPOSE_RELEASE_VERSION__ - val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build226" + val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build262" repositories { google() @@ -12,7 +12,7 @@ buildscript { classpath("org.jetbrains.compose:compose-gradle-plugin:$composeVersion") classpath("com.android.tools.build:gradle:4.0.1") // __KOTLIN_COMPOSE_VERSION__ - classpath(kotlin("gradle-plugin", version = "1.5.10")) + classpath(kotlin("gradle-plugin", version = "1.5.21")) } } diff --git a/tutorials/Desktop_Components/README.md b/tutorials/Desktop_Components/README.md index c467913c64..dfa894b96a 100644 --- a/tutorials/Desktop_Components/README.md +++ b/tutorials/Desktop_Components/README.md @@ -256,6 +256,7 @@ The main arguments of the `BoxWithTooltip` function: ```kotlin import androidx.compose.desktop.Window import androidx.compose.foundation.BoxWithTooltip +import androidx.compose.foundation.TooltipPlacement import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -293,7 +294,11 @@ fun main() = Window(title = "Tooltip Example", size = IntSize(300, 300)) { } }, delay = 600, // in milliseconds - offset = if (index % 2 == 0) DpOffset(-16.dp, 0.dp) else DpOffset.Zero // tooltip offset + tooltipPlacement = TooltipPlacement( + anchor = TooltipPlacement.Anchor.Pointer, + alignment = Alignment.BottomEnd, + offset = if (index % 2 == 0) DpOffset(-16.dp, 0.dp) else DpOffset.Zero // tooltip offset + ) ) { Button(onClick = {}) { Text(text = name) } } diff --git a/tutorials/Getting_Started/README.md b/tutorials/Getting_Started/README.md index 35f42d462d..d3af299108 100644 --- a/tutorials/Getting_Started/README.md +++ b/tutorials/Getting_Started/README.md @@ -32,11 +32,11 @@ packaging JDK 15 or later must be used. ### Update the wizard plugin -The Сompose plugin version used in the wizard above may be not the last. Update the version of the plugin to the latest available by editing the `build.gradle.kts` file, finding and updating the version information as shown below. In this example the latest version of the plugin was 0.5.0-build235 and a compatible version of kotlin was 1.5.10. For the latest versions, see the [latest versions](https://github.com/JetBrains/compose-jb/releases) site and the [Kotlin](https://kotlinlang.org/) site. +The Сompose plugin version used in the wizard above may be not the last. Update the version of the plugin to the latest available by editing the `build.gradle.kts` file, finding and updating the version information as shown below. In this example the latest version of the plugin was 0.5.0-build262 and a compatible version of kotlin was 1.5.21. For the latest versions, see the [latest versions](https://github.com/JetBrains/compose-jb/releases) site and the [Kotlin](https://kotlinlang.org/) site. ``` plugins { - kotlin("jvm") version "1.5.10" - id("org.jetbrains.compose") version "0.5.0-build235" + kotlin("jvm") version "1.5.21" + id("org.jetbrains.compose") version "0.5.0-build262" } ``` @@ -71,8 +71,8 @@ Then create `build.gradle.kts` with the following content: import org.jetbrains.compose.compose plugins { - kotlin("jvm") version "1.5.10" - id("org.jetbrains.compose") version "0.5.0-build235" + kotlin("jvm") version "1.5.21" + id("org.jetbrains.compose") version "0.5.0-build262" } repositories { diff --git a/web/build.gradle.kts b/web/build.gradle.kts index 6e20c5f141..9b2fdc9bc2 100644 --- a/web/build.gradle.kts +++ b/web/build.gradle.kts @@ -12,7 +12,7 @@ subprojects { version = COMPOSE_WEB_VERSION pluginManager.withPlugin("maven-publish") { - configure { + configure { repositories { maven { name = "internal" @@ -42,9 +42,10 @@ subprojects { repositories { gradlePluginPortal() + mavenLocal() mavenCentral() - maven { - url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") + maven { + url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") } maven { url = uri("https://packages.jetbrains.team/maven/p/ui/dev") diff --git a/web/compose-compiler-integration/main-template/build.gradle.kts b/web/compose-compiler-integration/main-template/build.gradle.kts index 675d1858d6..04b3a5a6fd 100644 --- a/web/compose-compiler-integration/main-template/build.gradle.kts +++ b/web/compose-compiler-integration/main-template/build.gradle.kts @@ -1,9 +1,10 @@ plugins { - kotlin("multiplatform") version "1.5.10" + kotlin("multiplatform") version "1.5.21" id("org.jetbrains.compose") } repositories { + mavenLocal() mavenCentral() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/PredefinedAttrValues.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/PredefinedAttrValues.kt index 56565090b7..f8baddf11a 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/PredefinedAttrValues.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/attributes/PredefinedAttrValues.kt @@ -167,8 +167,8 @@ enum class Scope(val str: String) { * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete */ @Suppress("Unused", "NOTHING_TO_INLINE", "NESTED_CLASS_IN_EXTERNAL_INTERFACE", "INLINE_EXTERNAL_DECLARATION", "WRONG_BODY_OF_EXTERNAL_DECLARATION", "NESTED_EXTERNAL_DECLARATION", "ClassName") -external interface AutoComplete { - external companion object { +interface AutoComplete { + companion object { /** * The browser is not permitted to automatically enter or select a value for this field. It is possible that the document or application provides its own autocomplete feature, or that security concerns require that the field's value not be automatically entered. * Note: In most modern browsers, setting autocomplete to "off" will not prevent a password manager from asking the user if they would like to save username and password information, or from automatically filling in those values in a site's login form. See the autocomplete attribute and login fields. diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSEnums.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSEnums.kt index 5d87857b97..d3d53763ef 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSEnums.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSEnums.kt @@ -2,12 +2,12 @@ package org.jetbrains.compose.web.css -external interface StylePropertyEnum: StylePropertyString +interface StylePropertyEnum: StylePropertyString inline val StylePropertyEnum.name get() = this.unsafeCast() inline val StylePropertyEnum.value get() = this.unsafeCast() -external interface LineStyle: StylePropertyEnum { - external companion object { +interface LineStyle: StylePropertyEnum { + companion object { inline val None get() = LineStyle("none") inline val Hidden get() = LineStyle("hidden") inline val Dotted get() = LineStyle("dotted") @@ -22,8 +22,8 @@ external interface LineStyle: StylePropertyEnum { } inline fun LineStyle(value: String) = value.unsafeCast() -external interface DisplayStyle: StylePropertyEnum { - external companion object { +interface DisplayStyle: StylePropertyEnum { + companion object { inline val Block get() = DisplayStyle("block") inline val Inline get() = DisplayStyle("inline") inline val InlineBlock get() = DisplayStyle("inline-block") @@ -57,7 +57,7 @@ external interface DisplayStyle: StylePropertyEnum { } inline fun DisplayStyle(value: String) = value.unsafeCast() -external interface FlexDirection: StylePropertyEnum { +interface FlexDirection: StylePropertyEnum { companion object { inline val Row get() = FlexDirection("row") inline val RowReverse get() = FlexDirection("row-reverse") @@ -67,7 +67,7 @@ external interface FlexDirection: StylePropertyEnum { } inline fun FlexDirection(value: String) = value.unsafeCast() -external interface FlexWrap: StylePropertyEnum { +interface FlexWrap: StylePropertyEnum { companion object { inline val Wrap get() = FlexWrap("wrap") inline val Nowrap get() = FlexWrap("nowrap") @@ -76,7 +76,7 @@ external interface FlexWrap: StylePropertyEnum { } inline fun FlexWrap(value: String) = value.unsafeCast() -external interface JustifyContent: StylePropertyEnum { +interface JustifyContent: StylePropertyEnum { companion object { inline val Center get() = JustifyContent("center") inline val Start get() = JustifyContent("start") @@ -99,7 +99,7 @@ external interface JustifyContent: StylePropertyEnum { } inline fun JustifyContent(value: String) = value.unsafeCast() -external interface AlignSelf: StylePropertyEnum { +interface AlignSelf: StylePropertyEnum { companion object { inline val Auto get() = AlignSelf("auto") inline val Normal get() = AlignSelf("normal") @@ -123,7 +123,7 @@ external interface AlignSelf: StylePropertyEnum { } inline fun AlignSelf(value: String) = value.unsafeCast() -external interface AlignItems: StylePropertyEnum { +interface AlignItems: StylePropertyEnum { companion object { inline val Normal get() = AlignItems("normal") inline val Stretch get() = AlignItems("stretch") @@ -145,7 +145,7 @@ external interface AlignItems: StylePropertyEnum { } inline fun AlignItems(value: String) = value.unsafeCast() -external interface AlignContent: StylePropertyEnum { +interface AlignContent: StylePropertyEnum { companion object { inline val Center get() = AlignContent("center") inline val Start get() = AlignContent("start") @@ -169,7 +169,7 @@ external interface AlignContent: StylePropertyEnum { } inline fun AlignContent(value: String) = value.unsafeCast() -external interface Position: StylePropertyEnum { +interface Position: StylePropertyEnum { companion object { inline val Static get() = Position("static") inline val Relative get() = Position("relative") @@ -182,7 +182,7 @@ inline fun Position(value: String) = value.unsafeCast() typealias LanguageCode = String -external interface StepPosition: StylePropertyEnum { +interface StepPosition: StylePropertyEnum { companion object { inline val JumpStart get() = StepPosition("jump-start") inline val JumpEnd get() = StepPosition("jump-end") @@ -194,7 +194,7 @@ external interface StepPosition: StylePropertyEnum { } inline fun StepPosition(value: String) = value.unsafeCast() -external interface AnimationTimingFunction: StylePropertyEnum { +interface AnimationTimingFunction: StylePropertyEnum { companion object { inline val Ease get() = AnimationTimingFunction("ease") inline val EaseIn get() = AnimationTimingFunction("ease-in") @@ -215,7 +215,7 @@ external interface AnimationTimingFunction: StylePropertyEnum { } inline fun AnimationTimingFunction(value: String) = value.unsafeCast() -external interface AnimationDirection: StylePropertyEnum { +interface AnimationDirection: StylePropertyEnum { companion object { inline val Normal get() = AnimationDirection("normal") inline val Reverse get() = AnimationDirection("reverse") @@ -229,7 +229,7 @@ external interface AnimationDirection: StylePropertyEnum { } inline fun AnimationDirection(value: String) = value.unsafeCast() -external interface AnimationFillMode: StylePropertyEnum { +interface AnimationFillMode: StylePropertyEnum { companion object { inline val None get() = AnimationFillMode("none") inline val Forwards get() = AnimationFillMode("forwards") @@ -239,7 +239,7 @@ external interface AnimationFillMode: StylePropertyEnum { } inline fun AnimationFillMode(value: String) = value.unsafeCast() -external interface AnimationPlayState: StylePropertyEnum { +interface AnimationPlayState: StylePropertyEnum { companion object { inline val Running get() = AnimationPlayState("running") inline val Paused get() = AnimationPlayState("Paused") diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSUnits.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSUnits.kt index e89f3729d1..b2ec469c50 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSUnits.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSUnits.kt @@ -16,16 +16,16 @@ data class CSSUnitValueTyped( override fun toString(): String = "$value$unit" } -external interface CSSUnitLengthOrPercentage: CSSUnit -external interface CSSUnitPercentage: CSSUnitLengthOrPercentage -external interface CSSUnitLength: CSSUnitLengthOrPercentage -external interface CSSUnitRel : CSSUnitLength -external interface CSSUnitAbs: CSSUnitLength -external interface CSSUnitAngle: CSSUnit -external interface CSSUnitTime: CSSUnit -external interface CSSUnitFrequency: CSSUnit -external interface CSSUnitResolution: CSSUnit -external interface CSSUnitFlex: CSSUnit +interface CSSUnitLengthOrPercentage: CSSUnit +interface CSSUnitPercentage: CSSUnitLengthOrPercentage +interface CSSUnitLength: CSSUnitLengthOrPercentage +interface CSSUnitRel : CSSUnitLength +interface CSSUnitAbs: CSSUnitLength +interface CSSUnitAngle: CSSUnit +interface CSSUnitTime: CSSUnit +interface CSSUnitFrequency: CSSUnit +interface CSSUnitResolution: CSSUnit +interface CSSUnitFlex: CSSUnit typealias CSSAngleValue = CSSSizeValue typealias CSSLengthOrPercentageValue = CSSSizeValue @@ -36,82 +36,82 @@ typealias CSSNumeric = CSSNumericValue typealias CSSpxValue = CSSSizeValue // fake interfaces to distinguish units -external interface CSSUnit { - external interface percent: CSSUnitPercentage +interface CSSUnit { + interface percent: CSSUnitPercentage - external interface em: CSSUnitRel + interface em: CSSUnitRel - external interface ex: CSSUnitRel + interface ex: CSSUnitRel - external interface ch: CSSUnitRel + interface ch: CSSUnitRel - external interface ic: CSSUnitRel + interface ic: CSSUnitRel - external interface rem: CSSUnitRel + interface rem: CSSUnitRel - external interface lh: CSSUnitRel + interface lh: CSSUnitRel - external interface rlh: CSSUnitRel + interface rlh: CSSUnitRel - external interface vw: CSSUnitRel + interface vw: CSSUnitRel - external interface vh: CSSUnitRel + interface vh: CSSUnitRel - external interface vi: CSSUnitRel + interface vi: CSSUnitRel - external interface vb: CSSUnitRel + interface vb: CSSUnitRel - external interface vmin: CSSUnitRel + interface vmin: CSSUnitRel - external interface vmax: CSSUnitRel + interface vmax: CSSUnitRel - external interface cm: CSSUnitRel + interface cm: CSSUnitRel - external interface mm: CSSUnitRel + interface mm: CSSUnitRel - external interface Q: CSSUnitRel + interface Q: CSSUnitRel - external interface pt: CSSUnitAbs + interface pt: CSSUnitAbs - external interface pc: CSSUnitAbs + interface pc: CSSUnitAbs - external interface px: CSSUnitAbs + interface px: CSSUnitAbs - external interface deg: CSSUnitAngle + interface deg: CSSUnitAngle - external interface grad: CSSUnitAngle + interface grad: CSSUnitAngle - external interface rad: CSSUnitAngle + interface rad: CSSUnitAngle - external interface turn: CSSUnitAngle + interface turn: CSSUnitAngle - external interface s: CSSUnitTime + interface s: CSSUnitTime - external interface ms: CSSUnitTime + interface ms: CSSUnitTime - external interface Hz: CSSUnitFrequency + interface Hz: CSSUnitFrequency - external interface kHz: CSSUnitFrequency + interface kHz: CSSUnitFrequency - external interface dpi: CSSUnitResolution + interface dpi: CSSUnitResolution - external interface dpcm: CSSUnitResolution + interface dpcm: CSSUnitResolution - external interface dppx: CSSUnitResolution + interface dppx: CSSUnitResolution - external interface fr: CSSUnitFlex + interface fr: CSSUnitFlex - external interface number: CSSUnit - - external companion object { + interface number: CSSUnit + + companion object { inline val percent get() = "%".unsafeCast() inline val em get() = "em".unsafeCast() - + inline val ex get() = "ex".unsafeCast() inline val ch get() = "ch".unsafeCast() - + inline val ic get() = "ic".unsafeCast() inline val rem get() = "rem".unsafeCast() @@ -119,7 +119,7 @@ external interface CSSUnit { inline val lh get() = "lh".unsafeCast() inline val rlh get() = "rlh".unsafeCast() - + inline val vw get() = "vw".unsafeCast() inline val vh get() = "vh".unsafeCast() diff --git a/web/core/src/jsTest/kotlin/FailingTestCases.kt b/web/core/src/jsTest/kotlin/FailingTestCases.kt new file mode 100644 index 0000000000..549da12b15 --- /dev/null +++ b/web/core/src/jsTest/kotlin/FailingTestCases.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. + * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. + */ + +package org.jetbrains.compose.web.core.tests + +import kotlin.test.Test +import kotlin.test.assertTrue + +class FailingTestCases { + + @Test + fun externalInterfaceSimulatingEnum() { + var expectedErrorThrown = false + try { + // Doesn't throw in kotlin 1.5.10. + // Since kotlin 1.5.20 (and 1.5.21) throws `ReferenceError: MyI is not defined` + useMyI(MyI.Value1) + } catch (e: Throwable) { + expectedErrorThrown = true + } + assertTrue(expectedErrorThrown) + } +} + +@Suppress("Unused", "NOTHING_TO_INLINE", "NESTED_CLASS_IN_EXTERNAL_INTERFACE", "INLINE_EXTERNAL_DECLARATION", "WRONG_BODY_OF_EXTERNAL_DECLARATION", "NESTED_EXTERNAL_DECLARATION", "ClassName") +private external interface MyI { + companion object { + inline val Value1 get() = MyI("value1") + inline val Value2 get() = MyI("value2") + } +} + +@Suppress("NOTHING_TO_INLINE") +private inline fun MyI(value: String) = value.unsafeCast() + +private fun useMyI(myI: MyI) { + println("Using MyI = " + myI.unsafeCast()) +} diff --git a/web/gradle.properties b/web/gradle.properties index facbb97665..1896d50b69 100644 --- a/web/gradle.properties +++ b/web/gradle.properties @@ -1,4 +1,5 @@ -COMPOSE_CORE_VERSION=0.5.0-build235 -COMPOSE_WEB_VERSION=0.0.16-SNAPSHOT +# __LATEST_COMPOSE_RELEASE_VERSION__ +COMPOSE_CORE_VERSION=0.5.0-build262 +COMPOSE_WEB_VERSION=0.5.0-build262 COMPOSE_WEB_BUILD_WITH_EXAMPLES=false compose.web.tests.integration.withFirefox diff --git a/web/settings.gradle.kts b/web/settings.gradle.kts index 3d6017196e..e738011871 100644 --- a/web/settings.gradle.kts +++ b/web/settings.gradle.kts @@ -2,6 +2,7 @@ pluginManagement { repositories { gradlePluginPortal() mavenCentral() + mavenLocal() maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") } @@ -16,7 +17,7 @@ pluginManagement { println("[build] compose core version: ${extra["COMPOSE_CORE_VERSION"]}") useModule("org.jetbrains.compose:org.jetbrains.compose.gradle.plugin:${extra["COMPOSE_CORE_VERSION"]}") } else if (requested.id.id == "org.jetbrains.kotlin.multiplatform") { - useModule("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:1.5.10") + useModule("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:1.5.21") } } } From f4f53d69c87e9d68d6bf992cc2d7e0abba7061df Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Wed, 21 Jul 2021 15:23:19 +0300 Subject: [PATCH 2/3] Fix multiple composable windows If we open two windows and close the first one - the second one will jump to the position of the closed one --- examples/notepad/src/main/kotlin/NotepadApplication.kt | 5 ++++- tutorials/Window_API_new/README.md | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/notepad/src/main/kotlin/NotepadApplication.kt b/examples/notepad/src/main/kotlin/NotepadApplication.kt index e30c663c1f..7eac92178a 100644 --- a/examples/notepad/src/main/kotlin/NotepadApplication.kt +++ b/examples/notepad/src/main/kotlin/NotepadApplication.kt @@ -1,4 +1,5 @@ import androidx.compose.runtime.Composable +import androidx.compose.runtime.key import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.window.MenuScope @@ -14,7 +15,9 @@ fun NotepadApplication(state: NotepadApplicationState) { } for (window in state.windows) { - NotepadWindow(window) + key(window) { + NotepadWindow(window) + } } } diff --git a/tutorials/Window_API_new/README.md b/tutorials/Window_API_new/README.md index f5b20238ee..947d93de47 100644 --- a/tutorials/Window_API_new/README.md +++ b/tutorials/Window_API_new/README.md @@ -191,6 +191,7 @@ fun getTrayIcon(): BufferedImage { If an application has multiple windows, then it is better to put its state into a separate class and open/close window in response to `mutableStateListOf` changes (see [notepad example](https://github.com/JetBrains/compose-jb/tree/master/examples/notepad) for more complex use cases): ```kotlin import androidx.compose.runtime.Composable +import androidx.compose.runtime.key import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.remember import androidx.compose.ui.ExperimentalComposeUiApi @@ -203,7 +204,9 @@ fun main() = application { val applicationState = remember { MyApplicationState() } for (window in applicationState.windows) { - MyWindow(window) + key(window) { + MyWindow(window) + } } } From 636694a46e26d80c3f56ed16f4ab02fbbdde2ee4 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Wed, 21 Jul 2021 21:45:15 +0200 Subject: [PATCH 3/3] Introduce basic support for grid-column/row-start/end This contributes to #895 --- .../compose/web/css/properties/grid.kt | 36 +++++ web/core/src/jsTest/kotlin/css/GridTests.kt | 153 ++++++++++++++++++ 2 files changed, 189 insertions(+) diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/grid.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/grid.kt index 7de32f6e2b..bbcd1994f6 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/grid.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/properties/grid.kt @@ -27,6 +27,24 @@ fun StyleBuilder.gridColumn(start: Int, end: Int) { } +// https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-start +fun StyleBuilder.gridColumnStart(value: String) { + property("grid-column-start", value) +} + +fun StyleBuilder.gridColumnStart(value: Int) { + property("grid-column-start", value) +} + +// https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end +fun StyleBuilder.gridColumnEnd(value: String) { + property("grid-column-end", value) +} + +fun StyleBuilder.gridColumnEnd(value: Int) { + property("grid-column-end", value) +} + // https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row fun StyleBuilder.gridRow(value: String) { property("grid-row", value) @@ -48,6 +66,24 @@ fun StyleBuilder.gridRow(start: Int, end: Int) { property("grid-row", "$start / $end") } +// https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-start +fun StyleBuilder.gridRowStart(value: String) { + property("grid-row-start", value) +} + +fun StyleBuilder.gridRowStart(value: Int) { + property("grid-row-start", value) +} + +// https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end +fun StyleBuilder.gridRowEnd(value: String) { + property("grid-row-end", value) +} + +fun StyleBuilder.gridRowEnd(value: Int) { + property("grid-row-end", value) +} + // https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns fun StyleBuilder.gridTemplateColumns(value: String) { property("grid-template-columns", value) diff --git a/web/core/src/jsTest/kotlin/css/GridTests.kt b/web/core/src/jsTest/kotlin/css/GridTests.kt index 983f6f5267..6759a9f788 100644 --- a/web/core/src/jsTest/kotlin/css/GridTests.kt +++ b/web/core/src/jsTest/kotlin/css/GridTests.kt @@ -63,6 +63,159 @@ class GridColumnTests { } } +class GridColumnEndTests { + @Test + fun gridColumnEndOneValue() = runTest { + composition { + Div({ style { gridColumnEnd("1") } }) + Div({ style { gridColumnEnd("somegridarea") } }) + } + + assertEquals("1", nextChild().style.asDynamic().gridColumnEnd) + assertEquals("somegridarea", nextChild().style.asDynamic().gridColumnEnd) + } + + @Test + fun gridColumnEndIntValue() = runTest { + composition { + Div({ style { gridColumnEnd(-4) } }) + } + + val el = nextChild().style.asDynamic() + assertEquals("-4", el.gridColumnEnd) + } + + @Test + fun gridColumnEndGlobalValues() = runTest { + composition { + Div({ style { gridColumn("inherit") } }) + Div({ style { gridColumn("initial") } }) + Div({ style { gridColumn("revert") } }) + Div({ style { gridColumn("unset") } }) + } + + assertEquals("inherit", nextChild().style.asDynamic().gridColumnEnd) + assertEquals("initial", nextChild().style.asDynamic().gridColumnEnd) + assertEquals("revert", nextChild().style.asDynamic().gridColumnEnd) + assertEquals("unset", nextChild().style.asDynamic().gridColumnEnd) + } +} + +class GridColumnStartTests { + @Test + fun gridColumnStartOneValue() = runTest { + composition { + Div({ style { gridColumnStart("1") } }) + Div({ style { gridColumnStart("somegridarea") } }) + } + + assertEquals("1", nextChild().style.asDynamic().gridColumnStart) + assertEquals("somegridarea", nextChild().style.asDynamic().gridColumnStart) + } + + @Test + fun gridColumnStartIntValue() = runTest { + composition { + Div({ style { gridColumnStart(-4) } }) + } + + val el = nextChild().style.asDynamic() + assertEquals("-4", el.gridColumnStart) + } + + @Test + fun gridColumnStartGlobalValues() = runTest { + composition { + Div({ style { gridColumn("inherit") } }) + Div({ style { gridColumn("initial") } }) + Div({ style { gridColumn("revert") } }) + Div({ style { gridColumn("unset") } }) + } + + assertEquals("inherit", nextChild().style.asDynamic().gridColumnStart) + assertEquals("initial", nextChild().style.asDynamic().gridColumnStart) + assertEquals("revert", nextChild().style.asDynamic().gridColumnStart) + assertEquals("unset", nextChild().style.asDynamic().gridColumnStart) + } +} + +class GridRowStartTests { + @Test + fun gridRowStartOneValue() = runTest { + composition { + Div({ style { gridRowStart("1") } }) + Div({ style { gridRowStart("somegridarea") } }) + } + + assertEquals("1", nextChild().style.asDynamic().gridRowStart) + assertEquals("somegridarea", nextChild().style.asDynamic().gridRowStart) + } + + @Test + fun gridRowStartIntValue() = runTest { + composition { + Div({ style { gridRowStart(-4) } }) + } + + val el = nextChild().style.asDynamic() + assertEquals("-4", el.gridRowStart) + } + + @Test + fun gridRowStartGlobalValues() = runTest { + composition { + Div({ style { gridRow("inherit") } }) + Div({ style { gridRow("initial") } }) + Div({ style { gridRow("revert") } }) + Div({ style { gridRow("unset") } }) + } + + assertEquals("inherit", nextChild().style.asDynamic().gridRowStart) + assertEquals("initial", nextChild().style.asDynamic().gridRowStart) + assertEquals("revert", nextChild().style.asDynamic().gridRowStart) + assertEquals("unset", nextChild().style.asDynamic().gridRowStart) + } +} + +class GridRowEndTests { + @Test + fun gridRowEndOneValue() = runTest { + composition { + Div({ style { gridRowEnd("1") } }) + Div({ style { gridRowEnd("somegridarea") } }) + } + + assertEquals("1", nextChild().style.asDynamic().gridRowEnd) + assertEquals("somegridarea", nextChild().style.asDynamic().gridRowEnd) + } + + @Test + fun gridRowEndIntValue() = runTest { + composition { + Div({ style { gridRowEnd(-4) } }) + } + + val el = nextChild().style.asDynamic() + assertEquals("-4", el.gridRowEnd) + } + + @Test + fun gridRowEndGlobalValues() = runTest { + composition { + Div({ style { gridRow("inherit") } }) + Div({ style { gridRow("initial") } }) + Div({ style { gridRow("revert") } }) + Div({ style { gridRow("unset") } }) + } + + assertEquals("inherit", nextChild().style.asDynamic().gridRowEnd) + assertEquals("initial", nextChild().style.asDynamic().gridRowEnd) + assertEquals("revert", nextChild().style.asDynamic().gridRowEnd) + assertEquals("unset", nextChild().style.asDynamic().gridRowEnd) + } +} + + class GridRawTests { @Test