shared(ui): FoundContent – add isBold param and forward to FoundList
app(found): pass isBold using !FoundStore.isAway(...) in FoundContent call
This commit is contained in:
@@ -130,6 +130,7 @@ import app.klottr.net.uploadImageFromUri
|
||||
import app.klottr.shared.SharedPing
|
||||
import app.klottr.theme.KlottrTheme
|
||||
import app.klottr.ui.FoundList // Delad, material-fri listkomponent för "Hittat"
|
||||
import app.klottr.ui.FoundContent // Delat innehåll för “Hittat”
|
||||
import app.klottr.ui.NearbyEntryRow
|
||||
import app.klottr.ui.NearbyList // Delad material-fri listkomponent
|
||||
import app.klottr.util.Auth
|
||||
@@ -787,49 +788,31 @@ private fun KlottrApp(
|
||||
if (foundList.isEmpty()) {
|
||||
Text("Inga fynd ännu.")
|
||||
} else {
|
||||
Box( // Behåll layout: fyll bredd + ta resterande höjd i kolumnen
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth() //
|
||||
.weight(1f) // samma som tidigare LazyColumn hade
|
||||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
) {
|
||||
FoundList( // Delad, material-fri listkomponent
|
||||
entries = foundList, // Vi skickar in befintliga "Hittat"-poster
|
||||
labelFor = { f -> // Rubrik per rad (med ev. förbättrad etikett)
|
||||
val key = "${f.layer}|${f.id}" //
|
||||
val base = labelOverrides[key] ?: f.label // Ta förbättrad etikett om finns
|
||||
if (base.isBlank()) { // Fallbacks om label saknas
|
||||
when (f.layer) {
|
||||
FoundStore.LAYER_KLOTTER -> "Okänt klotter"
|
||||
FoundStore.LAYER_DM -> "DigitaltMuseum"
|
||||
FoundStore.LAYER_FORNSOK -> "Fornsök"
|
||||
else -> "Wikipedia"
|
||||
}
|
||||
} else base
|
||||
},
|
||||
subtitleFor = { f -> // Byt till delad formatterare
|
||||
val my = LastLocationStore.lastKnownLocation // Aktuell position (kan vara null)
|
||||
val _tick = locationTick // Bind rad-UI till plats-tick (så avstånd uppdateras)
|
||||
app.klottr.nearby.foundSubtitle( // Anropa KMP-funktionen
|
||||
entry = f, // Hittat-raden
|
||||
currentLat = my?.latitude, // Nullable lat
|
||||
currentLon = my?.longitude, // Nullable lon
|
||||
showCoords = showCoords, // Samma toggle som tidigare
|
||||
distanceFormatter = ::formatDistance, // Plattformens avståndsformatterare
|
||||
coordsFormatter = ::formatCoords // Plattformens koordinatformatterare
|
||||
)
|
||||
},
|
||||
val my = LastLocationStore.lastKnownLocation // ny: läs senaste position för avståndsberäkning
|
||||
val _tick = locationTick // ny: bind UI till platsuppdateringar
|
||||
|
||||
isClickable = { f -> // Samma klick-regel som tidigare
|
||||
FoundContent( // ny: delat material-fritt “Hittat”-innehåll
|
||||
entries = foundList, // oför: dina fynd
|
||||
currentLat = my?.latitude, // ny: skickas till delad formatterare
|
||||
currentLon = my?.longitude, // ny: skickas till delad formatterare
|
||||
showCoords = showCoords, // oför: toggle för koordinater
|
||||
labelOverrides = labelOverrides, // ny: förbättrade etiketter (klotter)
|
||||
isClickable = { f -> // oför: samma klick-regel som innan
|
||||
(f.layer == FoundStore.LAYER_WIKI) ||
|
||||
(f.layer == FoundStore.LAYER_FORNSOK) ||
|
||||
(f.layer == FoundStore.LAYER_KLOTTER) ||
|
||||
(f.layer == FoundStore.LAYER_DM)
|
||||
},
|
||||
onEntryClick = { f -> // Samma klickbeteende som tidigare rader
|
||||
onEntryClick = { f -> // oför: samma klickbeteende som tidigare
|
||||
when (f.layer) {
|
||||
FoundStore.LAYER_KLOTTER -> {
|
||||
val display = (labelOverrides["${f.layer}|${f.id}"] ?: f.label).ifBlank { "Okänt klotter" } //
|
||||
openKlotter = OpenKlotter( //
|
||||
val display = (labelOverrides["${f.layer}|${f.id}"] ?: f.label).ifBlank { "Okänt klotter" }
|
||||
openKlotter = OpenKlotter(
|
||||
id = f.id,
|
||||
lat = f.lat,
|
||||
lon = f.lon,
|
||||
@@ -837,11 +820,11 @@ private fun KlottrApp(
|
||||
)
|
||||
}
|
||||
FoundStore.LAYER_WIKI -> {
|
||||
val pid = f.id.toLongOrNull() //
|
||||
if (pid != null) openWiki = OpenWiki(pid, f.lat, f.lon) //
|
||||
val pid = f.id.toLongOrNull()
|
||||
if (pid != null) openWiki = OpenWiki(pid, f.lat, f.lon)
|
||||
}
|
||||
FoundStore.LAYER_FORNSOK -> {
|
||||
scope.launch { // Samma enrich-flöde som tidigare
|
||||
scope.launch {
|
||||
val enriched = withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val around = Fornsok.getNearby(f.lat, f.lon, radiusMeters = 150)
|
||||
@@ -864,7 +847,7 @@ private fun KlottrApp(
|
||||
}
|
||||
}
|
||||
FoundStore.LAYER_DM -> {
|
||||
scope.launch { // Samma DM-lookup som tidigare
|
||||
scope.launch {
|
||||
val exact = withContext(Dispatchers.IO) {
|
||||
try { app.klottr.net.DigitaltMuseum.lookupByIdentifier(f.id) }
|
||||
catch (_: Exception) { null }
|
||||
@@ -880,9 +863,11 @@ private fun KlottrApp(
|
||||
}
|
||||
}
|
||||
},
|
||||
isBold = { f -> !FoundStore.isAway(context, f.layer, f.id) }, // Fet stil när posten är “aktiv”
|
||||
rowTextStyle = MaterialTheme.typography.bodyMedium.copy( // Tydlig text i dag/natt
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
isBold = { f -> !FoundStore.isAway(context, f.layer, f.id) }, // Fet rubrik när posten inte är "away"
|
||||
distanceFormatter = ::formatDistance, // Plattformsformatterare (meter → text)
|
||||
coordsFormatter = ::formatCoords, // Plattformsformatterare (lat/lon → text)
|
||||
rowTextStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface // Läsbar text dag/natt
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user