refactor: move logic to core module

This commit is contained in:
Cilly Leang 2026-01-23 19:05:25 +11:00
parent f3fca134c7
commit dae42c48f2
Signed by: cilly
GPG key ID: 6500251E087653C9
13 changed files with 75 additions and 24 deletions

View file

@ -24,6 +24,7 @@ kotlin {
implementation(libs.androidx.activity.compose)
}
commonMain.dependencies {
implementation(project(":core"))
implementation(libs.compose.runtime)
implementation(libs.compose.foundation)
implementation(libs.compose.material3)

View file

@ -6,6 +6,7 @@ import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import moe.lava.neon.ui.App
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {

View file

@ -1,7 +0,0 @@
package moe.lava.neon
interface Platform {
val name: String
}
expect fun getPlatform(): Platform

View file

@ -1,4 +1,4 @@
package moe.lava.neon
package moe.lava.neon.ui
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image

View file

@ -1,4 +1,4 @@
package moe.lava.neon
package moe.lava.neon.ui
class Greeting {
private val platform = getPlatform()

View file

@ -1,7 +0,0 @@
package moe.lava.neon
class JVMPlatform: Platform {
override val name: String = "Java ${System.getProperty("java.version")}"
}
actual fun getPlatform(): Platform = JVMPlatform()

View file

@ -2,6 +2,7 @@ package moe.lava.neon
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import moe.lava.neon.ui.App
fun main() = application {
Window(

47
core/build.gradle.kts Normal file
View file

@ -0,0 +1,47 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.androidLibrary)
alias(libs.plugins.kotlinMultiplatform)
}
kotlin {
jvm()
androidTarget {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
sourceSets {
commonMain.dependencies {
// Add any common dependencies here
}
commonTest.dependencies {
implementation(libs.kotlin.test)
}
}
}
android {
namespace = "moe.lava.neon.core"
compileSdk = libs.versions.android.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt()
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}

View file

@ -1,4 +1,4 @@
package moe.lava.neon
package moe.lava.neon.core
import android.os.Build

View file

@ -0,0 +1,7 @@
package moe.lava.neon.core
interface Platform {
val name: String
}
expect fun getPlatform(): Platform

View file

@ -0,0 +1,7 @@
package moe.lava.neon.core
class JVMPlatform : Platform {
override val name: String = "Java ${System.getProperty("java.version")}"
}
actual fun getPlatform(): Platform = JVMPlatform()

View file

@ -14,7 +14,7 @@ composeMultiplatform = "1.10.0"
junit = "4.13.2"
kotlin = "2.3.0"
kotlinx-coroutines = "1.10.2"
material3 = "1.10.0-alpha05"
material3 = "1.10.0"
[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }

View file

@ -33,3 +33,4 @@ plugins {
}
include(":composeApp")
include(":core")