Browse Source

Tutorials for 0.4.0-rc2

pull/715/head
Igor Demin 4 years ago
parent
commit
560f411e01
  1. 2
      templates/desktop-template/build.gradle.kts
  2. 2
      templates/multiplatform-template/build.gradle.kts
  3. 9
      tutorials/Image_And_Icons_Manipulations/README.md
  4. 9
      tutorials/Scrollbars/README.md
  5. 20
      tutorials/Tray_Notifications_MenuBar/README.md
  6. 10
      tutorials/Window_API/README.md

2
templates/desktop-template/build.gradle.kts

@ -5,7 +5,7 @@ plugins {
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
kotlin("jvm") version "1.5.10" kotlin("jvm") version "1.5.10"
// __LATEST_COMPOSE_RELEASE_VERSION__ // __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 { repositories {

2
templates/multiplatform-template/build.gradle.kts

@ -1,6 +1,6 @@
buildscript { buildscript {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __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 { repositories {
// TODO: remove after new build is published // TODO: remove after new build is published

9
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.ColorAlphaType
import org.jetbrains.skija.IRect import org.jetbrains.skija.IRect
import org.jetbrains.skija.ImageInfo import org.jetbrains.skija.ImageInfo
import org.jetbrains.skija.Image
import java.awt.image.BufferedImage import java.awt.image.BufferedImage
import java.io.File import java.io.File
import javax.imageio.ImageIO import javax.imageio.ImageIO
@ -90,8 +91,8 @@ fun main() {
modifier = Modifier.fillMaxSize() modifier = Modifier.fillMaxSize()
) { ) {
drawIntoCanvas { canvas -> drawIntoCanvas { canvas ->
canvas.nativeCanvas.drawBitmapRect( canvas.nativeCanvas.drawImageRect(
bitmap, Image.makeFromBitmap(bitmap),
IRect(0, 0, bitmap.getWidth(), bitmap.getHeight()).toRect() 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.Modifier
import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.window.MenuItem import androidx.compose.ui.window.v1.MenuItem
import androidx.compose.ui.window.Tray import androidx.compose.ui.window.v1.Tray
import org.jetbrains.skija.Image import org.jetbrains.skija.Image
import java.awt.image.BufferedImage import java.awt.image.BufferedImage
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream

9
tutorials/Scrollbars/README.md

@ -97,7 +97,6 @@ You can use scrollbars with lazy scrollable components, for example, LazyColumn.
```kotlin ```kotlin
import androidx.compose.desktop.Window import androidx.compose.desktop.Window
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.VerticalScrollbar import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
@ -124,7 +123,6 @@ fun main() {
} }
} }
@OptIn(ExperimentalFoundationApi::class)
@Composable @Composable
fun LazyScrollable() { fun LazyScrollable() {
Box( Box(
@ -134,10 +132,9 @@ fun LazyScrollable() {
) { ) {
val state = rememberLazyListState() val state = rememberLazyListState()
val itemCount = 1000
LazyColumn(Modifier.fillMaxSize().padding(end = 12.dp), state) { LazyColumn(Modifier.fillMaxSize().padding(end = 12.dp), state) {
items(itemCount) { x -> items(1000) { x ->
TextBox("Item #$x") TextBox("Item #$x")
Spacer(modifier = Modifier.height(5.dp)) Spacer(modifier = Modifier.height(5.dp))
} }
@ -145,9 +142,7 @@ fun LazyScrollable() {
VerticalScrollbar( VerticalScrollbar(
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(), modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
adapter = rememberScrollbarAdapter( adapter = rememberScrollbarAdapter(
scrollState = state, scrollState = state
itemCount = itemCount,
averageItemSize = 37.dp // TextBox height + Spacer height
) )
) )
} }

20
tutorials/Tray_Notifications_MenuBar/README.md

@ -22,8 +22,8 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.window.MenuItem import androidx.compose.ui.window.v1.MenuItem
import androidx.compose.ui.window.Tray import androidx.compose.ui.window.v1.Tray
import java.awt.Color import java.awt.Color
import java.awt.image.BufferedImage import java.awt.image.BufferedImage
@ -167,10 +167,10 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.Key
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.window.KeyStroke import androidx.compose.ui.window.v1.KeyStroke
import androidx.compose.ui.window.MenuItem import androidx.compose.ui.window.v1.MenuItem
import androidx.compose.ui.window.Menu import androidx.compose.ui.window.v1.Menu
import androidx.compose.ui.window.MenuBar import androidx.compose.ui.window.v1.MenuBar
fun main() { fun main() {
// To use Apple global menu. // To use Apple global menu.
@ -236,10 +236,10 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.Key
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.window.KeyStroke import androidx.compose.ui.window.v1.KeyStroke
import androidx.compose.ui.window.MenuItem import androidx.compose.ui.window.v1.MenuItem
import androidx.compose.ui.window.Menu import androidx.compose.ui.window.v1.Menu
import androidx.compose.ui.window.MenuBar import androidx.compose.ui.window.v1.MenuBar
import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.IntSize

10
tutorials/Window_API/README.md

@ -43,7 +43,7 @@ import androidx.compose.material.Button
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.v1.Dialog
fun main() { fun main() {
Window { Window {
@ -96,10 +96,10 @@ import androidx.compose.ui.input.key.Key
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.window.MenuItem import androidx.compose.ui.window.v1.MenuItem
import androidx.compose.ui.window.KeyStroke import androidx.compose.ui.window.v1.KeyStroke
import androidx.compose.ui.window.Menu import androidx.compose.ui.window.v1.Menu
import androidx.compose.ui.window.MenuBar import androidx.compose.ui.window.v1.MenuBar
import java.awt.Color import java.awt.Color
import java.awt.image.BufferedImage import java.awt.image.BufferedImage

Loading…
Cancel
Save