This commit is contained in:
LavaDesu 2025-04-13 00:51:32 +10:00
commit aebc802b88
Signed by: cilly
GPG key ID: 6500251E087653C9
54 changed files with 1598 additions and 0 deletions

40
shared/build.gradle.kts Normal file
View file

@ -0,0 +1,40 @@
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
}
kotlin {
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
jvm()
sourceSets {
commonMain.dependencies {
// put your Multiplatform dependencies here
}
}
}
android {
namespace = "moe.lava.banksia.shared"
compileSdk = libs.versions.android.compileSdk.get().toInt()
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt()
}
}

View file

@ -0,0 +1,9 @@
package moe.lava.banksia
import android.os.Build
class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}"
}
actual fun getPlatform(): Platform = AndroidPlatform()

View file

@ -0,0 +1,3 @@
package moe.lava.banksia
const val SERVER_PORT = 8080

View file

@ -0,0 +1,9 @@
package moe.lava.banksia
class Greeting {
private val platform = getPlatform()
fun greet(): String {
return "Hello, ${platform.name}!"
}
}

View file

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

View file

@ -0,0 +1,9 @@
package moe.lava.banksia
import platform.UIKit.UIDevice
class IOSPlatform: Platform {
override val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
}
actual fun getPlatform(): Platform = IOSPlatform()

View file

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