Browse Source

Refactor: CFD 1.0.1

debug-writer
Rsedaikin 3 years ago
parent
commit
507ddfddf9
  1. 13
      debug-writer/build.gradle.kts
  2. 2
      debug-writer/gradle.properties
  3. 7
      debug-writer/settings.gradle.kts
  4. 23
      debug-writer/src/main/kotlin/debugwriter/Main.kt

13
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"
}
}

2
debug-writer/gradle.properties

@ -1,2 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
kotlin.version=1.6.10
compose.version=1.0.1

7
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")
}
plugins {
kotlin("jvm").version(extra["kotlin.version"] as String)
id("org.jetbrains.compose").version(extra["compose.version"] as String)
}
}

23
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,12 +40,17 @@ fun main() {
output = "Failed to cteate file: $fileName"
}
try {
application {
val closed = remember { mutableStateOf(false) }
if (!closed.value) {
Window(
onCloseRequest = ::exitApplication,
title = "DebugWriter",
size = IntSize(650, 450)
state = WindowState(
position = WindowPosition.Aligned(Alignment.Center),
size = DpSize(650.dp, 450.dp)
)
) {
val window = LocalAppWindow.current
AppTheme {
Surface(
modifier = Modifier.fillMaxSize()
@ -68,7 +77,7 @@ fun main() {
}
}
)
Button("Close", Modifier.weight(1f), { window.close() })
Button("Close", Modifier.weight(1f), { closed.value = true })
}
}
}
@ -80,6 +89,8 @@ fun main() {
}
}
}
}
}
catch(e: Exception) {
writeException(fileName, e)
System.exit(0)

Loading…
Cancel
Save