diff --git a/buildSrc/src/main/kotlin/Deps.kt b/buildSrc/src/main/kotlin/Deps.kt index 0c7fae3..395c929 100644 --- a/buildSrc/src/main/kotlin/Deps.kt +++ b/buildSrc/src/main/kotlin/Deps.kt @@ -141,6 +141,10 @@ object Deps { val timber = "com.jakewharton.timber:timber:${Versions.timber}" } + object Desktop { + val libui = "com.github.msink:libui:0.1.8" + } + } diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 1596980..c03b151 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -52,7 +52,13 @@ val ideaActive = System.getProperty("idea.active") == "true" kotlin { val hostOsName = getHostOsName() - + if (ideaActive) { + when (hostOsName) { + "linux" -> linuxX64("native") + "macos" -> macosX64("native") + "windows" -> mingwX64("native") + } + } android() runningOnLinuxx86_64 { jvm() @@ -88,13 +94,13 @@ kotlin { } } - - linuxArm64() { - binaries { - executable { - } - } - } + //Disable for now as libui doesnt support arm64 +// linuxArm64() { +// binaries { +// executable { +// } +// } +// } } @@ -222,16 +228,53 @@ kotlin { - val nativeMain by creating { - dependsOn(commonMain) - dependencies { +// val nativeMain by creating { +// dependsOn(commonMain) +// dependencies { +// implementation(Deps.Desktop.libui) +// } +// } +// +// val nativeTest by creating { +// dependsOn(commonTest) +// dependencies { +// } +// } + + val nativeMain = if (ideaActive) { + val nativeMain by getting { + dependsOn(commonMain) + dependencies { + implementation(Deps.Desktop.libui) + } } + nativeMain + } else { + val nativeMain by creating { + dependsOn(commonMain) + dependencies { + implementation(Deps.Desktop.libui) + } + } + nativeMain } - val nativeTest by creating { - dependsOn(commonTest) - dependencies { + val nativeTest = if (ideaActive) { + val nativeTest by getting { + dependsOn(commonTest) + dependencies { + implementation(Deps.Native.coroutines) + } } + nativeTest + } else { + val nativeTest by creating { + dependsOn(commonTest) + dependencies { + implementation(Deps.Native.coroutines) + } + } + nativeTest } runningOnLinuxx86_64 { @@ -280,12 +323,12 @@ kotlin { dependsOn(nativeTest) } - val linuxArm64Main by getting { - dependsOn(nativeMain) - } - val linuxArm64Test by getting { - dependsOn(nativeTest) - } +// val linuxArm64Main by getting { +// dependsOn(nativeMain) +// } +// val linuxArm64Test by getting { +// dependsOn(nativeTest) +// } } runningOnMacos { diff --git a/sample/src/linuxMain/kotlin/com/ionspin/kotlin/crypto/sample/Runner.kt b/sample/src/nativeMain/kotlin/Runner.kt similarity index 71% rename from sample/src/linuxMain/kotlin/com/ionspin/kotlin/crypto/sample/Runner.kt rename to sample/src/nativeMain/kotlin/Runner.kt index 3343ed0..0630398 100644 --- a/sample/src/linuxMain/kotlin/com/ionspin/kotlin/crypto/sample/Runner.kt +++ b/sample/src/nativeMain/kotlin/Runner.kt @@ -1,5 +1,6 @@ import com.ionspin.kotlin.crypto.sample.Sample -fun main() { +fun main() : Unit { Sample.runSample() + ui() } diff --git a/sample/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/sample/UI.kt b/sample/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/sample/UI.kt new file mode 100644 index 0000000..2c84065 --- /dev/null +++ b/sample/src/nativeMain/kotlin/com/ionspin/kotlin/crypto/sample/UI.kt @@ -0,0 +1,30 @@ +import com.ionspin.kotlin.crypto.hash.Hash +import com.ionspin.kotlin.crypto.util.encodeToUByteArray +import com.ionspin.kotlin.crypto.util.toHexString +import libui.ktx.TextArea +import libui.ktx.appWindow +import libui.ktx.button +import libui.ktx.textarea +import libui.ktx.vbox + +fun ui() = appWindow( + title = "Hello", + width = 320, + height = 240 +) { + val hash = Hash.sha512("123".encodeToUByteArray()) + val text = "Hash (SHA512) of 123: ${hash.toHexString()}" + vbox { + lateinit var scroll: TextArea + + button("Test") { + action { + scroll.append(text.trimMargin()) + } + } + scroll = textarea { + readonly = true + stretchy = true + } + } +}