Browse Source

Update examples (#967)

* Update widgets gallery examples

* Update notepad example

* Update issues example

This change updates:
* Gradle to 7.1.1;
* AGP to 7.0.0;
* Compose to 1.0.0-alpha1-rc1;
* Kotlin to 1.5.21.

* Update image viewer example
pull/972/head
Alexey Tsvetkov 3 years ago committed by GitHub
parent
commit
079a317c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      examples/imageviewer/android/build.gradle.kts
  2. 7
      examples/imageviewer/build.gradle.kts
  3. 10
      examples/imageviewer/common/build.gradle.kts
  4. 2
      examples/imageviewer/desktop/build.gradle.kts
  5. 2
      examples/imageviewer/gradle/wrapper/gradle-wrapper.properties
  6. 8
      examples/issues/android/build.gradle.kts
  7. 6
      examples/issues/build.gradle.kts
  8. 13
      examples/issues/common/build.gradle.kts
  9. 22
      examples/issues/desktop/src/jvmMain/kotlin/androidx/ui/examples/jetissues/Main.kt
  10. 2
      examples/issues/gradle/wrapper/gradle-wrapper.properties
  11. 6
      examples/notepad/build.gradle.kts
  12. 2
      examples/notepad/gradle/wrapper/gradle-wrapper.properties
  13. 2
      examples/notepad/src/main/kotlin/NotepadApplication.kt
  14. 41
      examples/notepad/src/main/kotlin/common/AppResources.kt
  15. 3
      examples/notepad/src/main/kotlin/util/Dialogs.kt
  16. 10
      examples/notepad/src/main/kotlin/window/NotepadWindow.kt
  17. 8
      examples/widgetsgallery/android/build.gradle.kts
  18. 2
      examples/widgetsgallery/build.gradle.kts
  19. 13
      examples/widgetsgallery/common/build.gradle.kts
  20. 2
      examples/widgetsgallery/common/src/androidMain/AndroidManifest.xml
  21. 2
      examples/widgetsgallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt
  22. 14
      examples/widgetsgallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt
  23. 29
      examples/widgetsgallery/desktop/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt
  24. 2
      examples/widgetsgallery/gradle/wrapper/gradle-wrapper.properties

8
examples/imageviewer/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
} }
android { android {
compileSdkVersion(30) compileSdk = 30
defaultConfig { defaultConfig {
minSdkVersion(21) minSdk = 21
targetSdkVersion(30) targetSdk = 30
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@ -22,5 +22,5 @@ android {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.3.0-alpha02") implementation("androidx.activity:activity-compose:1.3.0")
} }

7
examples/imageviewer/build.gradle.kts

@ -1,6 +1,4 @@
buildscript { buildscript {
val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build270"
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
@ -8,8 +6,9 @@ buildscript {
} }
dependencies { dependencies {
classpath("org.jetbrains.compose:compose-gradle-plugin:$composeVersion") // __LATEST_COMPOSE_RELEASE_VERSION__
classpath("com.android.tools.build:gradle:4.0.1") classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1-rc1")
classpath("com.android.tools.build:gradle:7.0.0")
classpath(kotlin("gradle-plugin", version = "1.5.21")) classpath(kotlin("gradle-plugin", version = "1.5.21"))
} }
} }

10
examples/imageviewer/common/build.gradle.kts

@ -20,7 +20,7 @@ kotlin {
} }
named("androidMain") { named("androidMain") {
dependencies { dependencies {
api("androidx.appcompat:appcompat:1.3.0-beta01") api("androidx.appcompat:appcompat:1.3.1")
api("androidx.core:core-ktx:1.3.1") api("androidx.core:core-ktx:1.3.1")
implementation("io.ktor:ktor-client-cio:1.4.1") implementation("io.ktor:ktor-client-cio:1.4.1")
} }
@ -35,13 +35,11 @@ kotlin {
} }
android { android {
compileSdkVersion(30) compileSdk = 30
defaultConfig { defaultConfig {
minSdkVersion(21) minSdk = 21
targetSdkVersion(30) targetSdk = 30
versionCode = 1
versionName = "1.0"
} }
compileOptions { compileOptions {

2
examples/imageviewer/desktop/build.gradle.kts

@ -29,8 +29,6 @@ compose.desktop {
packageName = "ImageViewer" packageName = "ImageViewer"
packageVersion = "1.0.0" packageVersion = "1.0.0"
modules("jdk.crypto.ec")
val iconsRoot = project.file("../common/src/desktopMain/resources/images") val iconsRoot = project.file("../common/src/desktopMain/resources/images")
macOS { macOS {
iconFile.set(iconsRoot.resolve("icon-mac.icns")) iconFile.set(iconsRoot.resolve("icon-mac.icns"))

2
examples/imageviewer/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

8
examples/issues/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
} }
android { android {
compileSdkVersion(30) compileSdk = 30
defaultConfig { defaultConfig {
minSdkVersion(26) minSdk = 26
targetSdkVersion(30) targetSdk = 30
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@ -22,5 +22,5 @@ android {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.3.0-alpha02") implementation("androidx.activity:activity-compose:1.3.0")
} }

6
examples/issues/build.gradle.kts

@ -8,10 +8,10 @@ buildscript {
dependencies { dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
classpath("org.jetbrains.compose:compose-gradle-plugin:0.4.0") classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1-rc1")
classpath("com.android.tools.build:gradle:4.0.1") classpath("com.android.tools.build:gradle:7.0.0")
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.5.10")) classpath(kotlin("gradle-plugin", version = "1.5.21"))
} }
} }

13
examples/issues/common/build.gradle.kts

@ -24,7 +24,7 @@ kotlin {
named("androidMain") { named("androidMain") {
kotlin.srcDirs("src/jvmAndAndroidMain/kotlin") kotlin.srcDirs("src/jvmAndAndroidMain/kotlin")
dependencies { dependencies {
api("androidx.appcompat:appcompat:1.3.0-beta01") api("androidx.appcompat:appcompat:1.3.1")
api("androidx.core:core-ktx:1.3.1") api("androidx.core:core-ktx:1.3.1")
} }
} }
@ -40,13 +40,11 @@ apollo {
} }
android { android {
compileSdkVersion(30) compileSdk = 30
defaultConfig { defaultConfig {
minSdkVersion(26) minSdk = 26
targetSdkVersion(30) targetSdk = 30
versionCode = 1
versionName = "1.0"
} }
compileOptions { compileOptions {
@ -57,9 +55,6 @@ android {
sourceSets { sourceSets {
named("main") { named("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml") manifest.srcFile("src/androidMain/AndroidManifest.xml")
// res.srcDirs("src/androidMain/res")
} }
} }
} }

22
examples/issues/desktop/src/jvmMain/kotlin/androidx/ui/examples/jetissues/Main.kt

@ -1,8 +1,11 @@
package androidx.ui.examples.jetissues package androidx.ui.examples.jetissues
import androidx.compose.desktop.Window
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowSize
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.window.application
import androidx.ui.examples.jetissues.view.JetIssuesView import androidx.ui.examples.jetissues.view.JetIssuesView
import androidx.ui.examples.jetissues.view.Repository import androidx.ui.examples.jetissues.view.Repository
import androidx.ui.examples.jetissues.data.IssuesRepositoryImpl import androidx.ui.examples.jetissues.data.IssuesRepositoryImpl
@ -11,11 +14,14 @@ import androidx.ui.examples.jetissues.data.defaultRepo
val repo = IssuesRepositoryImpl(defaultRepo.first, defaultRepo.second, System.getenv("GITHUB_TOKEN") ?: defaultAuth) val repo = IssuesRepositoryImpl(defaultRepo.first, defaultRepo.second, System.getenv("GITHUB_TOKEN") ?: defaultAuth)
fun main() = Window( fun main() = application {
title = "JetIssues", Window(
size = IntSize(1440, 768) onCloseRequest = ::exitApplication,
) { title = "JetIssues",
CompositionLocalProvider(Repository provides repo) { state = WindowState(size = WindowSize(1440.dp, 768.dp))
JetIssuesView() ) {
CompositionLocalProvider(Repository provides repo) {
JetIssuesView()
}
} }
} }

2
examples/issues/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

6
examples/notepad/build.gradle.kts

@ -3,12 +3,13 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins { plugins {
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
kotlin("jvm") version "1.5.10" kotlin("jvm") version "1.5.21"
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build229") id("org.jetbrains.compose") version ("1.0.0-alpha1-rc1")
} }
repositories { repositories {
google()
mavenCentral() mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
} }
@ -21,7 +22,6 @@ dependencies {
compose.desktop { compose.desktop {
application { application {
mainClass = "MainKt" mainClass = "MainKt"
jvmArgs("-Dskiko.rendering.laf.global=true")
nativeDistributions { nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)

2
examples/notepad/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

2
examples/notepad/src/main/kotlin/NotepadApplication.kt

@ -25,7 +25,7 @@ fun NotepadApplication(state: NotepadApplicationState) {
@Composable @Composable
private fun ApplicationTray(state: NotepadApplicationState) { private fun ApplicationTray(state: NotepadApplicationState) {
Tray( Tray(
LocalAppResources.current.icon ?: return, LocalAppResources.current.icon,
state = state.tray, state = state.tray,
hint = "Notepad", hint = "Notepad",
menu = { ApplicationMenu(state) } menu = { ApplicationMenu(state) }

41
examples/notepad/src/main/kotlin/common/AppResources.kt

@ -3,15 +3,14 @@ package common
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Description import androidx.compose.material.icons.filled.Description
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import util.toAwtImage import androidx.compose.ui.graphics.vector.ImageVector
import java.awt.image.BufferedImage import androidx.compose.ui.graphics.vector.RenderVectorGroup
import androidx.compose.ui.graphics.vector.VectorPainter
import androidx.compose.ui.graphics.vector.rememberVectorPainter
val LocalAppResources = staticCompositionLocalOf<AppResources> { val LocalAppResources = staticCompositionLocalOf<AppResources> {
error("LocalNotepadResources isn't provided") error("LocalNotepadResources isn't provided")
@ -19,20 +18,22 @@ val LocalAppResources = staticCompositionLocalOf<AppResources> {
@Composable @Composable
fun rememberAppResources(): AppResources { fun rememberAppResources(): AppResources {
val resources = remember { AppResources() } val icon = rememberVectorPainter(Icons.Default.Description, Color(0xFF2CA4E1))
return remember { AppResources(icon) }
LaunchedEffect(Unit) {
resources.init()
}
return resources
} }
class AppResources { class AppResources(val icon: VectorPainter)
var icon: BufferedImage? by mutableStateOf(null)
private set
suspend fun init() { @OptIn(ExperimentalComposeUiApi::class)
icon = Icons.Default.Description.toAwtImage(Color(0xFF2CA4E1)) @Composable
} fun rememberVectorPainter(image: ImageVector, tintColor: Color) =
} rememberVectorPainter(
defaultWidth = image.defaultWidth,
defaultHeight = image.defaultHeight,
viewportWidth = image.viewportWidth,
viewportHeight = image.viewportHeight,
name = image.name,
tintColor = tintColor,
tintBlendMode = image.tintBlendMode,
content = { _, _ -> RenderVectorGroup(group = image.root) }
)

3
examples/notepad/src/main/kotlin/util/Dialogs.kt

@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.AwtWindow import androidx.compose.ui.window.AwtWindow
import androidx.compose.ui.window.FrameWindowScope
import androidx.compose.ui.window.WindowScope import androidx.compose.ui.window.WindowScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
@ -16,7 +17,7 @@ import javax.swing.JOptionPane
@OptIn(ExperimentalComposeUiApi::class) @OptIn(ExperimentalComposeUiApi::class)
@Composable @Composable
fun WindowScope.FileDialog( fun FrameWindowScope.FileDialog(
title: String, title: String,
isLoad: Boolean, isLoad: Boolean,
onResult: (result: Path?) -> Unit onResult: (result: Path?) -> Unit

10
examples/notepad/src/main/kotlin/window/NotepadWindow.kt

@ -7,11 +7,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.window.MenuBar import androidx.compose.ui.window.*
import androidx.compose.ui.window.Notification
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPlacement
import androidx.compose.ui.window.WindowScope
import common.LocalAppResources import common.LocalAppResources
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -28,7 +24,7 @@ fun NotepadWindow(state: NotepadWindowState) {
Window( Window(
state = state.window, state = state.window,
title = titleOf(state), title = titleOf(state),
icon = LocalAppResources.current.icon ?: return, icon = LocalAppResources.current.icon,
onCloseRequest = { exit() } onCloseRequest = { exit() }
) { ) {
LaunchedEffect(Unit) { state.run() } LaunchedEffect(Unit) { state.run() }
@ -98,7 +94,7 @@ private fun WindowNotifications(state: NotepadWindowState) {
} }
@Composable @Composable
private fun WindowScope.WindowMenuBar(state: NotepadWindowState) = MenuBar { private fun FrameWindowScope.WindowMenuBar(state: NotepadWindowState) = MenuBar {
val scope = rememberCoroutineScope() val scope = rememberCoroutineScope()
fun save() = scope.launch { state.save() } fun save() = scope.launch { state.save() }

8
examples/widgetsgallery/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
} }
android { android {
compileSdkVersion(30) compileSdk = 30
defaultConfig { defaultConfig {
minSdkVersion(26) minSdk = 26
targetSdkVersion(30) targetSdk = 30
versionCode = 1 versionCode = 1
versionName = "1.0" versionName = "1.0"
} }
@ -22,5 +22,5 @@ android {
dependencies { dependencies {
implementation(project(":common")) implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.3.0-alpha02") implementation("androidx.activity:activity-compose:1.3.0")
} }

2
examples/widgetsgallery/build.gradle.kts

@ -9,7 +9,7 @@ buildscript {
dependencies { dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1-rc1") classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1-rc1")
classpath("com.android.tools.build:gradle:4.0.1") classpath("com.android.tools.build:gradle:7.0.0")
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.5.21")) classpath(kotlin("gradle-plugin", version = "1.5.21"))
} }

13
examples/widgetsgallery/common/build.gradle.kts

@ -20,15 +20,12 @@ kotlin {
} }
} }
named("androidMain") { named("androidMain") {
kotlin.srcDirs("src/jvmMain/kotlin")
dependencies { dependencies {
api("androidx.appcompat:appcompat:1.3.0-beta01") api("androidx.appcompat:appcompat:1.3.1")
api("androidx.core:core-ktx:1.3.1") api("androidx.core:core-ktx:1.3.1")
} }
} }
named("desktopMain") { named("desktopMain") {
kotlin.srcDirs("src/jvmMain/kotlin")
resources.srcDirs("src/commonMain/resources")
dependencies { dependencies {
api(compose.desktop.common) api(compose.desktop.common)
} }
@ -37,13 +34,11 @@ kotlin {
} }
android { android {
compileSdkVersion(30) compileSdk = 30
defaultConfig { defaultConfig {
minSdkVersion(21) minSdk = 21
targetSdkVersion(30) targetSdk = 30
versionCode = 1
versionName = "1.0"
} }
compileOptions { compileOptions {

2
examples/widgetsgallery/common/src/androidMain/AndroidManifest.xml

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest package="org.jetbrains.compose.demo.widgets"/> <manifest package="org.jetbrains.compose.demo.widgets.platform"/>

2
examples/widgetsgallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt

@ -5,7 +5,7 @@ import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.imageResource import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.vectorResource import androidx.compose.ui.res.vectorResource
import org.jetbrains.compose.demo.widgets.R import org.jetbrains.compose.demo.widgets.platform.R
@Composable @Composable
actual fun imageResource(res: String): ImageBitmap { actual fun imageResource(res: String): ImageBitmap {

14
examples/widgetsgallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt

@ -1,13 +1,12 @@
package org.jetbrains.compose.demo.widgets.platform package org.jetbrains.compose.demo.widgets.platform
import androidx.compose.runtime.*
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.PointerIcon import androidx.compose.ui.input.pointer.awtCursor
import androidx.compose.ui.input.pointer.pointerIcon import androidx.compose.ui.input.pointer.pointerIcon
import androidx.compose.ui.input.pointer.pointerMoveFilter import androidx.compose.ui.input.pointer.pointerMoveFilter
import java.awt.Cursor
actual fun Modifier.pointerMoveFilter( actual fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean, onEnter: () -> Boolean,
@ -16,10 +15,5 @@ actual fun Modifier.pointerMoveFilter(
): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove) ): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove)
@OptIn(ExperimentalComposeUiApi::class) @OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.cursorForHorizontalResize(): Modifier = composed { actual fun Modifier.cursorForHorizontalResize(): Modifier =
var isHover by remember { mutableStateOf(false) } pointerIcon(awtCursor(Cursor(Cursor.E_RESIZE_CURSOR)))
pointerMoveFilter(
onEnter = { isHover = true; true },
onExit = { isHover = false; true }
).pointerIcon(if (isHover) PointerIcon.Crosshair else PointerIcon.Default)
}

29
examples/widgetsgallery/desktop/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt

@ -1,27 +1,18 @@
package org.jetbrains.compose.demo.widgets package org.jetbrains.compose.demo.widgets
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.* import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowSize
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.window.application
import org.jetbrains.compose.demo.widgets.ui.MainView import org.jetbrains.compose.demo.widgets.ui.MainView
import java.awt.Dimension
import java.awt.Toolkit
fun main() { fun main() = application {
val size = getPreferredWindowSize(600, 800) Window(
singleWindowApplication ( onCloseRequest = ::exitApplication,
title = "Widgets Gallery", title = "Widgets Gallery",
state = WindowState(size = WindowSize(size.width.dp, size.height.dp)), state = WindowState(size = WindowSize(800.dp, 600.dp))
) { ) {
MainView() MainView()
} }
} }
private fun getPreferredWindowSize(desiredWidth: Int, desiredHeight: Int): IntSize {
val screenSize: Dimension = Toolkit.getDefaultToolkit().screenSize
val preferredWidth: Int = (screenSize.width * 0.8f).toInt()
val preferredHeight: Int = (screenSize.height * 0.8f).toInt()
val width: Int = if (desiredWidth < preferredWidth) desiredWidth else preferredWidth
val height: Int = if (desiredHeight < preferredHeight) desiredHeight else preferredHeight
return IntSize(width, height)
}

2
examples/widgetsgallery/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

Loading…
Cancel
Save