diff --git a/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt index 4f9cf4014..867913659 100644 --- a/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt @@ -25,6 +25,7 @@ class AndroidFeatureConventionPlugin : Plugin { add("implementation", project(":core:ui")) add("implementation", project(":core:designsystem")) add("implementation", project(":shared")) + add("implementation", project(":desktop")) add("implementation", libs.findLibrary("androidx.material.navigation").get()) add("implementation", libs.findLibrary("androidx.hilt.navigation.compose").get()) diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts new file mode 100644 index 000000000..3b1627122 --- /dev/null +++ b/desktop/build.gradle.kts @@ -0,0 +1,43 @@ +import org.jetbrains.compose.desktop.application.dsl.TargetFormat + +plugins { + kotlin("multiplatform") + alias(libs.plugins.jetbrainsCompose) +} + + +kotlin { + jvm { + jvmToolchain(17) + withJava() + } + + sourceSets { + val jvmMain by getting { + dependencies { + implementation(project(":shared")) + implementation(compose.desktop.currentOs) + } + } + } +} + +compose.desktop { + application { + mainClass = "MainKt" + nativeDistributions { + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "org.mifospay.desktop" + packageVersion = "1.0.0" + windows { + // a version for all Windows distributables + packageVersion = "1.0.0" + // a version only for the msi package + msiPackageVersion = "1.0.0" + // a version only for the exe package + exePackageVersion = "1.0.0" + menu = true + } + } + } +} \ No newline at end of file diff --git a/desktop/src/jvmMain/kotlin/Main.kt b/desktop/src/jvmMain/kotlin/Main.kt new file mode 100644 index 000000000..9bfc3a1d0 --- /dev/null +++ b/desktop/src/jvmMain/kotlin/Main.kt @@ -0,0 +1,17 @@ +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application +import androidx.compose.ui.window.rememberWindowState +import org.mifospay.shared.MainView + +fun main() { + application { + val windowState = rememberWindowState() + Window( + onCloseRequest = ::exitApplication, + state = windowState, + title = "MifosWallet" + ) { + MainView() + } + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2a202745b..b8f312808 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -25,10 +25,11 @@ androidxHilt = "1.2.0" androidxLifecycle = "2.8.4" hilt = "2.51.1" junit = "4.13.2" -kotlin = "1.9.25" -ksp = "1.9.25-1.0.20" -firebaseCrashlyticsPlugin = "3.0.2" -gmsPlugin = "4.4.2" +kotlin = "1.9.22" +compose-plugin = "1.6.1" +ksp = "1.9.22-1.0.18" +firebaseCrashlyticsPlugin = "2.9.9" +gmsPlugin = "4.4.1" butterknifePlugin = "10.2.3" secrets = "2.0.1" lifecycleVersion = "2.8.4" @@ -198,6 +199,7 @@ spotless-gradle = { group = "com.diffplug.spotless", name = "spotless-plugin-gra [plugins] +jetbrainsCompose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" } android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } gms = { id = "com.google.gms.google-services", version.ref = "gmsPlugin" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 2130d8e4b..94141b7a7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -64,3 +64,4 @@ include(":feature:upi-setup") include(":feature:qr") include(":feature:home") include(":shared") +include(":desktop") diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 71bf750d5..7bb408554 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("multiplatform") id("com.android.library") + alias(libs.plugins.jetbrainsCompose) } kotlin { @@ -11,7 +12,11 @@ kotlin { } } } - + + jvm("desktop"){ + jvmToolchain(17) + } + listOf( iosX64(), iosArm64(), @@ -26,6 +31,16 @@ kotlin { sourceSets { commonMain.dependencies { //put your multiplatform dependencies here + implementation(compose.material) + implementation(compose.material3) + } + + val desktopMain by getting { + dependencies { + // Desktop specific dependencies + implementation(compose.desktop.currentOs) + implementation(compose.desktop.common) + } } } task("testClasses") diff --git a/shared/src/commonMain/kotlin/org/mifospay/shared/App.kt b/shared/src/commonMain/kotlin/org/mifospay/shared/App.kt new file mode 100644 index 000000000..f57a99b1a --- /dev/null +++ b/shared/src/commonMain/kotlin/org/mifospay/shared/App.kt @@ -0,0 +1,26 @@ +package org.mifospay.shared + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.material.Text +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.text.font.FontWeight + + +@Composable +fun App() { + Box( + modifier = Modifier + .fillMaxSize(), + contentAlignment = Alignment.Center + ) { + Text( + text = "MifosWallet", + style = MaterialTheme.typography.titleLarge.copy(fontWeight = FontWeight.Bold), + color = MaterialTheme.colorScheme.onSurface, + ) + } +} \ No newline at end of file diff --git a/shared/src/desktopMain/kotlin/org/mifospay/shared/Platform.desktop.kt b/shared/src/desktopMain/kotlin/org/mifospay/shared/Platform.desktop.kt new file mode 100644 index 000000000..881d0911c --- /dev/null +++ b/shared/src/desktopMain/kotlin/org/mifospay/shared/Platform.desktop.kt @@ -0,0 +1,12 @@ +package org.mifospay.shared + +import androidx.compose.runtime.Composable + +@Composable +fun MainView() = App() + +class JVMPlatform: Platform { + override val name: String ="Windows" +} + +actual fun getPlatform(): Platform = JVMPlatform() \ No newline at end of file