Share Nearby dialog container and fix night-mode text in detail dialogs
- New: shared/ui/NearbyDialogContent.kt (material-free container for dialog body) - Android: use NearbyDialogContent in NearbyDialog; keep AlertDialog shell only - Fix: pass MaterialTheme colors to Wiki/Fornsok/DM detail contents (title/body/caption) so text follows light/dark mode
This commit is contained in:
@@ -146,7 +146,7 @@ import app.klottr.ui.KlottrAboutContent
|
|||||||
import app.klottr.ui.KlottrHomeContent // Ny: delat mittinnehåll
|
import app.klottr.ui.KlottrHomeContent // Ny: delat mittinnehåll
|
||||||
import app.klottr.ui.LoginRequiredContent
|
import app.klottr.ui.LoginRequiredContent
|
||||||
import app.klottr.ui.NearbyContent // Delat material-fritt innehåll för Närliggande
|
import app.klottr.ui.NearbyContent // Delat material-fritt innehåll för Närliggande
|
||||||
import app.klottr.ui.MapPanelShell
|
import app.klottr.ui.NearbyDialogContent
|
||||||
import app.klottr.ui.SettingsContent // Delad material-fri UI för inställningar
|
import app.klottr.ui.SettingsContent // Delad material-fri UI för inställningar
|
||||||
import app.klottr.ui.WikiDetailContent // Ny: delad Wiki-layout
|
import app.klottr.ui.WikiDetailContent // Ny: delad Wiki-layout
|
||||||
import app.klottr.ui.WriteDocContent // Använd delad, material-fri formulär-UI
|
import app.klottr.ui.WriteDocContent // Använd delad, material-fri formulär-UI
|
||||||
@@ -1294,34 +1294,23 @@ private fun NearbyDialog(
|
|||||||
title = { Text("Närliggande") },
|
title = { Text("Närliggande") },
|
||||||
text = {
|
text = {
|
||||||
val hasLocation = (lat != null && lon != null)
|
val hasLocation = (lat != null && lon != null)
|
||||||
|
|
||||||
// Dialogens innehåll i delat skal med rimlig höjd (max ~80% av skärmen)
|
|
||||||
val cfg = LocalConfiguration.current
|
val cfg = LocalConfiguration.current
|
||||||
val maxDialogHeight = (cfg.screenHeightDp * 0.8f).dp
|
val maxDialogHeight = (cfg.screenHeightDp * 0.8f).dp
|
||||||
|
|
||||||
MapPanelShell(
|
NearbyDialogContent(maxHeight = maxDialogHeight) {
|
||||||
modifier = Modifier
|
NearbyContent(
|
||||||
.fillMaxWidth()
|
loading = loading,
|
||||||
.heightIn(min = 360.dp, max = maxDialogHeight), // Gör dialogytan stor nog och skrollbar
|
error = error,
|
||||||
title = null, // AlertDialog visar redan "Närliggande" som titel
|
hasLocation = hasLocation,
|
||||||
titleTextStyle = MaterialTheme.typography.titleLarge.copy(
|
entries = if (hasLocation) entries else emptyList(),
|
||||||
color = MaterialTheme.colorScheme.onSurface
|
dm = dm,
|
||||||
),
|
forn = forn,
|
||||||
mainContent = {
|
onOpenAction = onOpenAction,
|
||||||
NearbyContent(
|
rowTextStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||||
loading = loading,
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
error = error,
|
|
||||||
hasLocation = hasLocation,
|
|
||||||
entries = if (hasLocation) entries else emptyList(), // Filtrera direkt i anropet, ingen skuggning
|
|
||||||
dm = dm,
|
|
||||||
forn = forn,
|
|
||||||
onOpenAction = onOpenAction, // Ny enhetlig callback
|
|
||||||
rowTextStyle = MaterialTheme.typography.bodyMedium.copy(
|
|
||||||
color = MaterialTheme.colorScheme.onSurface
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
},
|
},
|
||||||
confirmButton = { Button(onClick = onClose) { Text("Stäng") } }
|
confirmButton = { Button(onClick = onClose) { Text("Stäng") } }
|
||||||
)
|
)
|
||||||
@@ -2275,9 +2264,15 @@ private fun WikiArticleDialog(
|
|||||||
distanceText = wikiDistanceText, // Oför: redan beräknad
|
distanceText = wikiDistanceText, // Oför: redan beräknad
|
||||||
coordText = if (showCoords && lat != null && lon != null) formatCoords(lat, lon) else null,
|
coordText = if (showCoords && lat != null && lon != null) formatCoords(lat, lon) else null,
|
||||||
thumb = thumb?.asImageBitmap(),
|
thumb = thumb?.asImageBitmap(),
|
||||||
titleStyle = MaterialTheme.typography.titleLarge,
|
titleStyle = MaterialTheme.typography.titleLarge.copy(
|
||||||
bodyStyle = MaterialTheme.typography.bodyMedium,
|
color = MaterialTheme.colorScheme.onSurface // Ny: följer dag/natt
|
||||||
captionStyle = MaterialTheme.typography.bodySmall.copy(color = MaterialTheme.colorScheme.onSurfaceVariant),
|
),
|
||||||
|
bodyStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
color = MaterialTheme.colorScheme.onSurface // Ny
|
||||||
|
),
|
||||||
|
captionStyle = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant // Ny
|
||||||
|
),
|
||||||
actions = {
|
actions = {
|
||||||
Button(onClick = {
|
Button(onClick = {
|
||||||
val url = "https://sv.m.wikipedia.org/?curid=$pageId"
|
val url = "https://sv.m.wikipedia.org/?curid=$pageId"
|
||||||
@@ -2373,9 +2368,15 @@ private fun FornsokDialog(
|
|||||||
descText = desc,
|
descText = desc,
|
||||||
distanceText = fornDistanceText,
|
distanceText = fornDistanceText,
|
||||||
coordText = if (showCoords) formatCoords(platLat, platLon) else null,
|
coordText = if (showCoords) formatCoords(platLat, platLon) else null,
|
||||||
titleStyle = MaterialTheme.typography.titleLarge,
|
titleStyle = MaterialTheme.typography.titleLarge.copy(
|
||||||
bodyStyle = MaterialTheme.typography.bodyMedium,
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
captionStyle = MaterialTheme.typography.bodySmall.copy(color = MaterialTheme.colorScheme.onSurfaceVariant),
|
),
|
||||||
|
bodyStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
|
),
|
||||||
|
captionStyle = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
),
|
||||||
actions = {
|
actions = {
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
@@ -2528,9 +2529,15 @@ private fun DmDialog(
|
|||||||
distanceText = dmDistanceText,
|
distanceText = dmDistanceText,
|
||||||
coordText = if (showCoords) formatCoords(item.lat, item.lon) else null,
|
coordText = if (showCoords) formatCoords(item.lat, item.lon) else null,
|
||||||
image = thumb?.asImageBitmap(),
|
image = thumb?.asImageBitmap(),
|
||||||
titleStyle = MaterialTheme.typography.titleLarge,
|
titleStyle = MaterialTheme.typography.titleLarge.copy(
|
||||||
bodyStyle = MaterialTheme.typography.bodyMedium,
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
captionStyle = MaterialTheme.typography.bodySmall.copy(color = MaterialTheme.colorScheme.onSurfaceVariant),
|
),
|
||||||
|
bodyStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
color = MaterialTheme.colorScheme.onSurface
|
||||||
|
),
|
||||||
|
captionStyle = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
),
|
||||||
actions = {
|
actions = {
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
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.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Material-fri container för Närliggande-dialogens innehåll.
|
||||||
|
* Android skickar in maxhöjd och själva innehållet som en slot.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun NearbyDialogContent(
|
||||||
|
maxHeight: Dp,
|
||||||
|
content: @Composable () -> Unit
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.heightIn(min = 360.dp, max = maxHeight) // Samma höjdlogik som tidigare
|
||||||
|
) {
|
||||||
|
content()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user