From 44fa5c1dbea3c80e8f2a56f26fbdde98a16f6af8 Mon Sep 17 00:00:00 2001 From: Fabian Norlin Date: Wed, 1 Oct 2025 17:57:25 +0200 Subject: [PATCH] Show recent finds under "Hem" tab in new UI using reused KlottrHomeContent logic --- .../kotlin/app/klottr/KlottrAppShell.kt | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/shared/src/commonMain/kotlin/app/klottr/KlottrAppShell.kt b/shared/src/commonMain/kotlin/app/klottr/KlottrAppShell.kt index 72a801f..87f5203 100644 --- a/shared/src/commonMain/kotlin/app/klottr/KlottrAppShell.kt +++ b/shared/src/commonMain/kotlin/app/klottr/KlottrAppShell.kt @@ -2,6 +2,7 @@ package app.klottr import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -321,8 +322,8 @@ fun KlottrAppShell( label = { Text("Lager") } ) NavigationBarItem( - selected = false, - onClick = { /* TODO Nära */ }, + selected = (selectedTab == "nearby"), + onClick = { selectedTab = "nearby" }, icon = { Icon(Icons.Filled.Place, contentDescription = "Nära") }, label = { Text("Nära") } ) @@ -421,6 +422,50 @@ fun KlottrAppShell( footer = { /* tom i nya layouten */ } ) } + "nearby" -> { + Column(modifier = Modifier.padding(innerPadding)) { + // Övre halvan: karta + Box(modifier = Modifier.weight(1f).fillMaxWidth()) { + MapDialog( + onClose = { /* inget, vi stänger inte i nya UI */ }, + onKlotterClick = { id, la, lo, label -> + openKlotter = OpenKlotter(id = id, lat = la, lon = lo, label = label) + }, + onOpenUrl = { _, url -> AppNavigator.openUrl(url) }, + isKnownNote = { noteId -> + FoundStore.getAll().any { it.layer == LAYER_KLOTTER && it.id == noteId.toString() } + } + ) + } + + // Nedre halvan: närliggande-lista + Box(modifier = Modifier.weight(1f).fillMaxWidth()) { + NearbyDialog( + loading = nearbyLoading, + error = nearbyError, + lat = lastKnownLat, + lon = lastKnownLon, + entries = nearbyBundle?.entries.orEmpty(), + dm = nearbyBundle?.dm.orEmpty(), + forn = nearbyBundle?.forn.orEmpty(), + onOpenAction = { action -> + when (action) { + is FoundOpenAction.Klotter -> + openKlotter = OpenKlotter(action.id, action.lat, action.lon, action.label) + is FoundOpenAction.Wiki -> + openWiki = OpenWiki(action.pageId, action.lat, action.lon) + is FoundOpenAction.Fornsok -> + openFornsok = OpenFornsok(action.item) + is FoundOpenAction.DigitaltMuseum -> + openDm = action.item + FoundOpenAction.None -> Unit + } + }, + onClose = { /* inget i nya UI */ } + ) + } + } + } else -> { Box(modifier = Modifier.padding(innerPadding)) { Text("Här kommer ${selectedTab}-sidan")