Browse Source

Move templates to build150 and fix most tutorials.

pull/361/head
Nikolay Igotti 4 years ago
parent
commit
c8b0ee23d0
  1. 4
      templates/desktop-template/build.gradle.kts
  2. 4
      templates/multiplatform-template/build.gradle.kts
  3. 5
      tutorials/Mouse_Events/README.md
  4. 2
      tutorials/Scrollbars/README.md
  5. 10
      tutorials/Window_API/README.md

4
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 {

4
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"))
}
}

5
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++}"
},

2
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

10
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,10 +214,8 @@ fun main() {
Text(text = "Location: ${windowPos.value}")
Button(
onClick = {
if (current != null) {
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 = {

Loading…
Cancel
Save