Use cached nearby results in "Nära" tab to show list immediately and refresh seamlessly in background

This commit is contained in:
2025-10-01 23:08:32 +02:00
parent 704342b6e2
commit 085e147862
2 changed files with 108 additions and 88 deletions

View File

@@ -3,6 +3,7 @@ package app.klottr.ui
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import app.klottr.location.LastLocationStore
import app.klottr.location.LocationServiceProvider
import app.klottr.maps.*
import app.klottr.net.*
@@ -134,20 +135,28 @@ fun MapContent(
return out
}
val lastKnown = LastLocationStore.lastKnownLocation.value
val startLat = initialLat ?: lastKnown?.lat ?: 59.2974 // Årsta Torg
val startLon = initialLon ?: lastKnown?.lon ?: 18.0520
val mapState = remember {
MapState(
initialCamera = CameraPosition(
target = LatLng(startLat, startLon),
zoom = 16f
),
initialUi = MapUiSettings(
compassEnabled = true,
zoomControlsEnabled = false,
myLocationButtonEnabled = hasFgLocationPerms(),
mapType = if (satellite) MapType.SATELLITE else MapType.NORMAL
)
)
}
Box(modifier = modifier) {
MapContainer(
state = MapState(
initialCamera = CameraPosition(
target = LatLng(initialLat ?: 59.3293, initialLon ?: 18.0686),
zoom = 16f
),
initialUi = MapUiSettings(
compassEnabled = true,
zoomControlsEnabled = false,
myLocationButtonEnabled = hasFgLocationPerms(),
mapType = if (satellite) MapType.SATELLITE else MapType.NORMAL
)
),
state = mapState,
onMapClick = { /* inget extra här */ },
onMarkerClick = { id ->
when {