Fix satellite by removing shadowing flows and using parameter-based MapState
This commit is contained in:
@@ -691,7 +691,9 @@ fun KlottrAppShell(
|
||||
onFornsokClick = { item -> openFornsok = OpenFornsok(item) },
|
||||
isKnownNote = { noteId ->
|
||||
FoundStore.getAll().any { it.layer == LAYER_KLOTTER && it.id == noteId.toString() }
|
||||
}
|
||||
},
|
||||
satellite = satellite,
|
||||
night = night
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -1001,7 +1003,9 @@ fun KlottrAppShell(
|
||||
revealKlotterTitles = true,
|
||||
klotterRadiusM = 0, // obegränsat
|
||||
onlyExtraKlotter = true,
|
||||
onFeaturesApplied = { myNotesLoading = false }
|
||||
onFeaturesApplied = { myNotesLoading = false },
|
||||
satellite = satellite,
|
||||
night = night
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package app.klottr.util
|
||||
|
||||
import app.klottr.prefs.KvPrefs
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
|
||||
object SettingsStore {
|
||||
// Nycklar (samma namn som tidigare för kompatibilitet)
|
||||
@@ -16,6 +18,17 @@ object SettingsStore {
|
||||
const val KEY_SHOW_FORNSOK = "show_fornsok"
|
||||
const val KEY_FORNSOK_RADIUS = "fornsok_radius_m"
|
||||
|
||||
// --- Flows för reaktiva uppdateringar till Compose ---
|
||||
val satelliteFlow: Flow<Boolean> = preferenceFlow("satellite_map", false)
|
||||
val showKlotterFlow: Flow<Boolean> = preferenceFlow("show_klotter", true)
|
||||
val showWikiFlow: Flow<Boolean> = preferenceFlow("show_wiki", true)
|
||||
val wikiRadiusFlow: Flow<Int> = preferenceFlow("wiki_radius", 200)
|
||||
val showDmFlow: Flow<Boolean> = preferenceFlow("show_dm", true)
|
||||
val dmRadiusFlow: Flow<Int> = preferenceFlow("dm_radius", 500)
|
||||
val showFornsokFlow: Flow<Boolean> = preferenceFlow("show_fornsok", true)
|
||||
val fornsokRadiusFlow: Flow<Int> = preferenceFlow("fornsok_radius", 500)
|
||||
|
||||
|
||||
// --- Observers via KvPrefs (plattformoberoende) ---
|
||||
fun observe(onChanged: (key: String?) -> Unit): (String?) -> Unit {
|
||||
KvPrefs.addListener(onChanged)
|
||||
@@ -88,4 +101,8 @@ object SettingsStore {
|
||||
fun setFornsokRadiusMeters(meters: Int) {
|
||||
KvPrefs.putInt(KEY_FORNSOK_RADIUS, meters)
|
||||
}
|
||||
// Enkel implementation tills vidare – returnerar bara ett statiskt Flow
|
||||
private fun <T> preferenceFlow(key: String, defaultValue: T): Flow<T> {
|
||||
return MutableStateFlow(defaultValue)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user