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. 85
      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)
}
}

85
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()
}
}
}
}
}

Loading…
Cancel
Save