From 560f411e016782a455622c3e80a82fad66a2110c Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Fri, 28 May 2021 19:48:53 +0300 Subject: [PATCH] Tutorials for 0.4.0-rc2 --- templates/desktop-template/build.gradle.kts | 2 +- .../multiplatform-template/build.gradle.kts | 2 +- .../Image_And_Icons_Manipulations/README.md | 9 +++++---- tutorials/Scrollbars/README.md | 9 ++------- .../Tray_Notifications_MenuBar/README.md | 20 +++++++++---------- tutorials/Window_API/README.md | 10 +++++----- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/templates/desktop-template/build.gradle.kts b/templates/desktop-template/build.gradle.kts index 513ca89660..3ad0542e17 100644 --- a/templates/desktop-template/build.gradle.kts +++ b/templates/desktop-template/build.gradle.kts @@ -5,7 +5,7 @@ plugins { // __KOTLIN_COMPOSE_VERSION__ kotlin("jvm") version "1.5.10" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.4.0-rc1") + id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.4.0-rc2") } repositories { diff --git a/templates/multiplatform-template/build.gradle.kts b/templates/multiplatform-template/build.gradle.kts index 688560d2b9..55433bba7c 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.4.0-rc1" + val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.4.0-rc2" repositories { // TODO: remove after new build is published diff --git a/tutorials/Image_And_Icons_Manipulations/README.md b/tutorials/Image_And_Icons_Manipulations/README.md index 1e8b00c8c0..ad88fd293b 100755 --- a/tutorials/Image_And_Icons_Manipulations/README.md +++ b/tutorials/Image_And_Icons_Manipulations/README.md @@ -79,6 +79,7 @@ import org.jetbrains.skija.Bitmap import org.jetbrains.skija.ColorAlphaType import org.jetbrains.skija.IRect import org.jetbrains.skija.ImageInfo +import org.jetbrains.skija.Image import java.awt.image.BufferedImage import java.io.File import javax.imageio.ImageIO @@ -90,8 +91,8 @@ fun main() { modifier = Modifier.fillMaxSize() ) { drawIntoCanvas { canvas -> - canvas.nativeCanvas.drawBitmapRect( - bitmap, + canvas.nativeCanvas.drawImageRect( + Image.makeFromBitmap(bitmap), IRect(0, 0, bitmap.getWidth(), bitmap.getHeight()).toRect() ) } @@ -272,8 +273,8 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.window.MenuItem -import androidx.compose.ui.window.Tray +import androidx.compose.ui.window.v1.MenuItem +import androidx.compose.ui.window.v1.Tray import org.jetbrains.skija.Image import java.awt.image.BufferedImage import java.io.ByteArrayOutputStream diff --git a/tutorials/Scrollbars/README.md b/tutorials/Scrollbars/README.md index 89130c7732..94bec9ad37 100644 --- a/tutorials/Scrollbars/README.md +++ b/tutorials/Scrollbars/README.md @@ -97,7 +97,6 @@ You can use scrollbars with lazy scrollable components, for example, LazyColumn. ```kotlin import androidx.compose.desktop.Window -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.VerticalScrollbar import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box @@ -124,7 +123,6 @@ fun main() { } } -@OptIn(ExperimentalFoundationApi::class) @Composable fun LazyScrollable() { Box( @@ -134,10 +132,9 @@ fun LazyScrollable() { ) { val state = rememberLazyListState() - val itemCount = 1000 LazyColumn(Modifier.fillMaxSize().padding(end = 12.dp), state) { - items(itemCount) { x -> + items(1000) { x -> TextBox("Item #$x") Spacer(modifier = Modifier.height(5.dp)) } @@ -145,9 +142,7 @@ fun LazyScrollable() { VerticalScrollbar( modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(), adapter = rememberScrollbarAdapter( - scrollState = state, - itemCount = itemCount, - averageItemSize = 37.dp // TextBox height + Spacer height + scrollState = state ) ) } diff --git a/tutorials/Tray_Notifications_MenuBar/README.md b/tutorials/Tray_Notifications_MenuBar/README.md index 31ff78649e..4f203181cd 100755 --- a/tutorials/Tray_Notifications_MenuBar/README.md +++ b/tutorials/Tray_Notifications_MenuBar/README.md @@ -22,8 +22,8 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.window.MenuItem -import androidx.compose.ui.window.Tray +import androidx.compose.ui.window.v1.MenuItem +import androidx.compose.ui.window.v1.Tray import java.awt.Color import java.awt.image.BufferedImage @@ -167,10 +167,10 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Alignment import androidx.compose.ui.input.key.Key import androidx.compose.ui.Modifier -import androidx.compose.ui.window.KeyStroke -import androidx.compose.ui.window.MenuItem -import androidx.compose.ui.window.Menu -import androidx.compose.ui.window.MenuBar +import androidx.compose.ui.window.v1.KeyStroke +import androidx.compose.ui.window.v1.MenuItem +import androidx.compose.ui.window.v1.Menu +import androidx.compose.ui.window.v1.MenuBar fun main() { // To use Apple global menu. @@ -236,10 +236,10 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Alignment import androidx.compose.ui.input.key.Key import androidx.compose.ui.Modifier -import androidx.compose.ui.window.KeyStroke -import androidx.compose.ui.window.MenuItem -import androidx.compose.ui.window.Menu -import androidx.compose.ui.window.MenuBar +import androidx.compose.ui.window.v1.KeyStroke +import androidx.compose.ui.window.v1.MenuItem +import androidx.compose.ui.window.v1.Menu +import androidx.compose.ui.window.v1.MenuBar import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntSize diff --git a/tutorials/Window_API/README.md b/tutorials/Window_API/README.md index 5514b3b8a9..8cb1767cca 100755 --- a/tutorials/Window_API/README.md +++ b/tutorials/Window_API/README.md @@ -43,7 +43,7 @@ import androidx.compose.material.Button import androidx.compose.material.Text import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.v1.Dialog fun main() { Window { @@ -96,10 +96,10 @@ import androidx.compose.ui.input.key.Key import androidx.compose.ui.Modifier import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntSize -import androidx.compose.ui.window.MenuItem -import androidx.compose.ui.window.KeyStroke -import androidx.compose.ui.window.Menu -import androidx.compose.ui.window.MenuBar +import androidx.compose.ui.window.v1.MenuItem +import androidx.compose.ui.window.v1.KeyStroke +import androidx.compose.ui.window.v1.Menu +import androidx.compose.ui.window.v1.MenuBar import java.awt.Color import java.awt.image.BufferedImage