Fix satellite by removing shadowing flows and using parameter-based MapState

This commit is contained in:
2025-10-07 20:55:33 +02:00
parent 5e562b89e2
commit e4029faf50
3 changed files with 36 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ package app.klottr.ui
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Modifier
import app.klottr.location.LastLocationStore
import app.klottr.location.LocationServiceProvider
@@ -31,9 +32,14 @@ fun MapContent(
// Radie-override för klotter; null = använd default, 0 = obegränsat
klotterRadiusM: Int? = null,
onlyExtraKlotter: Boolean = false,
onFeaturesApplied: (() -> Unit)? = null
onFeaturesApplied: (() -> Unit)? = null,
satellite: Boolean,
night: Boolean
) {
val satellite = SettingsStore.getSatelliteMap()
println("🛰 Satellite flag = $satellite")
// --- Läs aktuella inställningar från SettingsStore (utan Flow) ---
// satellite kommer redan som parameter från KlottrAppShell
val showKlotter = SettingsStore.getShowKlotter()
val showWiki = SettingsStore.getShowWikipedia()
val wikiRadius = SettingsStore.getWikiRadiusMeters()
@@ -42,6 +48,7 @@ fun MapContent(
val showFornsok = SettingsStore.getShowFornsok()
val fornsokRadius = SettingsStore.getFornsokRadiusMeters()
var myLat by remember { mutableStateOf<Double?>(null) }
var myLon by remember { mutableStateOf<Double?>(null) }
@@ -208,7 +215,7 @@ fun MapContent(
val startLat = initialLat ?: lastKnown?.lat ?: 59.2974 // Årsta Torg
val startLon = initialLon ?: lastKnown?.lon ?: 18.0520
val mapState = remember {
val mapState = remember(satellite) {
MapState(
initialCamera = CameraPosition(
target = LatLng(startLat, startLon),
@@ -235,7 +242,8 @@ fun MapContent(
val n = klotter.firstOrNull { it.i.toString() == nid }
?: extraKlotter.firstOrNull { it.i.toString() == nid }
if (n != null) {
val titleLine = n.t.substringBefore('\n').ifBlank { "Okänt klotter" }
val titleLine =
n.t.substringBefore('\n').ifBlank { "Okänt klotter" }
onKlotterClick(nid, n.a, n.o, titleLine)
}
}
@@ -270,7 +278,6 @@ fun MapContent(
onFeaturesApplied?.invoke()
}
)
MapSyncEffects(
controller = mapController,
myLat = if (onlyExtraKlotter) null else myLat,
@@ -288,6 +295,7 @@ fun MapContent(
}
}
}
}
@Composable