Removed old-UI and cleaned up.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -24,107 +24,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import app.klottr.ui.SettingsContent
|
import app.klottr.ui.SettingsContent
|
||||||
|
|
||||||
/* ---------- Inställningar (scroll + “Stäng” synlig) ---------- */
|
/* ---------- Inställningar ---------- */
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Composable
|
|
||||||
fun SettingsDialog(
|
|
||||||
onlyNew: Boolean,
|
|
||||||
satellite: Boolean,
|
|
||||||
night: Boolean,
|
|
||||||
showCoords: Boolean,
|
|
||||||
onShowCoordsChanged: (Boolean) -> Unit,
|
|
||||||
useNewUi: Boolean,
|
|
||||||
onUseNewUiChanged: (Boolean) -> Unit,
|
|
||||||
showKlotter: Boolean,
|
|
||||||
showWiki: Boolean,
|
|
||||||
wikiRadius: Int,
|
|
||||||
showDm: Boolean,
|
|
||||||
dmRadius: Int,
|
|
||||||
showFornsok: Boolean,
|
|
||||||
fornsokRadius: Int,
|
|
||||||
onOnlyNewChanged: (Boolean) -> Unit,
|
|
||||||
onSatelliteChanged: (Boolean) -> Unit,
|
|
||||||
onNightChanged: (Boolean) -> Unit,
|
|
||||||
onShowKlotterChanged: (Boolean) -> Unit,
|
|
||||||
onShowWikiChanged: (Boolean) -> Unit,
|
|
||||||
onWikiRadiusChanged: (Int) -> Unit,
|
|
||||||
onShowDmChanged: (Boolean) -> Unit,
|
|
||||||
onDmRadiusChanged: (Int) -> Unit,
|
|
||||||
onShowFornsokChanged: (Boolean) -> Unit,
|
|
||||||
onFornsokRadiusChanged: (Int) -> Unit,
|
|
||||||
onClearFinds: () -> Unit,
|
|
||||||
onClose: () -> Unit
|
|
||||||
) {
|
|
||||||
val maxDialogHeight = (LocalWindowInfo.current.containerSize.height.dp * 0.75f)
|
|
||||||
|
|
||||||
val wikiOptions = listOf(20, 50, 100, 200, 500, 1000, 2000, 5000)
|
|
||||||
val fornsokOptions = listOf(50, 100, 200, 500, 1000, 2000, 5000)
|
|
||||||
val dmOptions = listOf(50, 100, 200, 500, 1000, 2000)
|
|
||||||
|
|
||||||
var askClear by remember { mutableStateOf(false) }
|
|
||||||
|
|
||||||
AlertDialog(
|
|
||||||
onDismissRequest = onClose,
|
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false),
|
|
||||||
title = { Text("Inställningar") },
|
|
||||||
text = {
|
|
||||||
Box(
|
|
||||||
Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(maxDialogHeight)
|
|
||||||
) {
|
|
||||||
SettingsContent(
|
|
||||||
versionLine = "FIXME_VERSIONLINE", // TODO: OH: Do this platform independenlty
|
|
||||||
buildTimeLine = "FIXME_BUILDTIME",
|
|
||||||
onlyNew = onlyNew,
|
|
||||||
onOnlyNewChanged = onOnlyNewChanged,
|
|
||||||
showCoords = showCoords,
|
|
||||||
onShowCoordsChanged = onShowCoordsChanged,
|
|
||||||
satellite = satellite,
|
|
||||||
onSatelliteChanged = onSatelliteChanged,
|
|
||||||
night = night,
|
|
||||||
onNightChanged = onNightChanged,
|
|
||||||
useNewUi = useNewUi,
|
|
||||||
onUseNewUiChanged = onUseNewUiChanged,
|
|
||||||
showKlotter = showKlotter,
|
|
||||||
onShowKlotterChanged = onShowKlotterChanged,
|
|
||||||
showWiki = showWiki,
|
|
||||||
wikiRadius = wikiRadius,
|
|
||||||
wikiOptions = listOf(20, 50, 100, 200, 500, 1000, 2000, 5000),
|
|
||||||
onShowWikiChanged = onShowWikiChanged,
|
|
||||||
onWikiRadiusChanged = onWikiRadiusChanged,
|
|
||||||
showDm = showDm,
|
|
||||||
dmRadius = dmRadius,
|
|
||||||
dmOptions = listOf(50, 100, 200, 500, 1000, 2000),
|
|
||||||
onShowDmChanged = onShowDmChanged,
|
|
||||||
onDmRadiusChanged = onDmRadiusChanged,
|
|
||||||
showFornsok = showFornsok,
|
|
||||||
fornsokRadius = fornsokRadius,
|
|
||||||
fornsokOptions = listOf(50, 100, 200, 500, 1000, 2000, 5000),
|
|
||||||
onShowFornsokChanged = onShowFornsokChanged,
|
|
||||||
onFornsokRadiusChanged = onFornsokRadiusChanged,
|
|
||||||
onRequestClear = { askClear = true }, // trigga bekräftelsedialog
|
|
||||||
rowTextStyle = MaterialTheme.typography.bodyMedium.copy(
|
|
||||||
color = MaterialTheme.colorScheme.onSurface
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Behåll den inre bekräftelsedialogen för rensning
|
|
||||||
if (askClear) {
|
|
||||||
AlertDialog(
|
|
||||||
onDismissRequest = { askClear = false },
|
|
||||||
title = { Text("Radera historik?") },
|
|
||||||
text = { Text("Vill du verkligen radera alla fynd? Detta går inte att ångra.") },
|
|
||||||
confirmButton = { Button(onClick = { askClear = false; onClearFinds() }) { Text("Ja, radera") } },
|
|
||||||
dismissButton = { Button(onClick = { askClear = false }) { Text("Avbryt") } }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
confirmButton = { Button(onClick = onClose) { Text("Stäng") } }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsScreen(
|
fun SettingsScreen(
|
||||||
|
|||||||
@@ -60,65 +60,6 @@ import kotlinx.coroutines.delay
|
|||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
/* ---------- Nearby (shared) ---------- */
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun NearbyDialog(
|
|
||||||
loading: Boolean,
|
|
||||||
error: String?,
|
|
||||||
lat: Double?,
|
|
||||||
lon: Double?,
|
|
||||||
entries: List<NearbyEntryShared>,
|
|
||||||
dm: List<DigitaltMuseumItem>,
|
|
||||||
forn: List<FornsokItem>,
|
|
||||||
onOpenAction: (FoundOpenAction) -> Unit,
|
|
||||||
onClose: () -> Unit,
|
|
||||||
/** Optional max content height; if null, content becomes scrollable. */
|
|
||||||
maxHeight: Dp? = null
|
|
||||||
) {
|
|
||||||
AlertDialog(
|
|
||||||
onDismissRequest = onClose,
|
|
||||||
title = { Text("Närliggande") },
|
|
||||||
text = {
|
|
||||||
val hasLocation = (lat != null && lon != null)
|
|
||||||
|
|
||||||
// Cap to caller-provided height or ~75% of the real screen height (platform-agnostic).
|
|
||||||
val percentageCap = (platformScreenHeightDp() * 0.75f)
|
|
||||||
val cap = (maxHeight ?: percentageCap).coerceAtLeast(320.dp)
|
|
||||||
|
|
||||||
val container = @Composable { inner: @Composable () -> Unit ->
|
|
||||||
// Bound the height BEFORE measuring child content; do NOT add verticalScroll here.
|
|
||||||
Box(
|
|
||||||
Modifier
|
|
||||||
.widthIn(min = 280.dp)
|
|
||||||
.requiredHeightIn(max = cap)
|
|
||||||
) {
|
|
||||||
// Let inner content (NearbyList) own scrolling; fill available space.
|
|
||||||
Column(Modifier.fillMaxSize()) { inner() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NearbyDialogContent(maxHeight = cap) {
|
|
||||||
container {
|
|
||||||
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") } }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------- Username (shared) ---------- */
|
/* ---------- Username (shared) ---------- */
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -283,100 +224,6 @@ fun UsernameDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- About (shared, platform-fed) ---------- */
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun AboutDialog(onDismiss: () -> Unit) {
|
|
||||||
val info = remember { appAboutInfo() } // platform provides
|
|
||||||
AlertDialog(
|
|
||||||
onDismissRequest = onDismiss,
|
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false),
|
|
||||||
confirmButton = { TextButton(onClick = onDismiss) { Text("Stäng") } },
|
|
||||||
text = {
|
|
||||||
Box(
|
|
||||||
Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.widthIn(max = 520.dp)
|
|
||||||
) {
|
|
||||||
KlottrAboutContent(
|
|
||||||
header = {
|
|
||||||
KlottrLogo(modifier = Modifier.height(48.dp))
|
|
||||||
},
|
|
||||||
lines = listOf(
|
|
||||||
"Version ${info.versionName} (${info.buildType}) • build ${info.buildNumber}",
|
|
||||||
"Byggd ${info.buildTimeUtc}",
|
|
||||||
"Utvecklad av ${info.devBy}.",
|
|
||||||
"IOS-ansvarig: ${info.iosLead}.",
|
|
||||||
"Mejlkontakt: ${info.contactEmail}"
|
|
||||||
),
|
|
||||||
lineStyle = MaterialTheme.typography.bodyMedium.copy(
|
|
||||||
color = MaterialTheme.colorScheme.onSurface
|
|
||||||
),
|
|
||||||
spacingDp = 12
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------- Image viewer (shared, byte[] + Coil KMP, pinch/zoom) ---------- */
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun ImageViewerDialog(
|
|
||||||
bytes: ByteArray,
|
|
||||||
mimeType: String? = null,
|
|
||||||
onClose: () -> Unit
|
|
||||||
) {
|
|
||||||
Dialog(
|
|
||||||
onDismissRequest = onClose,
|
|
||||||
properties = DialogProperties(usePlatformDefaultWidth = false)
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(Color.Black)
|
|
||||||
) {
|
|
||||||
var scale by remember { mutableStateOf(1f) }
|
|
||||||
var offset by remember { mutableStateOf(Offset.Zero) }
|
|
||||||
|
|
||||||
AsyncImage(
|
|
||||||
model = ImageRequest.Builder(LocalPlatformContext.current)
|
|
||||||
.data(bytes)
|
|
||||||
.build(),
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.clipToBounds()
|
|
||||||
.pointerInput(Unit) {
|
|
||||||
detectTransformGestures { _, pan, zoom, _ ->
|
|
||||||
scale = (scale * zoom).coerceIn(0.5f, 6f)
|
|
||||||
offset += pan
|
|
||||||
val clamp = 2000f
|
|
||||||
offset = Offset(
|
|
||||||
x = offset.x.coerceIn(-clamp, clamp),
|
|
||||||
y = offset.y.coerceIn(-clamp, clamp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.graphicsLayer(
|
|
||||||
scaleX = scale,
|
|
||||||
scaleY = scale,
|
|
||||||
translationX = offset.x,
|
|
||||||
translationY = offset.y
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.align(Alignment.TopEnd)
|
|
||||||
.padding(12.dp)
|
|
||||||
) {
|
|
||||||
Button(onClick = onClose) { Text("Stäng") }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AboutScreen(modifier: Modifier = Modifier) {
|
fun AboutScreen(modifier: Modifier = Modifier) {
|
||||||
val info = remember { appAboutInfo() } // platform provides
|
val info = remember { appAboutInfo() } // platform provides
|
||||||
|
|||||||
Reference in New Issue
Block a user