Move most of net to shared, use AsyncImage for url loaded images
Introduce BuildKonfig to be able to have KMP build config Preparing DialogShells to be moved to shared (not possible to move yet)
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
|
||||
import java.util.Properties
|
||||
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
|
||||
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.BOOLEAN
|
||||
import java.time.Instant
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.kotlin.multiplatform.library)
|
||||
@@ -14,7 +18,8 @@ plugins {
|
||||
// JetBrains Compose Multiplatform för UI i :shared/commonMain.
|
||||
// Viktigt: detta är *inte* AndroidX Compose BOM. Vi använder compose.*-aliasen
|
||||
// (org.jetbrains.compose) vilket gör att :shared förblir plattformsneutral.
|
||||
id("org.jetbrains.compose") version "1.8.2"
|
||||
id("org.jetbrains.compose") version "1.9.0"
|
||||
id("com.codingfeline.buildkonfig") version "0.17.1"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -98,6 +103,14 @@ kotlin {
|
||||
implementation(compose.material3)
|
||||
// Material Icons (Icons.Filled.*, Icons.Outlined.*)
|
||||
implementation(compose.materialIconsExtended)
|
||||
implementation(compose.components.resources)
|
||||
|
||||
// Coil 3 (KMP) — image loading + caching for Compose Multiplatform
|
||||
implementation("io.coil-kt.coil3:coil-compose:3.3.0")
|
||||
// Use Ktor-based multiplatform networking backend for Coil
|
||||
implementation("io.coil-kt.coil3:coil-network-ktor3:3.3.0")
|
||||
|
||||
|
||||
|
||||
// för Compose i :shared (Android-del)
|
||||
// OBS: Dessa AndroidX Compose-rader ska förbli utkommenterade i :shared.
|
||||
@@ -106,6 +119,10 @@ kotlin {
|
||||
//implementation(libs.androidx.ui)
|
||||
//implementation(libs.androidx.material3)
|
||||
}
|
||||
// resources.srcDirs(
|
||||
// "src/commonMain/composeResources",
|
||||
// "src/commonMain/resources"
|
||||
// )
|
||||
}
|
||||
|
||||
commonTest {
|
||||
@@ -145,4 +162,44 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ------------------- BuildKonfig (shared constants) -------------------
|
||||
// Read local.properties (or override via -PKEY=VALUE)
|
||||
val localProps = Properties().apply {
|
||||
val f = rootProject.file("local.properties")
|
||||
if (f.exists()) f.inputStream().use { load(it) }
|
||||
}
|
||||
|
||||
fun prop(name: String): String? =
|
||||
providers.gradleProperty(name).orNull ?: localProps.getProperty(name)
|
||||
|
||||
fun propOr(name: String, default: String) = prop(name) ?: default
|
||||
|
||||
val buildTimeUtc: String = Instant.now().toString()
|
||||
|
||||
// Infer build type from tasks (Debug/Release), but allow override via -PBUILD_TYPE=...
|
||||
val inferredBuildType: String = providers.gradleProperty("BUILD_TYPE").orNull
|
||||
?: if (gradle.startParameter.taskNames.any { it.contains("release", ignoreCase = true) }) "release" else "debug"
|
||||
|
||||
|
||||
buildkonfig {
|
||||
packageName = "app.klottr"
|
||||
|
||||
defaultConfigs {
|
||||
buildConfigField(STRING, "BUILD_TYPE", inferredBuildType )
|
||||
|
||||
buildConfigField(STRING, "APP_NAME", "Klottr")
|
||||
buildConfigField(STRING, "BUILD_TIME_UTC", buildTimeUtc)
|
||||
|
||||
buildConfigField(STRING, "SERVER_API_BASE_URL", propOr("SERVER_API_BASE_URL", ""))
|
||||
buildConfigField(STRING, "SERVER_API_KEY", propOr("SERVER_API_KEY", ""))
|
||||
buildConfigField(STRING, "WEB_CLIENT_ID", propOr("WEB_CLIENT_ID", ""))
|
||||
|
||||
buildConfigField(STRING, "DM_API_KEY", propOr("DM_API_KEY", ""))
|
||||
buildConfigField(STRING, "DM_OWNERS", propOr("DM_OWNERS", ""))
|
||||
|
||||
buildConfigField(BOOLEAN, "KLLOG_DEBUG", propOr("KLLOG_DEBUG", "false"))
|
||||
buildConfigField(BOOLEAN, "KLLOG_HTTP_DEBUG", propOr("KLLOG_HTTP_DEBUG", "false"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user