From 929b28787d023010413bdcf2a85657c2765725bd Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Mon, 27 Sep 2021 17:59:28 +0300 Subject: [PATCH] Mostly move to 1.0.0-alpha4-build361 --- examples/codeviewer/build.gradle.kts | 4 +- .../codeviewer/platform/Scrollbar.kt | 2 +- examples/falling-balls/build.gradle.kts | 4 +- examples/imageviewer/build.gradle.kts | 6 +-- .../imageviewer/model/DesktopContentState.kt | 6 +-- .../example/imageviewer/view/MainScreen.kt | 2 +- .../example/imageviewer/view/Tooltip.kt | 3 +- examples/intellij-plugin/build.gradle.kts | 4 +- examples/issues/build.gradle.kts | 4 +- templates/desktop-template/build.gradle.kts | 4 +- tutorials/Context_Menu/README.md | 47 +++++++++++++------ tutorials/Desktop_Components/README.md | 11 +++-- tutorials/Mouse_Events/README.md | 4 +- 13 files changed, 60 insertions(+), 41 deletions(-) diff --git a/examples/codeviewer/build.gradle.kts b/examples/codeviewer/build.gradle.kts index 9eb9ff58dd..ca87402368 100644 --- a/examples/codeviewer/build.gradle.kts +++ b/examples/codeviewer/build.gradle.kts @@ -8,10 +8,10 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1") + classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha4-build361") classpath("com.android.tools.build:gradle:4.0.1") // __KOTLIN_COMPOSE_VERSION__ - classpath(kotlin("gradle-plugin", version = "1.5.21")) + classpath(kotlin("gradle-plugin", version = "1.5.31")) } } diff --git a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt b/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt index e5f7f982fa..4ce9357586 100644 --- a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt +++ b/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt @@ -25,6 +25,6 @@ actual fun VerticalScrollbar( itemCount: Int, averageItemSize: Dp ) = androidx.compose.foundation.VerticalScrollbar( - rememberScrollbarAdapter(scrollState, itemCount, averageItemSize), + rememberScrollbarAdapter(scrollState), modifier ) \ No newline at end of file diff --git a/examples/falling-balls/build.gradle.kts b/examples/falling-balls/build.gradle.kts index d8ab110725..f4bd464ec5 100644 --- a/examples/falling-balls/build.gradle.kts +++ b/examples/falling-balls/build.gradle.kts @@ -4,9 +4,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { // __KOTLIN_COMPOSE_VERSION__ - kotlin("jvm") version "1.5.21" + kotlin("jvm") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version "1.0.0-alpha1" + id("org.jetbrains.compose") version "1.0.0-alpha4-build361" } group = "me.user" diff --git a/examples/imageviewer/build.gradle.kts b/examples/imageviewer/build.gradle.kts index 4dfe785a85..6e8482669b 100755 --- a/examples/imageviewer/build.gradle.kts +++ b/examples/imageviewer/build.gradle.kts @@ -7,9 +7,9 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1") + classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha4-build361") classpath("com.android.tools.build:gradle:4.1.0") - classpath(kotlin("gradle-plugin", version = "1.5.21")) + classpath(kotlin("gradle-plugin", version = "1.5.31")) } } @@ -19,4 +19,4 @@ allprojects { mavenCentral() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } -} \ No newline at end of file +} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt index 35a60c5dd6..73daf71680 100644 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt +++ b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt @@ -20,12 +20,12 @@ import java.awt.image.BufferedImage import java.io.File import java.util.concurrent.ExecutorService import java.util.concurrent.Executors -import org.jetbrains.skija.Image.makeFromEncoded import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.delay +import org.jetbrains.skia.Image object ContentState { val drag = DragHandler() @@ -241,7 +241,7 @@ object ContentState { } fun updateMainImage() { - MainImageWrapper.mainImageAsImageBitmap.value = makeFromEncoded( + MainImageWrapper.mainImageAsImageBitmap.value = Image.makeFromEncoded( toByteArray( cropBitmapByScale( mainImage.value, @@ -363,4 +363,4 @@ private object MainImageWrapper { graphics.drawImage(bitmap, 0, 0, result.width, result.height, null) return result } -} \ No newline at end of file +} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt index 85b8d448e5..ab57a2b9ad 100755 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt +++ b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt @@ -186,7 +186,7 @@ fun Miniature( } ) { Image( - org.jetbrains.skija.Image.makeFromEncoded( + org.jetbrains.skia.Image.makeFromEncoded( toByteArray(picture.image) ).asImageBitmap(), contentDescription = null, diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.kt index 9d6819058f..c13605ab08 100644 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.kt +++ b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.kt @@ -1,6 +1,7 @@ package example.imageviewer.view import androidx.compose.foundation.BoxWithTooltip +import androidx.compose.foundation.TooltipArea import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.MaterialTheme @@ -16,7 +17,7 @@ fun Tooltip( text: String = "Tooltip", content: @Composable () -> Unit ) { - BoxWithTooltip( + TooltipArea( tooltip = { Surface( color = Color(210, 210, 210), diff --git a/examples/intellij-plugin/build.gradle.kts b/examples/intellij-plugin/build.gradle.kts index 65048a542c..dabfecfb62 100644 --- a/examples/intellij-plugin/build.gradle.kts +++ b/examples/intellij-plugin/build.gradle.kts @@ -3,9 +3,9 @@ import org.jetbrains.compose.compose plugins { id("org.jetbrains.intellij") version "1.1.4" java - kotlin("jvm") version "1.5.21" + kotlin("jvm") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version "1.0.0-alpha1" + id("org.jetbrains.compose") version "1.0.0-alpha4-build361" id("idea") } diff --git a/examples/issues/build.gradle.kts b/examples/issues/build.gradle.kts index fe1e4f9855..8f1def37a7 100644 --- a/examples/issues/build.gradle.kts +++ b/examples/issues/build.gradle.kts @@ -8,10 +8,10 @@ buildscript { dependencies { // __LATEST_COMPOSE_RELEASE_VERSION__ - classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1") + classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha4-build361") classpath("com.android.tools.build:gradle:4.1.0") // __KOTLIN_COMPOSE_VERSION__ - classpath(kotlin("gradle-plugin", version = "1.5.21")) + classpath(kotlin("gradle-plugin", version = "1.5.31")) } } diff --git a/templates/desktop-template/build.gradle.kts b/templates/desktop-template/build.gradle.kts index 93c8e3026e..f6c71177b3 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.30" + kotlin("jvm") version "1.5.31" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha4-build328") + id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha4-build361") } repositories { diff --git a/tutorials/Context_Menu/README.md b/tutorials/Context_Menu/README.md index e1e330841d..35f1ac91d7 100644 --- a/tutorials/Context_Menu/README.md +++ b/tutorials/Context_Menu/README.md @@ -109,32 +109,49 @@ In this example Text/TextField context menus will be extended with two additiona There is a possibility to create a context menu for an arbitrary application window area. This is implemented using ContextMenuArea API that is similar to ContextMenuDataProvider. ```kotlin -import androidx.compose.desktop.DesktopMaterialTheme -import androidx.compose.foundation.ContextMenuArea +import androidx.compose.foundation.ContextMenuDataProvider import androidx.compose.foundation.ContextMenuItem -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.width +import androidx.compose.foundation.text.selection.SelectionContainer +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.material.TextField +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.window.singleWindowApplication @OptIn(ExperimentalComposeUiApi::class, androidx.compose.foundation.ExperimentalFoundationApi::class) fun main() = singleWindowApplication(title = "Context menu") { - DesktopMaterialTheme { //it is mandatory for Context Menu - ContextMenuArea(items = { - listOf( - ContextMenuItem("User-defined Action") {/*do something here*/}, - ContextMenuItem("Another user-defined action") {/*do something else*/} - ) - }) { - Box(modifier = Modifier.background(Color.Blue).height(100.dp).width(100.dp)) { + MaterialTheme { //it is mandatory for Context Menu + val text = remember {mutableStateOf("Hello!")} + Column { + ContextMenuDataProvider( + items = { + listOf( + ContextMenuItem("User-defined Action") {/*do something here*/}, + ContextMenuItem("Another user-defined action") {/*do something else*/} + ) + } + ) { + TextField( + value = text.value, + onValueChange = { text.value = it }, + label = { Text(text = "Input") } + ) + + Spacer(Modifier.height(16.dp)) + + SelectionContainer { + Text("Hello World!") + } } } } -} +} ``` Right click on the Blue Square will show a context menu with two items diff --git a/tutorials/Desktop_Components/README.md b/tutorials/Desktop_Components/README.md index 7bc1f56a99..2413fbb314 100644 --- a/tutorials/Desktop_Components/README.md +++ b/tutorials/Desktop_Components/README.md @@ -264,7 +264,8 @@ The main arguments of the `BoxWithTooltip` function: - delay - time delay in milliseconds after which the tooltip will be shown (default is 500 ms) ```kotlin -import androidx.compose.foundation.BoxWithTooltip +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.TooltipArea import androidx.compose.foundation.TooltipPlacement import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -285,7 +286,7 @@ import androidx.compose.ui.window.Window import androidx.compose.ui.window.application import androidx.compose.ui.window.rememberWindowState -@OptIn(ExperimentalComposeUiApi::class) +@OptIn(ExperimentalComposeUiApi::class, ExperimentalFoundationApi::class) fun main() = application { Window( onCloseRequest = ::exitApplication, @@ -296,8 +297,7 @@ fun main() = application { Column(Modifier.fillMaxSize(), Arrangement.spacedBy(5.dp)) { buttons.forEachIndexed { index, name -> // wrap button in BoxWithTooltip - BoxWithTooltip( - modifier = Modifier.padding(start = 40.dp), + TooltipArea( tooltip = { // composable tooltip content Surface( @@ -311,7 +311,8 @@ fun main() = application { ) } }, - delay = 600, // in milliseconds + modifier = Modifier.padding(start = 40.dp), + delayMillis = 600, // in milliseconds tooltipPlacement = TooltipPlacement.CursorPoint( alignment = Alignment.BottomEnd, offset = if (index % 2 == 0) DpOffset(-16.dp, 0.dp) else DpOffset.Zero // tooltip offset diff --git a/tutorials/Mouse_Events/README.md b/tutorials/Mouse_Events/README.md index dad71a4fb5..a23f18548e 100644 --- a/tutorials/Mouse_Events/README.md +++ b/tutorials/Mouse_Events/README.md @@ -159,7 +159,7 @@ fun main() = singleWindowApplication { Compose for Desktop contains desktop-only `Modifier.mouseClickable`, where data about pressed mouse buttons and keyboard modifiers is available. This is an experimental API, which means that it's likely to be changed before release. ```kotlin -import androidx.compose.foundation.ExperimentalDesktopApi +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.mouseClickable import androidx.compose.material.Text import androidx.compose.runtime.getValue @@ -176,7 +176,7 @@ import androidx.compose.ui.input.pointer.isShiftPressed import androidx.compose.ui.input.pointer.isTertiaryPressed import androidx.compose.ui.window.singleWindowApplication -@OptIn(ExperimentalDesktopApi::class) +@OptIn(ExperimentalFoundationApi::class) fun main() = singleWindowApplication { var clickableText by remember { mutableStateOf("Click me!") }