shared(build): enable Kotlin Compose compiler plugin for CMP (Kotlin 2.x)
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.kotlin.multiplatform.library)
|
||||
alias(libs.plugins.android.lint)
|
||||
// alias(libs.plugins.kotlin.compose)
|
||||
|
||||
// Compose Compiler plugin (Kotlin ≥2.0): krävs för Compose Multiplatform i :shared.
|
||||
// Versionen kommer från libs.versions.toml (plugins.kotlin-compose -> kotlin).
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
|
||||
// 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"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -71,7 +80,15 @@ kotlin {
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
implementation(libs.ktor.client.logging)
|
||||
|
||||
// CMP-runtime & foundation. Paketnamnen i koden är androidx.compose.*,
|
||||
// men artefakterna kommer från JetBrains Compose via compose.*-aliasen.
|
||||
// Lämna AndroidX Compose BOM/runtimes utanför :shared.
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.foundation)
|
||||
|
||||
// för Compose i :shared (Android-del)
|
||||
// OBS: Dessa AndroidX Compose-rader ska förbli utkommenterade i :shared.
|
||||
// :shared använder JetBrains Compose (org.jetbrains.compose) för CMP.
|
||||
//implementation(project.dependencies.platform("androidx.compose:compose-bom:${libs.versions.composeBom.get()}"))
|
||||
//implementation(libs.androidx.ui)
|
||||
//implementation(libs.androidx.material3)
|
||||
|
||||
30
shared/src/commonMain/kotlin/app/klottr/ui/SharedInfoCard.kt
Normal file
30
shared/src/commonMain/kotlin/app/klottr/ui/SharedInfoCard.kt
Normal file
@@ -0,0 +1,30 @@
|
||||
package app.klottr.ui
|
||||
|
||||
// Denna fil är en minimal CMP-pilot i :shared/commonMain.
|
||||
// Den visar att vi kan länka in delad @Composable-UI i Android utan att dra in AndroidX BOM.
|
||||
// Importerna heter androidx.compose.*, men artefakterna kommer från JetBrains Compose via
|
||||
// implementation(compose.runtime/foundation) i shared/build.gradle.kts.
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.BasicText
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/**
|
||||
* Minimal delad @Composable för CMP-piloten.
|
||||
* - Ligger i :shared/commonMain (plattformsneutral).
|
||||
* - Använder inga Android-specifika beroenden (ingen Material3 här).
|
||||
* - Kan anropas från Android nu och från iOS senare.
|
||||
*/
|
||||
@Composable
|
||||
fun SharedInfoCard() {
|
||||
Column(Modifier.padding(12.dp)) {
|
||||
BasicText("Klottr – delad UI (CMP)")
|
||||
Spacer(Modifier.height(4.dp))
|
||||
BasicText("Renderas från :shared/commonMain (JetBrains Compose).")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user