diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index fa6cdfa..c0f0453 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.compose.desktop.application.dsl.TargetFormat + plugins { alias(libs.plugins.kotlinMultiplatform) alias(libs.plugins.androidApplication) @@ -12,7 +14,9 @@ kotlin { } } } - + + jvm("desktop") + listOf( iosX64(), iosArm64(), @@ -49,6 +53,12 @@ kotlin { } } + val desktopMain by getting + desktopMain.dependencies { + implementation(compose.desktop.currentOs) + implementation(libs.coroutines.swing) + } + val iosX64Main by getting val iosArm64Main by getting val iosSimulatorArm64Main by getting @@ -95,3 +105,16 @@ android { debugImplementation(libs.compose.ui.tooling) } } + +compose.desktop { + application { + mainClass = "MainKt" + + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "net.agorise.kee" + packageVersion = "1.0.0" + } + } +} + diff --git a/composeApp/src/commonMain/kotlin/net/agorise/kee/ui/screen/importaccount/ImportAccountScreen.kt b/composeApp/src/commonMain/kotlin/net/agorise/kee/ui/screen/importaccount/ImportAccountScreen.kt index 8eeb496..3bb0a91 100644 --- a/composeApp/src/commonMain/kotlin/net/agorise/kee/ui/screen/importaccount/ImportAccountScreen.kt +++ b/composeApp/src/commonMain/kotlin/net/agorise/kee/ui/screen/importaccount/ImportAccountScreen.kt @@ -95,5 +95,5 @@ private fun ImportAccountScreenContentLightPreview() = KeeTheme(useDarkTheme = f @Preview @Composable private fun ImportAccountScreenContentDarkPreview() = KeeTheme(useDarkTheme = true) { - ImportAccountScreenContent(ImportAccountScreenModel.State()) + ImportAccountScreenContent(ImportAccountScreenModel.State(blockCount = 265482)) } diff --git a/composeApp/src/desktopMain/kotlin/net/agorise/kee/Platform.jvm.kt b/composeApp/src/desktopMain/kotlin/net/agorise/kee/Platform.jvm.kt new file mode 100644 index 0000000..90a123b --- /dev/null +++ b/composeApp/src/desktopMain/kotlin/net/agorise/kee/Platform.jvm.kt @@ -0,0 +1,7 @@ +package net.agorise.kee + +class JVMPlatform: Platform { + override val name: String = "Java ${System.getProperty("java.version")}" +} + +actual fun getPlatform(): Platform = JVMPlatform() diff --git a/composeApp/src/desktopMain/kotlin/net/agorise/kee/main.kt b/composeApp/src/desktopMain/kotlin/net/agorise/kee/main.kt new file mode 100644 index 0000000..7f907ae --- /dev/null +++ b/composeApp/src/desktopMain/kotlin/net/agorise/kee/main.kt @@ -0,0 +1,20 @@ +package net.agorise.kee + + import androidx.compose.ui.unit.DpSize +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.WindowPosition +import androidx.compose.ui.window.application +import androidx.compose.ui.window.rememberWindowState +import cafe.adriel.voyager.navigator.Navigator +import net.agorise.kee.ui.screen.home.HomeScreen + +fun main() = application { + val state = rememberWindowState( + size = DpSize(420.dp, 880.dp), + position = WindowPosition(300.dp, 300.dp) + ) + Window(title = "Kee", onCloseRequest = ::exitApplication, state = state) { + Navigator(HomeScreen()) + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f5842ba..e7b5f62 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,9 +5,9 @@ android-minSdk = "26" android-targetSdk = "34" androidx-activityCompose = "1.8.2" compose = "1.6.4" -compose-plugin = "1.6.0" +compose-plugin = "1.6.1" coroutines = "1.8.0" -kotlin = "1.9.22" +kotlin = "1.9.23" ktor = "2.3.9" multiplatform-settings = "1.1.1" voyager = "1.0.0" @@ -16,7 +16,8 @@ voyager = "1.0.0" androidx-activity-compose = { group = "androidx.activity", name ="activity-compose", version.ref = "androidx-activityCompose" } compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "compose" } compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview", version.ref = "compose" } -coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } +coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" } +coroutines-swing = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-swing", version.ref = "coroutines" } ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktor" } ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" } ktor-client-websockets = { group = "io.ktor", name = "ktor-client-websockets", version.ref = "ktor" } diff --git a/shared/preferences/build.gradle.kts b/shared/preferences/build.gradle.kts index b9a1478..c7cf725 100644 --- a/shared/preferences/build.gradle.kts +++ b/shared/preferences/build.gradle.kts @@ -12,6 +12,8 @@ kotlin { } } + jvm() + iosX64() iosArm64() iosSimulatorArm64() diff --git a/shared/preferences/src/commonMain/kotlin/net/agorise/shared/preferences/KeePreferences.kt b/shared/preferences/src/commonMain/kotlin/net/agorise/shared/preferences/KeePreferences.kt index 1835212..b719a00 100644 --- a/shared/preferences/src/commonMain/kotlin/net/agorise/shared/preferences/KeePreferences.kt +++ b/shared/preferences/src/commonMain/kotlin/net/agorise/shared/preferences/KeePreferences.kt @@ -8,10 +8,10 @@ import com.russhwolf.settings.Settings object KeePreferences { // TODO Use a stronger implementation that allows encryption private val settings: Settings = Settings() - + // Keys used to store/retrieve preferences private const val KEY_RECOVERY_WORDS = "key_recovery_words" - + fun isAccountActive(): Boolean { return settings.hasKey(KEY_RECOVERY_WORDS) } diff --git a/shared/stargate/build.gradle.kts b/shared/stargate/build.gradle.kts index e367c06..5a47abe 100644 --- a/shared/stargate/build.gradle.kts +++ b/shared/stargate/build.gradle.kts @@ -12,6 +12,8 @@ kotlin { } } + jvm() + iosX64() iosArm64() iosSimulatorArm64() diff --git a/shared/stargate/src/commonMain/kotlin/net/agorise/shared/stargate/StargateBridge.kt b/shared/stargate/src/commonMain/kotlin/net/agorise/shared/stargate/StargateBridge.kt index 211eb52..12ae331 100644 --- a/shared/stargate/src/commonMain/kotlin/net/agorise/shared/stargate/StargateBridge.kt +++ b/shared/stargate/src/commonMain/kotlin/net/agorise/shared/stargate/StargateBridge.kt @@ -52,7 +52,7 @@ class StargateBridge { incoming.receiveAsFlow().collect { message -> (message as? Frame.Text)?.let { textFrame -> val text = textFrame.readText() - println(text) + println("Received -> $text") if (text.contains("\"method\":\"Block\"")) { blockBroadcastChannel.send(true) } else if (text.contains("\"count\":")) { @@ -68,7 +68,7 @@ class StargateBridge { private suspend fun DefaultClientWebSocketSession.writeMessages() { blockBroadcastChannel.receiveAsFlow().onEach { val blockCountRequest = getBlockCountRequest() - println("Requesting: $blockCountRequest") + println("Sent -> $blockCountRequest") outgoing.send(Frame.Text(blockCountRequest)) }.launchIn(this) }