From 25767eecb277c5328faab66708dc270c7328a182 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 2 Mar 2021 17:19:17 +0600 Subject: [PATCH] add github badge onto web version --- .../desktop/utils/OpenLink.kt | 18 ++++++++++++++++++ .../desktop/views/BuilderView.kt | 8 ++++++++ web/src/jsMain/resources/index.html | 1 + 3 files changed, 27 insertions(+) create mode 100644 desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/OpenLink.kt diff --git a/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/OpenLink.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/OpenLink.kt new file mode 100644 index 0000000..e64b29e --- /dev/null +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/utils/OpenLink.kt @@ -0,0 +1,18 @@ +package dev.inmo.kmppscriptbuilder.desktop.utils + +import java.awt.Desktop +import java.lang.Exception +import java.net.URI + +fun openLink(link: String): Boolean { + val desktop = if (Desktop.isDesktopSupported()) Desktop.getDesktop() else null + if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) { + try { + desktop.browse(URI(link)) + return true + } catch (e: Exception) { + e.printStackTrace() + } + } + return false +} diff --git a/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/BuilderView.kt b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/BuilderView.kt index 8f3f756..7e9200f 100644 --- a/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/BuilderView.kt +++ b/desktop/src/jvmMain/kotlin/dev/inmo/kmppscriptbuilder/desktop/views/BuilderView.kt @@ -6,10 +6,18 @@ import androidx.compose.foundation.layout.* import androidx.compose.material.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.asImageBitmap +import androidx.compose.ui.platform.DesktopPlatform +import androidx.compose.ui.res.loadSvgResource import androidx.compose.ui.res.svgResource +import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.dp import dev.inmo.kmppscriptbuilder.core.models.Config import dev.inmo.kmppscriptbuilder.desktop.utils.* +import dev.inmo.micro_utils.coroutines.safelyWithoutExceptions +import java.awt.Desktop +import java.lang.Exception +import java.net.URL class BuilderView : View() { private val projectTypeView = ProjectTypeView() diff --git a/web/src/jsMain/resources/index.html b/web/src/jsMain/resources/index.html index 4f3a5ea..cae9640 100644 --- a/web/src/jsMain/resources/index.html +++ b/web/src/jsMain/resources/index.html @@ -10,6 +10,7 @@