shared(ui): NearbyList fills its space and adds a lightweight, material-free scrollbar thumb; optional LazyListState support
shared(nearby,ui): add resolveNearbyOpenAction for “Nearby” entries and remove 420dp height cap — NearbyContent now fills its space and uses the shared open resolver
This commit is contained in:
@@ -87,3 +87,40 @@ suspend fun resolveFoundOpenAction(
|
||||
else -> FoundOpenAction.None
|
||||
}
|
||||
}
|
||||
|
||||
fun resolveNearbyOpenAction(
|
||||
entry: NearbyEntryShared,
|
||||
dmList: List<app.klottr.net.DigitaltMuseumItem>,
|
||||
fornList: List<app.klottr.net.FornsokItem>
|
||||
): FoundOpenAction {
|
||||
return when (entry.layer) {
|
||||
app.klottr.util.FoundStore.LAYER_KLOTTER -> {
|
||||
val id = entry.id ?: return FoundOpenAction.None // Säkerställ id
|
||||
FoundOpenAction.Klotter(
|
||||
id = id,
|
||||
lat = entry.lat,
|
||||
lon = entry.lon,
|
||||
label = entry.label
|
||||
)
|
||||
}
|
||||
app.klottr.util.FoundStore.LAYER_WIKI -> {
|
||||
val id = entry.id?.toLongOrNull() ?: return FoundOpenAction.None // Sida måste kunna tolkas
|
||||
FoundOpenAction.Wiki(
|
||||
pageId = id,
|
||||
lat = entry.lat,
|
||||
lon = entry.lon
|
||||
)
|
||||
}
|
||||
app.klottr.util.FoundStore.LAYER_DM -> {
|
||||
val id = entry.id ?: return FoundOpenAction.None
|
||||
val item = dmList.firstOrNull { it.id == id } ?: return FoundOpenAction.None
|
||||
FoundOpenAction.DigitaltMuseum(item)
|
||||
}
|
||||
app.klottr.util.FoundStore.LAYER_FORNSOK -> {
|
||||
val id = entry.id ?: return FoundOpenAction.None
|
||||
val item = fornList.firstOrNull { it.id == id } ?: return FoundOpenAction.None
|
||||
FoundOpenAction.Fornsok(item)
|
||||
}
|
||||
else -> FoundOpenAction.None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package app.klottr.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.text.BasicText
|
||||
|
||||
import app.klottr.nearby.FoundOpenAction
|
||||
import app.klottr.nearby.NearbyEntryShared
|
||||
import app.klottr.nearby.isClickable
|
||||
import app.klottr.nearby.resolveNearbyOpenAction
|
||||
import app.klottr.net.DigitaltMuseumItem
|
||||
import app.klottr.net.FornsokItem
|
||||
|
||||
@@ -33,11 +32,9 @@ fun NearbyContent(
|
||||
onKlotterClick: (String, Double, Double, String) -> Unit,
|
||||
rowTextStyle: TextStyle
|
||||
) {
|
||||
Box(
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(max = 420.dp)
|
||||
.padding(0.dp)
|
||||
.fillMaxSize() // Fyll den yta dialogen ger
|
||||
) {
|
||||
when {
|
||||
loading -> BasicText("Söker …", style = rowTextStyle)
|
||||
@@ -49,19 +46,12 @@ fun NearbyContent(
|
||||
entries = entries,
|
||||
isClickable = { e -> isClickable(e, dm, forn) },
|
||||
onEntryClick = { e ->
|
||||
when (e.layer) {
|
||||
app.klottr.util.FoundStore.LAYER_WIKI -> {
|
||||
val id = e.id; if (id != null) onWikiClick(id.toLong(), e.lat, e.lon)
|
||||
}
|
||||
app.klottr.util.FoundStore.LAYER_DM -> {
|
||||
val item = dm.firstOrNull { it.id == e.id }; if (item != null) onDmClick(item)
|
||||
}
|
||||
app.klottr.util.FoundStore.LAYER_FORNSOK -> {
|
||||
val item = forn.firstOrNull { it.id == e.id }; if (item != null) onFornsokClick(item)
|
||||
}
|
||||
app.klottr.util.FoundStore.LAYER_KLOTTER -> {
|
||||
val id = e.id; if (id != null) onKlotterClick(id, e.lat, e.lon, e.label)
|
||||
}
|
||||
when (val action = resolveNearbyOpenAction(e, dm, forn)) {
|
||||
is FoundOpenAction.Klotter -> onKlotterClick(action.id, action.lat, action.lon, e.label)
|
||||
is FoundOpenAction.Wiki -> onWikiClick(action.pageId, action.lat, action.lon)
|
||||
is FoundOpenAction.Fornsok -> onFornsokClick(action.item)
|
||||
is FoundOpenAction.DigitaltMuseum -> onDmClick(action.item)
|
||||
FoundOpenAction.None -> Unit
|
||||
}
|
||||
},
|
||||
rowTextStyle = rowTextStyle
|
||||
@@ -69,4 +59,5 @@ fun NearbyContent(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user