Skip to content

Commit

Permalink
Move to 0.5.0-build262
Browse files Browse the repository at this point in the history
  • Loading branch information
Rsedaikin committed Jul 26, 2021
1 parent 29912d8 commit 6419067
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 36 deletions.
4 changes: 2 additions & 2 deletions debug-writer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat

plugins {
// __KOTLIN_COMPOSE_VERSION__
kotlin("jvm") version "1.4.32"
kotlin("jvm") version "1.5.21"
// __LATEST_COMPOSE_RELEASE_VERSION__
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.4.0-build188")
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.5.0-build262")
}

repositories {
Expand Down
73 changes: 39 additions & 34 deletions debug-writer/src/main/kotlin/debugwriter/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,50 +35,55 @@ fun main() {
if (!result) {
output = "Failed to cteate file: $fileName"
}
try {
Window(
title = "DebugWriter",
size = IntSize(650, 450)
) {
val window = LocalAppWindow.current

Window(
title = "DebugWriter",
size = IntSize(650, 450)
) {
val window = LocalAppWindow.current

AppTheme {
Surface(
modifier = Modifier.fillMaxSize()
) {
Box(
modifier = Modifier.fillMaxSize().padding(20.dp),
contentAlignment = Alignment.Center
AppTheme {
Surface(
modifier = Modifier.fillMaxSize()
) {
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"
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"
}
}
}
)
Button("Close", Modifier.weight(1f), { window.close() })
)
Button("Close", Modifier.weight(1f), { window.close() })
}
}
}
}
}
}

if (result) {
writeDebugInfo()
if (result) {
writeDebugInfo()
}
}
}
catch(e: Exception) {
writeException(fileName, e)
System.exit(0)
}
}

private fun writeDebugInfo() {
Expand Down
14 changes: 14 additions & 0 deletions debug-writer/src/main/kotlin/debugwriter/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ fun enableDebugWritingTo(fileName: String = "output.txt"): Boolean {
}
}

fun writeException(fileName: String = "output.txt", e: Exception) {
try {
val directory = File(Paths.get(fileName).getParent().toString())
if (!directory.exists()) {
directory.mkdir()
}
val stream = PrintStream(FileOutputStream("$fileName"))
e.printStackTrace(stream)
revealDebugOutput(fileName)
} catch(e: Exception) {

}
}

fun readDebugOutput(fileName: String = "output.txt"): String {
val file = File("$fileName")
if (!file.exists()) {
Expand Down

0 comments on commit 6419067

Please sign in to comment.