shared(location): add expect/actual LastLocationStore (GeoPoint)

app(util): adapt LastLocationStore to delegate to shared store while keeping android.location.Location API
This commit is contained in:
2025-09-14 23:01:00 +02:00
parent ac451816e0
commit c65f230665
3 changed files with 28 additions and 1 deletions

View File

@@ -25,5 +25,19 @@ object MatchBus {
}
object LastLocationStore {
@Volatile var lastKnownLocation: Location? = null
// Adapter som låter befintlig Android-kod använda android.location.Location,
// men under huven lagras värdet i KMP-store (GeoPoint) i :shared.
var lastKnownLocation: Location?
get() {
val gp = app.klottr.location.LastLocationStore.lastKnown // Hämta från delad store
return gp?.let {
Location("klottr").apply { latitude = it.lat; longitude = it.lon }
}
}
set(value) {
app.klottr.location.LastLocationStore.lastKnown = value?.let {
app.klottr.location.GeoPoint(it.latitude, it.longitude)
}
}
}