From c8b0ee23d0c18e130d223d2e8934bf5b25a67878 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Sun, 7 Feb 2021 12:26:33 +0300 Subject: [PATCH] Move templates to build150 and fix most tutorials. --- templates/desktop-template/build.gradle.kts | 4 ++-- templates/multiplatform-template/build.gradle.kts | 4 ++-- tutorials/Mouse_Events/README.md | 5 ++++- tutorials/Scrollbars/README.md | 2 +- tutorials/Window_API/README.md | 12 +++++------- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/templates/desktop-template/build.gradle.kts b/templates/desktop-template/build.gradle.kts index 504acbf5ed..ff3dfbd34c 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.4.21-2" + kotlin("jvm") version "1.4.30" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.3.0-build146") + id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.3.0-build150") } repositories { diff --git a/templates/multiplatform-template/build.gradle.kts b/templates/multiplatform-template/build.gradle.kts index 3995ee2fd3..09861bfee5 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.3.0-build146" + val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.3.0-build150" repositories { // TODO: remove after new build is published @@ -14,7 +14,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.4.21-2")) + classpath(kotlin("gradle-plugin", version = "1.4.30")) } } diff --git a/tutorials/Mouse_Events/README.md b/tutorials/Mouse_Events/README.md index 12838741d1..0eeb037f22 100644 --- a/tutorials/Mouse_Events/README.md +++ b/tutorials/Mouse_Events/README.md @@ -14,8 +14,10 @@ so code like this will work on both platforms: ```kotlin import androidx.compose.desktop.Window +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.* import androidx.compose.material.Text import androidx.compose.runtime.mutableStateOf @@ -31,12 +33,13 @@ fun main() = Window(title = "Compose for Desktop", size = IntSize(400, 400)) { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxWidth()) { var text = remember { mutableStateOf("Click magenta box!") } Column { + @OptIn(ExperimentalFoundationApi::class) Box( modifier = Modifier .background(Color.Magenta) .fillMaxWidth(0.7f) .fillMaxHeight(0.2f) - .clickable( + .combinedClickable( onClick = { text.value = "Click! ${count.value++}" }, diff --git a/tutorials/Scrollbars/README.md b/tutorials/Scrollbars/README.md index 1e137fc453..60350eb1ae 100644 --- a/tutorials/Scrollbars/README.md +++ b/tutorials/Scrollbars/README.md @@ -173,7 +173,7 @@ fun TextBox(text: String = "Item") { Scrollbars support themes to change their appearance. The example below shows how to use the DesktopTheme appearance for the scrollbar. -```kotlin +``` kotlin import androidx.compose.desktop.DesktopTheme import androidx.compose.desktop.Window import androidx.compose.foundation.background diff --git a/tutorials/Window_API/README.md b/tutorials/Window_API/README.md index 46662865cf..5514b3b8a9 100755 --- a/tutorials/Window_API/README.md +++ b/tutorials/Window_API/README.md @@ -187,7 +187,7 @@ To get the properties of a window, it is enough to have a link to the current or 1. Using the global environment: ```kotlin -import androidx.compose.desktop.AppWindowAmbient +import androidx.compose.desktop.LocalAppWindow import androidx.compose.desktop.Window import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -203,7 +203,7 @@ fun main() { val windowPos = mutableStateOf(IntOffset.Zero) Window { - val current = AppWindowAmbient.current + val current = LocalAppWindow.current // Content Box( @@ -214,9 +214,7 @@ fun main() { Text(text = "Location: ${windowPos.value}") Button( onClick = { - if (current != null) { - windowPos.value = IntOffset(current.x, current.y) - } + windowPos.value = IntOffset(current.x, current.y) } ) { Text(text = "Print window location") @@ -281,14 +279,14 @@ Using the following methods, you can change the properties of the AppWindow: 6. setMenuBar(menuBar: MenuBar) - window menu bar ```kotlin -import androidx.compose.desktop.AppWindowAmbient +import androidx.compose.desktop.LocalAppWindow import androidx.compose.desktop.Window import androidx.compose.material.Text import androidx.compose.material.Button fun main() { Window { - val window = AppWindowAmbient.current!! + val window = LocalAppWindow.current // Content Button( onClick = {