diff --git a/debug-writer/build.gradle.kts b/debug-writer/build.gradle.kts index 17e856cf48..719a17a8b9 100644 --- a/debug-writer/build.gradle.kts +++ b/debug-writer/build.gradle.kts @@ -2,18 +2,21 @@ import org.jetbrains.compose.compose import org.jetbrains.compose.desktop.application.dsl.TargetFormat plugins { - // __KOTLIN_COMPOSE_VERSION__ - kotlin("jvm") version "1.5.21" - // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build262") + kotlin("jvm") + id("org.jetbrains.compose") } repositories { mavenCentral() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + google() } dependencies { + // Note, if you develop a library, you should use compose.desktop.common. + // compose.desktop.currentOs should be used in launcher-sourceSet + // (in a separate module for demo project and in testMain). + // With compose.desktop.common you will also lose @Preview functionality implementation(compose.desktop.currentOs) } @@ -23,7 +26,7 @@ compose.desktop { nativeDistributions { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "DebugWriterTool" + packageName = "KotlinJvmComposeDesktopApplication" packageVersion = "1.0.0" } } diff --git a/debug-writer/gradle.properties b/debug-writer/gradle.properties index f1a9d3306a..7cea32dab0 100644 --- a/debug-writer/gradle.properties +++ b/debug-writer/gradle.properties @@ -1,2 +1,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +kotlin.version=1.6.10 +compose.version=1.0.1 diff --git a/debug-writer/settings.gradle.kts b/debug-writer/settings.gradle.kts index 1676142749..9474fbaae5 100644 --- a/debug-writer/settings.gradle.kts +++ b/debug-writer/settings.gradle.kts @@ -1,8 +1,11 @@ pluginManagement { repositories { - // TODO: remove after new build is published - mavenLocal() gradlePluginPortal() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } -} \ No newline at end of file + + plugins { + kotlin("jvm").version(extra["kotlin.version"] as String) + id("org.jetbrains.compose").version(extra["compose.version"] as String) + } +} diff --git a/debug-writer/src/main/kotlin/debugwriter/Main.kt b/debug-writer/src/main/kotlin/debugwriter/Main.kt index d96baed75b..f5e5fc0c5d 100644 --- a/debug-writer/src/main/kotlin/debugwriter/Main.kt +++ b/debug-writer/src/main/kotlin/debugwriter/Main.kt @@ -1,7 +1,10 @@ package debugwriter -import androidx.compose.desktop.LocalAppWindow -import androidx.compose.desktop.Window +import androidx.compose.ui.window.application +import androidx.compose.ui.window.rememberWindowState +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.WindowState +import androidx.compose.ui.window.WindowPosition import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Box @@ -20,6 +23,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.IntSize import debugwriter.decoration.AppTheme import kotlinx.coroutines.delay @@ -36,47 +40,54 @@ fun main() { output = "Failed to cteate file: $fileName" } try { - Window( - title = "DebugWriter", - size = IntSize(650, 450) - ) { - val window = LocalAppWindow.current - - AppTheme { - Surface( - modifier = Modifier.fillMaxSize() + application { + val closed = remember { mutableStateOf(false) } + if (!closed.value) { + Window( + onCloseRequest = ::exitApplication, + title = "DebugWriter", + state = WindowState( + position = WindowPosition.Aligned(Alignment.Center), + size = DpSize(650.dp, 450.dp) + ) ) { - Box( - modifier = Modifier.fillMaxSize().padding(20.dp), - contentAlignment = Alignment.Center - ) { - Column { - Header("Click [Refresh] to refresh info or [Open file] to see the output file.") - if (isReady) { - TextBox(output, Modifier.weight(1f).padding(start = 30.dp, end = 30.dp)) - } else { - Loader(Modifier.weight(1f).fillMaxWidth()) - } - Row(modifier = Modifier.fillMaxWidth()) { - Button("Refresh", Modifier.weight(1f), { writeDebugInfo() }) - Button( - text = "Open file", - modifier = Modifier.weight(1f), - action = { - if(!revealDebugOutput(fileName)) { - output = "Failed to open file: $fileName" - } + AppTheme { + Surface( + modifier = Modifier.fillMaxSize() + ) { + Box( + modifier = Modifier.fillMaxSize().padding(20.dp), + contentAlignment = Alignment.Center + ) { + Column { + Header("Click [Refresh] to refresh info or [Open file] to see the output file.") + if (isReady) { + TextBox(output, Modifier.weight(1f).padding(start = 30.dp, end = 30.dp)) + } else { + Loader(Modifier.weight(1f).fillMaxWidth()) } - ) - Button("Close", Modifier.weight(1f), { window.close() }) + Row(modifier = Modifier.fillMaxWidth()) { + Button("Refresh", Modifier.weight(1f), { writeDebugInfo() }) + Button( + text = "Open file", + modifier = Modifier.weight(1f), + action = { + if(!revealDebugOutput(fileName)) { + output = "Failed to open file: $fileName" + } + } + ) + Button("Close", Modifier.weight(1f), { closed.value = true }) + } + } } } } - } - } - if (result) { - writeDebugInfo() + if (result) { + writeDebugInfo() + } + } } } }