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. 12
      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 { plugins {
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
kotlin("jvm") version "1.4.21-2" kotlin("jvm") version "1.4.30"
// __LATEST_COMPOSE_RELEASE_VERSION__ // __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 { repositories {

4
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.3.0-build146" val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.3.0-build150"
repositories { repositories {
// TODO: remove after new build is published // TODO: remove after new build is published
@ -14,7 +14,7 @@ buildscript {
classpath("org.jetbrains.compose:compose-gradle-plugin:$composeVersion") classpath("org.jetbrains.compose:compose-gradle-plugin:$composeVersion")
classpath("com.android.tools.build:gradle:4.0.1") classpath("com.android.tools.build:gradle:4.0.1")
// __KOTLIN_COMPOSE_VERSION__ // __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 ```kotlin
import androidx.compose.desktop.Window import androidx.compose.desktop.Window
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.mutableStateOf 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()) { Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxWidth()) {
var text = remember { mutableStateOf("Click magenta box!") } var text = remember { mutableStateOf("Click magenta box!") }
Column { Column {
@OptIn(ExperimentalFoundationApi::class)
Box( Box(
modifier = Modifier modifier = Modifier
.background(Color.Magenta) .background(Color.Magenta)
.fillMaxWidth(0.7f) .fillMaxWidth(0.7f)
.fillMaxHeight(0.2f) .fillMaxHeight(0.2f)
.clickable( .combinedClickable(
onClick = { onClick = {
text.value = "Click! ${count.value++}" 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. 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.DesktopTheme
import androidx.compose.desktop.Window import androidx.compose.desktop.Window
import androidx.compose.foundation.background import androidx.compose.foundation.background

12
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: 1. Using the global environment:
```kotlin ```kotlin
import androidx.compose.desktop.AppWindowAmbient import androidx.compose.desktop.LocalAppWindow
import androidx.compose.desktop.Window import androidx.compose.desktop.Window
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@ -203,7 +203,7 @@ fun main() {
val windowPos = mutableStateOf(IntOffset.Zero) val windowPos = mutableStateOf(IntOffset.Zero)
Window { Window {
val current = AppWindowAmbient.current val current = LocalAppWindow.current
// Content // Content
Box( Box(
@ -214,9 +214,7 @@ fun main() {
Text(text = "Location: ${windowPos.value}") Text(text = "Location: ${windowPos.value}")
Button( Button(
onClick = { onClick = {
if (current != null) { windowPos.value = IntOffset(current.x, current.y)
windowPos.value = IntOffset(current.x, current.y)
}
} }
) { ) {
Text(text = "Print window location") 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 6. setMenuBar(menuBar: MenuBar) - window menu bar
```kotlin ```kotlin
import androidx.compose.desktop.AppWindowAmbient import androidx.compose.desktop.LocalAppWindow
import androidx.compose.desktop.Window import androidx.compose.desktop.Window
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.material.Button import androidx.compose.material.Button
fun main() { fun main() {
Window { Window {
val window = AppWindowAmbient.current!! val window = LocalAppWindow.current
// Content // Content
Button( Button(
onClick = { onClick = {

Loading…
Cancel
Save