Browse Source

Refactor: CFD 1.0.1

debug-writer
Rsedaikin 3 years ago
parent
commit
507ddfddf9
  1. 13
      debug-writer/build.gradle.kts
  2. 4
      debug-writer/gradle.properties
  3. 9
      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 import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins { plugins {
// __KOTLIN_COMPOSE_VERSION__ kotlin("jvm")
kotlin("jvm") version "1.5.21" id("org.jetbrains.compose")
// __LATEST_COMPOSE_RELEASE_VERSION__
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build262")
} }
repositories { repositories {
mavenCentral() mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
google()
} }
dependencies { 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) implementation(compose.desktop.currentOs)
} }
@ -23,7 +26,7 @@ compose.desktop {
nativeDistributions { nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "DebugWriterTool" packageName = "KotlinJvmComposeDesktopApplication"
packageVersion = "1.0.0" packageVersion = "1.0.0"
} }
} }

4
debug-writer/gradle.properties

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

9
debug-writer/settings.gradle.kts

@ -1,8 +1,11 @@
pluginManagement { pluginManagement {
repositories { repositories {
// TODO: remove after new build is published
mavenLocal()
gradlePluginPortal() gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") 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 package debugwriter
import androidx.compose.desktop.LocalAppWindow import androidx.compose.ui.window.application
import androidx.compose.desktop.Window 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.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
@ -20,6 +23,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.IntSize
import debugwriter.decoration.AppTheme import debugwriter.decoration.AppTheme
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
@ -36,47 +40,54 @@ fun main() {
output = "Failed to cteate file: $fileName" output = "Failed to cteate file: $fileName"
} }
try { try {
Window( application {
title = "DebugWriter", val closed = remember { mutableStateOf(false) }
size = IntSize(650, 450) if (!closed.value) {
) { Window(
val window = LocalAppWindow.current onCloseRequest = ::exitApplication,
title = "DebugWriter",
AppTheme { state = WindowState(
Surface( position = WindowPosition.Aligned(Alignment.Center),
modifier = Modifier.fillMaxSize() size = DpSize(650.dp, 450.dp)
)
) { ) {
Box( AppTheme {
modifier = Modifier.fillMaxSize().padding(20.dp), Surface(
contentAlignment = Alignment.Center modifier = Modifier.fillMaxSize()
) { ) {
Column { Box(
Header("Click [Refresh] to refresh info or [Open file] to see the output file.") modifier = Modifier.fillMaxSize().padding(20.dp),
if (isReady) { contentAlignment = Alignment.Center
TextBox(output, Modifier.weight(1f).padding(start = 30.dp, end = 30.dp)) ) {
} else { Column {
Loader(Modifier.weight(1f).fillMaxWidth()) Header("Click [Refresh] to refresh info or [Open file] to see the output file.")
} if (isReady) {
Row(modifier = Modifier.fillMaxWidth()) { TextBox(output, Modifier.weight(1f).padding(start = 30.dp, end = 30.dp))
Button("Refresh", Modifier.weight(1f), { writeDebugInfo() }) } else {
Button( Loader(Modifier.weight(1f).fillMaxWidth())
text = "Open file",
modifier = Modifier.weight(1f),
action = {
if(!revealDebugOutput(fileName)) {
output = "Failed to open file: $fileName"
}
} }
) Row(modifier = Modifier.fillMaxWidth()) {
Button("Close", Modifier.weight(1f), { window.close() }) 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) { if (result) {
writeDebugInfo() writeDebugInfo()
}
}
} }
} }
} }

Loading…
Cancel
Save