mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Move templates to build150 and fix most tutorials.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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++}"
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,9 +214,7 @@ fun main() {
|
||||
Text(text = "Location: ${windowPos.value}")
|
||||
Button(
|
||||
onClick = {
|
||||
if (current != null) {
|
||||
windowPos.value = IntOffset(current.x, current.y)
|
||||
}
|
||||
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 = {
|
||||
|
||||
Reference in New Issue
Block a user