shared(ui): add NearbyContent (material-free) and subtitle/list wiring
app(ui): use NearbyContent in NearbyDialog and mark finds before render
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
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.text.BasicText
|
||||
|
||||
import app.klottr.nearby.NearbyEntryShared
|
||||
import app.klottr.nearby.isClickable
|
||||
import app.klottr.net.DigitaltMuseumItem
|
||||
import app.klottr.net.FornsokItem
|
||||
|
||||
/**
|
||||
* Material-fri innehålls-komponent för “Närliggande”.
|
||||
* Visar laddning/fel/tomtext och annars listan via NearbyList.
|
||||
*/
|
||||
@Composable
|
||||
fun NearbyContent(
|
||||
loading: Boolean,
|
||||
error: String?,
|
||||
hasLocation: Boolean,
|
||||
entries: List<NearbyEntryShared>,
|
||||
dm: List<DigitaltMuseumItem>,
|
||||
forn: List<FornsokItem>,
|
||||
onWikiClick: (Long, Double, Double) -> Unit,
|
||||
onDmClick: (DigitaltMuseumItem) -> Unit,
|
||||
onFornsokClick: (FornsokItem) -> Unit,
|
||||
onKlotterClick: (String, Double, Double, String) -> Unit,
|
||||
rowTextStyle: TextStyle
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(max = 420.dp)
|
||||
.padding(0.dp)
|
||||
) {
|
||||
when {
|
||||
loading -> BasicText("Söker …", style = rowTextStyle)
|
||||
error != null -> BasicText(error, style = rowTextStyle)
|
||||
!hasLocation -> BasicText("Okänt avstånd – försök igen.", style = rowTextStyle)
|
||||
entries.isEmpty() -> BasicText("Inga träffar i närheten.", style = rowTextStyle)
|
||||
else -> {
|
||||
NearbyList(
|
||||
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)
|
||||
}
|
||||
}
|
||||
},
|
||||
rowTextStyle = rowTextStyle
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user