Roman Sedaikin
4 years ago
committed by
Rsedaikin
15 changed files with 678 additions and 0 deletions
@ -0,0 +1,15 @@
|
||||
*.iml |
||||
.gradle |
||||
/local.properties |
||||
/.idea |
||||
/.idea/caches |
||||
/.idea/libraries |
||||
/.idea/modules.xml |
||||
/.idea/workspace.xml |
||||
/.idea/navEditor.xml |
||||
/.idea/assetWizardSettings.xml |
||||
.DS_Store |
||||
build/ |
||||
/captures |
||||
.externalNativeBuild |
||||
.cxx |
@ -0,0 +1,21 @@
|
||||
<component name="ProjectRunConfigurationManager"> |
||||
<configuration default="false" name="desktop" type="GradleRunConfiguration" factoryName="Gradle"> |
||||
<ExternalSystemSettings> |
||||
<option name="executionName" /> |
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> |
||||
<option name="externalSystemIdString" value="GRADLE" /> |
||||
<option name="scriptParameters" value="" /> |
||||
<option name="taskDescriptions"> |
||||
<list /> |
||||
</option> |
||||
<option name="taskNames"> |
||||
<list> |
||||
<option value="run" /> |
||||
</list> |
||||
</option> |
||||
<option name="vmOptions" value="" /> |
||||
</ExternalSystemSettings> |
||||
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled> |
||||
<method v="2" /> |
||||
</configuration> |
||||
</component> |
@ -0,0 +1,4 @@
|
||||
Compose Desktop Application |
||||
|
||||
- `./gradlew run` - run application |
||||
- `./gradlew package` - package native distribution into `build/compose/binaries` |
@ -0,0 +1,31 @@
|
||||
import org.jetbrains.compose.compose |
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat |
||||
|
||||
plugins { |
||||
// __KOTLIN_COMPOSE_VERSION__ |
||||
kotlin("jvm") version "1.4.32" |
||||
// __LATEST_COMPOSE_RELEASE_VERSION__ |
||||
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "0.4.0-build188") |
||||
} |
||||
|
||||
repositories { |
||||
mavenLocal() |
||||
mavenCentral() |
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") |
||||
} |
||||
|
||||
dependencies { |
||||
implementation(compose.desktop.currentOs) |
||||
} |
||||
|
||||
compose.desktop { |
||||
application { |
||||
mainClass = "debugwriter.MainKt" |
||||
|
||||
nativeDistributions { |
||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) |
||||
packageName = "DebugWriterTool" |
||||
packageVersion = "1.0.0" |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash |
||||
set -euo pipefail |
||||
|
||||
# This script is for educational purposes only. |
||||
# Its purpose is to demonstrate how to compile & run Compose Desktop App without Gradle. |
||||
# Prefer running Gradle directly if your project uses Gradle. |
||||
|
||||
mkdir -p deps |
||||
|
||||
function mavenDep { |
||||
REPO=$1 |
||||
GROUP=$2 |
||||
ARTIFACT=$3 |
||||
VERSION=$4 |
||||
FILE="$ARTIFACT-$VERSION.jar" |
||||
if [ ! -f "deps/$FILE" ]; then |
||||
wget -P deps/ "$REPO/$GROUP/$ARTIFACT/$VERSION/$FILE" |
||||
fi |
||||
} |
||||
|
||||
PLATFORM=macos-x64 |
||||
SKIKO_VERSION=0.2.13 |
||||
# __KOTLIN_COMPOSE_VERSION__ |
||||
KOTLIN_VERSION=1.4.30 |
||||
# __LATEST_COMPOSE_RELEASE_VERSION__ |
||||
COMPOSE_VERSION=0.3.0 |
||||
COROUTINES_VERSION=1.3.6 |
||||
COLLECTIONS_VERSION=0.3 |
||||
SPACE_REPO="https://public.jetbrains.space/p/compose/packages/maven/" |
||||
MAVEN_CENTRAL="https://repo1.maven.org/maven2" |
||||
BINTRAY_KOTLINX="https://dl.bintray.com/kotlin/kotlinx" |
||||
|
||||
mavenDep "$SPACE_REPO" "org/jetbrains/skiko" "skiko-jvm-runtime-$PLATFORM" "$SKIKO_VERSION" |
||||
mavenDep "$SPACE_REPO" "org/jetbrains/compose" "compose-full" "$COMPOSE_VERSION" |
||||
mavenDep "$SPACE_REPO" "org/jetbrains/compose" "compose-compiler-hosted" "$COMPOSE_VERSION" |
||||
mavenDep "$BINTRAY_KOTLINX" "org/jetbrains/kotlinx" "kotlinx-collections-immutable-jvm" "$COLLECTIONS_VERSION" |
||||
mavenDep "$MAVEN_CENTRAL" "org/jetbrains/kotlinx" "kotlinx-coroutines-core" "$COROUTINES_VERSION" |
||||
mavenDep "$MAVEN_CENTRAL" "org/jetbrains/kotlin" "kotlin-stdlib" "$KOTLIN_VERSION" |
||||
if [ ! -f "deps/kotlin-compiler-$KOTLIN_VERSION.zip" ]; then |
||||
wget -P deps/ "https://github.com/JetBrains/kotlin/releases/download/v$KOTLIN_VERSION/kotlin-compiler-$KOTLIN_VERSION.zip" |
||||
pushd deps |
||||
unzip kotlin-compiler-$KOTLIN_VERSION.zip |
||||
popd |
||||
fi |
||||
|
||||
OUT_DIR=out/ |
||||
if [ -d "$OUT_DIR" ]; then |
||||
rm -rf $OUT_DIR |
||||
fi |
||||
|
||||
COMPILE_CLASSPATH="deps/compose-full-$COMPOSE_VERSION.jar:deps/skiko-jvm-runtime-$PLATFORM-$SKIKO_VERSION.jar:deps/kotlinx-coroutines-core-$COROUTINES_VERSION.jar" |
||||
RUNTIME_CLASSPATH="deps/kotlinx-collections-immutable-jvm-$COLLECTIONS_VERSION.jar:deps/kotlin-stdlib-$KOTLIN_VERSION.jar:$COMPILE_CLASSPATH" |
||||
SOURCES=$(find src/main -name "*.kt"|paste -sd " " -) |
||||
JAVA_OPTS=-Xmx1G deps/kotlinc/bin/kotlinc-jvm \ |
||||
-jvm-target 1.8 \ |
||||
-Xuse-ir \ |
||||
-Xmulti-platform \ |
||||
-Xplugin="deps/compose-compiler-hosted-$COMPOSE_VERSION.jar" \ |
||||
-cp "$COMPILE_CLASSPATH" \ |
||||
-d $OUT_DIR $SOURCES |
||||
|
||||
#jar cf result.jar -C "$OUT_DIR" . -C "src/main/resources" . |
||||
java -cp "out/:result.jar:$RUNTIME_CLASSPATH" MainKt |
@ -0,0 +1,2 @@
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 |
||||
kotlin.code.style=official |
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME |
||||
distributionPath=wrapper/dists |
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip |
||||
zipStoreBase=GRADLE_USER_HOME |
||||
zipStorePath=wrapper/dists |
@ -0,0 +1,183 @@
|
||||
#!/usr/bin/env sh |
||||
|
||||
# |
||||
# Copyright 2015 the original author or authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# https://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
# |
||||
|
||||
############################################################################## |
||||
## |
||||
## Gradle start up script for UN*X |
||||
## |
||||
############################################################################## |
||||
|
||||
# Attempt to set APP_HOME |
||||
# Resolve links: $0 may be a link |
||||
PRG="$0" |
||||
# Need this for relative symlinks. |
||||
while [ -h "$PRG" ] ; do |
||||
ls=`ls -ld "$PRG"` |
||||
link=`expr "$ls" : '.*-> \(.*\)$'` |
||||
if expr "$link" : '/.*' > /dev/null; then |
||||
PRG="$link" |
||||
else |
||||
PRG=`dirname "$PRG"`"/$link" |
||||
fi |
||||
done |
||||
SAVED="`pwd`" |
||||
cd "`dirname \"$PRG\"`/" >/dev/null |
||||
APP_HOME="`pwd -P`" |
||||
cd "$SAVED" >/dev/null |
||||
|
||||
APP_NAME="Gradle" |
||||
APP_BASE_NAME=`basename "$0"` |
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. |
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' |
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value. |
||||
MAX_FD="maximum" |
||||
|
||||
warn () { |
||||
echo "$*" |
||||
} |
||||
|
||||
die () { |
||||
echo |
||||
echo "$*" |
||||
echo |
||||
exit 1 |
||||
} |
||||
|
||||
# OS specific support (must be 'true' or 'false'). |
||||
cygwin=false |
||||
msys=false |
||||
darwin=false |
||||
nonstop=false |
||||
case "`uname`" in |
||||
CYGWIN* ) |
||||
cygwin=true |
||||
;; |
||||
Darwin* ) |
||||
darwin=true |
||||
;; |
||||
MINGW* ) |
||||
msys=true |
||||
;; |
||||
NONSTOP* ) |
||||
nonstop=true |
||||
;; |
||||
esac |
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar |
||||
|
||||
# Determine the Java command to use to start the JVM. |
||||
if [ -n "$JAVA_HOME" ] ; then |
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then |
||||
# IBM's JDK on AIX uses strange locations for the executables |
||||
JAVACMD="$JAVA_HOME/jre/sh/java" |
||||
else |
||||
JAVACMD="$JAVA_HOME/bin/java" |
||||
fi |
||||
if [ ! -x "$JAVACMD" ] ; then |
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME |
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the |
||||
location of your Java installation." |
||||
fi |
||||
else |
||||
JAVACMD="java" |
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. |
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the |
||||
location of your Java installation." |
||||
fi |
||||
|
||||
# Increase the maximum file descriptors if we can. |
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then |
||||
MAX_FD_LIMIT=`ulimit -H -n` |
||||
if [ $? -eq 0 ] ; then |
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then |
||||
MAX_FD="$MAX_FD_LIMIT" |
||||
fi |
||||
ulimit -n $MAX_FD |
||||
if [ $? -ne 0 ] ; then |
||||
warn "Could not set maximum file descriptor limit: $MAX_FD" |
||||
fi |
||||
else |
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" |
||||
fi |
||||
fi |
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock |
||||
if $darwin; then |
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" |
||||
fi |
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java |
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then |
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"` |
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` |
||||
JAVACMD=`cygpath --unix "$JAVACMD"` |
||||
|
||||
# We build the pattern for arguments to be converted via cygpath |
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` |
||||
SEP="" |
||||
for dir in $ROOTDIRSRAW ; do |
||||
ROOTDIRS="$ROOTDIRS$SEP$dir" |
||||
SEP="|" |
||||
done |
||||
OURCYGPATTERN="(^($ROOTDIRS))" |
||||
# Add a user-defined pattern to the cygpath arguments |
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then |
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" |
||||
fi |
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh |
||||
i=0 |
||||
for arg in "$@" ; do |
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` |
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option |
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition |
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` |
||||
else |
||||
eval `echo args$i`="\"$arg\"" |
||||
fi |
||||
i=`expr $i + 1` |
||||
done |
||||
case $i in |
||||
0) set -- ;; |
||||
1) set -- "$args0" ;; |
||||
2) set -- "$args0" "$args1" ;; |
||||
3) set -- "$args0" "$args1" "$args2" ;; |
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;; |
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; |
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; |
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; |
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; |
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; |
||||
esac |
||||
fi |
||||
|
||||
# Escape application args |
||||
save () { |
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done |
||||
echo " " |
||||
} |
||||
APP_ARGS=`save "$@"` |
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules |
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" |
||||
|
||||
exec "$JAVACMD" "$@" |
@ -0,0 +1,100 @@
|
||||
@rem |
||||
@rem Copyright 2015 the original author or authors. |
||||
@rem |
||||
@rem Licensed under the Apache License, Version 2.0 (the "License"); |
||||
@rem you may not use this file except in compliance with the License. |
||||
@rem You may obtain a copy of the License at |
||||
@rem |
||||
@rem https://www.apache.org/licenses/LICENSE-2.0 |
||||
@rem |
||||
@rem Unless required by applicable law or agreed to in writing, software |
||||
@rem distributed under the License is distributed on an "AS IS" BASIS, |
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
@rem See the License for the specific language governing permissions and |
||||
@rem limitations under the License. |
||||
@rem |
||||
|
||||
@if "%DEBUG%" == "" @echo off |
||||
@rem ########################################################################## |
||||
@rem |
||||
@rem Gradle startup script for Windows |
||||
@rem |
||||
@rem ########################################################################## |
||||
|
||||
@rem Set local scope for the variables with windows NT shell |
||||
if "%OS%"=="Windows_NT" setlocal |
||||
|
||||
set DIRNAME=%~dp0 |
||||
if "%DIRNAME%" == "" set DIRNAME=. |
||||
set APP_BASE_NAME=%~n0 |
||||
set APP_HOME=%DIRNAME% |
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. |
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" |
||||
|
||||
@rem Find java.exe |
||||
if defined JAVA_HOME goto findJavaFromJavaHome |
||||
|
||||
set JAVA_EXE=java.exe |
||||
%JAVA_EXE% -version >NUL 2>&1 |
||||
if "%ERRORLEVEL%" == "0" goto init |
||||
|
||||
echo. |
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. |
||||
echo. |
||||
echo Please set the JAVA_HOME variable in your environment to match the |
||||
echo location of your Java installation. |
||||
|
||||
goto fail |
||||
|
||||
:findJavaFromJavaHome |
||||
set JAVA_HOME=%JAVA_HOME:"=% |
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe |
||||
|
||||
if exist "%JAVA_EXE%" goto init |
||||
|
||||
echo. |
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% |
||||
echo. |
||||
echo Please set the JAVA_HOME variable in your environment to match the |
||||
echo location of your Java installation. |
||||
|
||||
goto fail |
||||
|
||||
:init |
||||
@rem Get command-line arguments, handling Windows variants |
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args |
||||
|
||||
:win9xME_args |
||||
@rem Slurp the command line arguments. |
||||
set CMD_LINE_ARGS= |
||||
set _SKIP=2 |
||||
|
||||
:win9xME_args_slurp |
||||
if "x%~1" == "x" goto execute |
||||
|
||||
set CMD_LINE_ARGS=%* |
||||
|
||||
:execute |
||||
@rem Setup the command line |
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar |
||||
|
||||
@rem Execute Gradle |
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% |
||||
|
||||
:end |
||||
@rem End local scope for the variables with windows NT shell |
||||
if "%ERRORLEVEL%"=="0" goto mainEnd |
||||
|
||||
:fail |
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of |
||||
rem the _cmd.exe /c_ return code! |
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 |
||||
exit /b 1 |
||||
|
||||
:mainEnd |
||||
if "%OS%"=="Windows_NT" endlocal |
||||
|
||||
:omega |
@ -0,0 +1,8 @@
|
||||
pluginManagement { |
||||
repositories { |
||||
// TODO: remove after new build is published |
||||
mavenLocal() |
||||
gradlePluginPortal() |
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") |
||||
} |
||||
} |
@ -0,0 +1,77 @@
|
||||
package debugwriter |
||||
|
||||
import androidx.compose.desktop.LocalAppWindow |
||||
import androidx.compose.desktop.Window |
||||
import androidx.compose.foundation.layout.Column |
||||
import androidx.compose.foundation.layout.Row |
||||
import androidx.compose.foundation.layout.Box |
||||
import androidx.compose.foundation.layout.fillMaxSize |
||||
import androidx.compose.foundation.layout.fillMaxWidth |
||||
import androidx.compose.foundation.layout.padding |
||||
import androidx.compose.material.Text |
||||
import androidx.compose.material.Button |
||||
import androidx.compose.material.MaterialTheme |
||||
import androidx.compose.material.Surface |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.runtime.getValue |
||||
import androidx.compose.runtime.mutableStateOf |
||||
import androidx.compose.runtime.remember |
||||
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.IntSize |
||||
import debugwriter.decoration.AppTheme |
||||
import kotlinx.coroutines.delay |
||||
import kotlinx.coroutines.GlobalScope |
||||
import kotlinx.coroutines.async |
||||
|
||||
private val fileName = "debug-info.txt" |
||||
private var output by mutableStateOf("") |
||||
private var isReady by mutableStateOf(false) |
||||
|
||||
fun main() { |
||||
enableDebugWritingTo(fileName) |
||||
|
||||
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 |
||||
) { |
||||
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("Open file", Modifier.weight(1f), { revealDebugOutput() }) |
||||
Button("Close", Modifier.weight(1f), { window.close() }) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
writeDebugInfo() |
||||
} |
||||
} |
||||
|
||||
private fun writeDebugInfo() { |
||||
isReady = false |
||||
GlobalScope.async { |
||||
delay(2000L) |
||||
isReady = true |
||||
output = readDebugOutput(fileName) |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
package debugwriter |
||||
|
||||
import java.io.File |
||||
import java.io.FileOutputStream |
||||
import java.io.InputStream |
||||
import java.io.PrintStream |
||||
import java.awt.Desktop |
||||
import org.jetbrains.skiko.hostOs |
||||
import org.jetbrains.skiko.OS |
||||
|
||||
fun enableDebugWritingTo(fileName: String = "output.txt") { |
||||
System.setProperty("skiko.hardwareInfo.enabled", "true") |
||||
val stream = PrintStream(FileOutputStream(fileName)) |
||||
System.setOut(stream) |
||||
} |
||||
|
||||
fun readDebugOutput(fileName: String = "output.txt"): String { |
||||
val inputStream: InputStream = File(fileName).inputStream() |
||||
return inputStream.bufferedReader().use { it.readText() } |
||||
} |
||||
|
||||
fun revealDebugOutput(fileName: String = "output.txt") { |
||||
val file = File("${System.getProperty("user.dir")}/$fileName") |
||||
if (Desktop.isDesktopSupported()) { |
||||
Desktop.getDesktop().open(file) |
||||
} |
||||
} |
@ -0,0 +1,73 @@
|
||||
package debugwriter |
||||
|
||||
import androidx.compose.foundation.layout.Box |
||||
import androidx.compose.foundation.layout.fillMaxWidth |
||||
import androidx.compose.foundation.layout.padding |
||||
import androidx.compose.foundation.layout.size |
||||
import androidx.compose.material.Button |
||||
import androidx.compose.material.CircularProgressIndicator |
||||
import androidx.compose.material.Text |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.ui.graphics.Color |
||||
import androidx.compose.ui.Alignment |
||||
import androidx.compose.ui.Modifier |
||||
import androidx.compose.ui.text.font.FontFamily |
||||
import androidx.compose.ui.text.font.FontWeight |
||||
import androidx.compose.ui.text.style.TextAlign |
||||
import androidx.compose.ui.text.TextStyle |
||||
import androidx.compose.ui.unit.dp |
||||
import androidx.compose.ui.unit.sp |
||||
|
||||
@Composable |
||||
internal fun Button(text: String, modifier: Modifier, action: () -> Unit) { |
||||
Box( |
||||
modifier = modifier, |
||||
contentAlignment = Alignment.Center |
||||
) { |
||||
Button( |
||||
modifier = Modifier.size(150.dp, 35.dp), |
||||
onClick = action |
||||
) { |
||||
Text(text) |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Composable |
||||
internal fun TextBox(text: String, modifier: Modifier) { |
||||
Box( |
||||
modifier = modifier, |
||||
contentAlignment = Alignment.Center |
||||
) { |
||||
Text(text) |
||||
} |
||||
} |
||||
|
||||
@Composable |
||||
internal fun Header(text: String) { |
||||
Box( |
||||
modifier = Modifier.padding(start = 30.dp, end = 30.dp).fillMaxWidth(), |
||||
contentAlignment = Alignment.Center |
||||
) { |
||||
Text( |
||||
text = text, |
||||
textAlign = TextAlign.Center, |
||||
style = TextStyle( |
||||
fontFamily = FontFamily.Default, |
||||
fontWeight = FontWeight.Normal, |
||||
fontSize = 20.sp, |
||||
color = Color.Gray |
||||
) |
||||
) |
||||
} |
||||
} |
||||
|
||||
@Composable |
||||
internal fun Loader(modifier: Modifier) { |
||||
Box( |
||||
modifier = modifier, |
||||
contentAlignment = Alignment.Center |
||||
) { |
||||
CircularProgressIndicator(modifier = Modifier.size(100.dp)) |
||||
} |
||||
} |
@ -0,0 +1,69 @@
|
||||
package debugwriter.decoration |
||||
|
||||
import androidx.compose.material.darkColors |
||||
import androidx.compose.material.lightColors |
||||
import androidx.compose.material.MaterialTheme |
||||
import androidx.compose.material.Typography |
||||
import androidx.compose.runtime.Composable |
||||
import androidx.compose.ui.graphics.Color |
||||
import androidx.compose.ui.text.font.FontFamily |
||||
import androidx.compose.ui.text.font.FontWeight |
||||
import androidx.compose.ui.text.TextStyle |
||||
import androidx.compose.ui.unit.sp |
||||
|
||||
private val colorPalette = darkColors( |
||||
primary = Color(0xffa5d6a7), |
||||
primaryVariant = Color(0xff388e3c), |
||||
secondary = Color(0xff80deea), |
||||
surface = Color(0xff323232), |
||||
background = Color(0xff323232), |
||||
onPrimary = Color.Black, |
||||
onSecondary = Color.White, |
||||
error = Color.Red, |
||||
) |
||||
|
||||
val typography = Typography( |
||||
body1 = TextStyle( |
||||
fontFamily = FontFamily.Default, |
||||
fontWeight = FontWeight.Normal, |
||||
fontSize = 16.sp |
||||
), |
||||
body2 = TextStyle( |
||||
fontFamily = FontFamily.Default, |
||||
fontWeight = FontWeight.Normal, |
||||
fontSize = 14.sp |
||||
), |
||||
button = TextStyle( |
||||
fontFamily = FontFamily.Default, |
||||
fontWeight = FontWeight.W500, |
||||
fontSize = 14.sp |
||||
), |
||||
caption = TextStyle( |
||||
fontFamily = FontFamily.Default, |
||||
fontWeight = FontWeight.Normal, |
||||
fontSize = 12.sp, |
||||
), |
||||
subtitle1 = TextStyle( |
||||
fontFamily = FontFamily.Default, |
||||
fontWeight = FontWeight.Normal, |
||||
fontSize = 16.sp, |
||||
color = Color.Gray |
||||
), |
||||
subtitle2 = TextStyle( |
||||
fontFamily = FontFamily.Default, |
||||
fontWeight = FontWeight.Normal, |
||||
fontSize = 14.sp, |
||||
color = Color.Gray |
||||
), |
||||
) |
||||
|
||||
@Composable |
||||
fun AppTheme( |
||||
content: @Composable() () -> Unit, |
||||
) { |
||||
MaterialTheme( |
||||
colors = colorPalette, |
||||
typography = typography, |
||||
content = content |
||||
) |
||||
} |
Loading…
Reference in new issue