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.LoginRequiredContent
|
||||
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.WikiDetailContent // Ny: delad Wiki-layout
|
||||
import app.klottr.ui.WriteDocContent // Använd delad, material-fri formulär-UI
|
||||
@@ -1294,34 +1294,23 @@ private fun NearbyDialog(
|
||||
title = { Text("Närliggande") },
|
||||
text = {
|
||||
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 maxDialogHeight = (cfg.screenHeightDp * 0.8f).dp
|
||||
|
||||
MapPanelShell(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 360.dp, max = maxDialogHeight), // Gör dialogytan stor nog och skrollbar
|
||||
title = null, // AlertDialog visar redan "Närliggande" som titel
|
||||
titleTextStyle = MaterialTheme.typography.titleLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
),
|
||||
mainContent = {
|
||||
NearbyContent(
|
||||
loading = loading,
|
||||
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
|
||||
)
|
||||
NearbyDialogContent(maxHeight = maxDialogHeight) {
|
||||
NearbyContent(
|
||||
loading = loading,
|
||||
error = error,
|
||||
hasLocation = hasLocation,
|
||||
entries = if (hasLocation) entries else emptyList(),
|
||||
dm = dm,
|
||||
forn = forn,
|
||||
onOpenAction = onOpenAction,
|
||||
rowTextStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
confirmButton = { Button(onClick = onClose) { Text("Stäng") } }
|
||||
)
|
||||
@@ -2275,9 +2264,15 @@ private fun WikiArticleDialog(
|
||||
distanceText = wikiDistanceText, // Oför: redan beräknad
|
||||
coordText = if (showCoords && lat != null && lon != null) formatCoords(lat, lon) else null,
|
||||
thumb = thumb?.asImageBitmap(),
|
||||
titleStyle = MaterialTheme.typography.titleLarge,
|
||||
bodyStyle = MaterialTheme.typography.bodyMedium,
|
||||
captionStyle = MaterialTheme.typography.bodySmall.copy(color = MaterialTheme.colorScheme.onSurfaceVariant),
|
||||
titleStyle = MaterialTheme.typography.titleLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface // Ny: följer dag/natt
|
||||
),
|
||||
bodyStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface // Ny
|
||||
),
|
||||
captionStyle = MaterialTheme.typography.bodySmall.copy(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant // Ny
|
||||
),
|
||||
actions = {
|
||||
Button(onClick = {
|
||||
val url = "https://sv.m.wikipedia.org/?curid=$pageId"
|
||||
@@ -2373,9 +2368,15 @@ private fun FornsokDialog(
|
||||
descText = desc,
|
||||
distanceText = fornDistanceText,
|
||||
coordText = if (showCoords) formatCoords(platLat, platLon) else null,
|
||||
titleStyle = MaterialTheme.typography.titleLarge,
|
||||
bodyStyle = MaterialTheme.typography.bodyMedium,
|
||||
captionStyle = MaterialTheme.typography.bodySmall.copy(color = MaterialTheme.colorScheme.onSurfaceVariant),
|
||||
titleStyle = MaterialTheme.typography.titleLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
),
|
||||
bodyStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
),
|
||||
captionStyle = MaterialTheme.typography.bodySmall.copy(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
),
|
||||
actions = {
|
||||
Button(
|
||||
onClick = {
|
||||
@@ -2528,9 +2529,15 @@ private fun DmDialog(
|
||||
distanceText = dmDistanceText,
|
||||
coordText = if (showCoords) formatCoords(item.lat, item.lon) else null,
|
||||
image = thumb?.asImageBitmap(),
|
||||
titleStyle = MaterialTheme.typography.titleLarge,
|
||||
bodyStyle = MaterialTheme.typography.bodyMedium,
|
||||
captionStyle = MaterialTheme.typography.bodySmall.copy(color = MaterialTheme.colorScheme.onSurfaceVariant),
|
||||
titleStyle = MaterialTheme.typography.titleLarge.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
),
|
||||
bodyStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
),
|
||||
captionStyle = MaterialTheme.typography.bodySmall.copy(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
),
|
||||
actions = {
|
||||
Button(
|
||||
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