shared(ui): make SharedInfoCard accept TextStyle for dark mode; keep foundation-only (no material deps)
This commit is contained in:
35
shared/src/commonMain/kotlin/app/klottr/ui/NearbyEntryRow.kt
Normal file
35
shared/src/commonMain/kotlin/app/klottr/ui/NearbyEntryRow.kt
Normal file
@@ -0,0 +1,35 @@
|
||||
package app.klottr.ui
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.foundation.text.BasicText
|
||||
|
||||
@Composable
|
||||
fun NearbyEntryRow(
|
||||
label: String, // ✅ Delad rad: huvudtext (titel/rubrik)
|
||||
subtitle: String, // ✅ Sekundär text (lager + avstånd + ev. extra)
|
||||
clickable: Boolean, // ✅ Ska raden gå att klicka på?
|
||||
onClick: (() -> Unit)? = null // ✅ Callback vid klick (valfri)
|
||||
) {
|
||||
// ✅ Grundlayout: en kolumn som fyller bredden, med lite padding runt
|
||||
var m = Modifier
|
||||
.fillMaxWidth() // ✅ Rad ska ta full bredd i listan
|
||||
.padding(horizontal = 16.dp, vertical = 10.dp) // ✅ Visuell luft
|
||||
|
||||
// ✅ Lägg till klickbarhet om vi har en callback
|
||||
if (clickable && onClick != null) {
|
||||
m = m.clickable { onClick() } // ✅ Klick triggar callback
|
||||
}
|
||||
|
||||
// ✅ Vi använder BasicText (foundation) istället för Material-komponenter
|
||||
// → håller :shared plattformsneutral och fri från AndroidX Material beroenden.
|
||||
Column(m) {
|
||||
BasicText(text = label) // ✅ Titel
|
||||
BasicText(text = subtitle) // ✅ Undertext
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ 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.text.TextStyle // Vi kan skicka in textstil från anroparen
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
/**
|
||||
@@ -21,10 +22,12 @@ import androidx.compose.ui.unit.dp
|
||||
* - Kan anropas från Android nu och från iOS senare.
|
||||
*/
|
||||
@Composable
|
||||
fun SharedInfoCard() {
|
||||
fun SharedInfoCard(
|
||||
textStyle: TextStyle = TextStyle.Default // [NY] Fallback: neutral stil; vi skickar in rätt stil från Android
|
||||
) {
|
||||
Column(Modifier.padding(12.dp)) {
|
||||
BasicText("Klottr – delad UI (CMP)")
|
||||
BasicText("Klottr – delad UI (CMP)", style = textStyle) // [ÄNDRAD] använd inskickad stil
|
||||
Spacer(Modifier.height(4.dp))
|
||||
BasicText("Renderas från :shared/commonMain (JetBrains Compose).")
|
||||
BasicText("Renderas från :shared/commonMain (JetBrains Compose).", style = textStyle) // [ÄNDRAD] använd inskickad stil
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user