Location updates now handled in a more compose friendly way via StateFlow Lots of small changed in MainActivity and DetailDialogShell to make them platform independent Add new platform apis for openUrl, openMap (AppNavigator) Add Platform independent OutboxScheduler Try to clean up event handling of FoundEvents and location updates (need more cleanup) New wrapper for handling App Context in shared (could be used to clean up integration further)
35 lines
1.9 KiB
Kotlin
35 lines
1.9 KiB
Kotlin
package app.klottr.nearby //Regler för “Närliggande” (logik i commonMain)
|
|
|
|
import app.klottr.net.DigitaltMuseumItem //För att kunna slå upp DM-poster
|
|
import app.klottr.net.FornsokItem //För att kunna slå upp Fornsök-poster
|
|
import app.klottr.util.FoundStore //Lagerkonstanter
|
|
|
|
//Centraliserad regel: vilka entries är klickbara?
|
|
fun isClickable( //
|
|
entry: NearbyEntryShared, //Raden vi bedömer
|
|
dm: List<DigitaltMuseumItem>, //DM-listan (för id-uppslag)
|
|
forn: List<FornsokItem> //Fornsök-listan (för id-uppslag)
|
|
): Boolean = when (entry.layer) { //
|
|
FoundStore.LAYER_WIKI, //Wiki: klickbar om id finns
|
|
FoundStore.LAYER_KLOTTER -> entry.id != null //
|
|
FoundStore.LAYER_DM -> dm.any { it.id == entry.id } //Klickbar om vi hittar DM-objektet
|
|
FoundStore.LAYER_FORNSOK -> forn.any { it.id == entry.id } //Klickbar om vi hittar Fornsök-objektet
|
|
else -> false //
|
|
}
|
|
|
|
//Markera nya fynd i FoundStore baserat på delade entries (plattformneutral hjälpare)
|
|
fun markNewFinds( //
|
|
entries: List<NearbyEntryShared>, //Delade “Närliggande”-rader
|
|
nowMillis: Long, //Tidpunkt för markering
|
|
onMarked: () -> Unit //Callback om något faktiskt markerats nytt
|
|
) {
|
|
for (e in entries) { //
|
|
val id = e.id //Lokal kopia för säkra null-kontroller mellan moduler
|
|
if (e.distanceM <= e.insideRadiusM && id != null) { //Samma villkor som i appen
|
|
if (FoundStore.markFound(e.layer, id, e.label, e.lat, e.lon, nowMillis)) { //
|
|
onMarked() //Signalera att något nytt markerades
|
|
}
|
|
}
|
|
}
|
|
}
|