app(ui): place “Senaste” as content heading; render SharedInfoCard with themed TextStyle; remove debug UI; restore top app bar; speed up theme switch (LaunchedEffect key); use shared NearbyEntryRow in NearbyDialog; tidy imports
This commit is contained in:
@@ -18,19 +18,28 @@ import androidx.activity.ComponentActivity
|
|||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
|
import androidx.activity.result.PickVisualMediaRequest
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia
|
import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia
|
||||||
import androidx.activity.result.PickVisualMediaRequest
|
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.gestures.rememberTransformableState
|
import androidx.compose.foundation.gestures.rememberTransformableState
|
||||||
import androidx.compose.foundation.gestures.transformable
|
import androidx.compose.foundation.gestures.transformable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
|
import androidx.compose.foundation.layout.imePadding
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.widthIn
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
@@ -39,7 +48,6 @@ import androidx.compose.foundation.verticalScroll
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Info
|
import androidx.compose.material.icons.filled.Info
|
||||||
import androidx.compose.material.icons.filled.Settings
|
import androidx.compose.material.icons.filled.Settings
|
||||||
import androidx.compose.material3.*
|
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
@@ -51,6 +59,7 @@ import androidx.compose.material3.DropdownMenuItem
|
|||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.ExposedDropdownMenuBox
|
import androidx.compose.material3.ExposedDropdownMenuBox
|
||||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||||
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.ListItem
|
import androidx.compose.material3.ListItem
|
||||||
@@ -61,16 +70,25 @@ import androidx.compose.material3.Scaffold
|
|||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.collectAsState
|
||||||
|
import androidx.compose.runtime.derivedStateOf
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.geometry.Offset
|
import androidx.compose.ui.geometry.Offset
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
@@ -92,8 +110,6 @@ import app.klottr.data.NoteRepository
|
|||||||
import app.klottr.net.Api
|
import app.klottr.net.Api
|
||||||
import app.klottr.net.DigitaltMuseum
|
import app.klottr.net.DigitaltMuseum
|
||||||
import app.klottr.net.DigitaltMuseumItem
|
import app.klottr.net.DigitaltMuseumItem
|
||||||
import app.klottr.net.deleteNote
|
|
||||||
import app.klottr.net.fetchImageStreamPost
|
|
||||||
import app.klottr.net.Fornsok
|
import app.klottr.net.Fornsok
|
||||||
import app.klottr.net.FornsokItem
|
import app.klottr.net.FornsokItem
|
||||||
import app.klottr.net.Geocache
|
import app.klottr.net.Geocache
|
||||||
@@ -101,33 +117,35 @@ import app.klottr.net.NoteDTO
|
|||||||
import app.klottr.net.Wikipedia
|
import app.klottr.net.Wikipedia
|
||||||
import app.klottr.net.WikipediaPage
|
import app.klottr.net.WikipediaPage
|
||||||
import app.klottr.net.createNoteDoc
|
import app.klottr.net.createNoteDoc
|
||||||
|
import app.klottr.net.deleteNote
|
||||||
|
import app.klottr.net.fetchImageStreamPost
|
||||||
import app.klottr.net.fetchNoteDetail
|
import app.klottr.net.fetchNoteDetail
|
||||||
import app.klottr.net.uploadImageFromUri
|
import app.klottr.net.uploadImageFromUri
|
||||||
import app.klottr.shared.SharedPing
|
import app.klottr.shared.SharedPing
|
||||||
import app.klottr.ui.SharedInfoCard // Delad @Composable från :shared/commonMain (Compose Multiplatform-pilot)
|
|
||||||
import app.klottr.theme.KlottrTheme
|
import app.klottr.theme.KlottrTheme
|
||||||
|
import app.klottr.ui.NearbyEntryRow
|
||||||
|
import app.klottr.ui.SharedInfoCard
|
||||||
import app.klottr.util.Auth
|
import app.klottr.util.Auth
|
||||||
import app.klottr.util.Config
|
import app.klottr.util.Config
|
||||||
import app.klottr.util.FoundStore
|
import app.klottr.util.FoundStore
|
||||||
import app.klottr.util.FoundStore.LAYER_WIKI
|
|
||||||
import app.klottr.util.FoundStore.LAYER_DM
|
import app.klottr.util.FoundStore.LAYER_DM
|
||||||
import app.klottr.util.FoundStore.LAYER_KLOTTER
|
import app.klottr.util.FoundStore.LAYER_KLOTTER
|
||||||
|
import app.klottr.util.FoundStore.LAYER_WIKI
|
||||||
import app.klottr.util.ImageBitmapCache
|
import app.klottr.util.ImageBitmapCache
|
||||||
import app.klottr.util.LastLocationStore
|
import app.klottr.util.LastLocationStore
|
||||||
import app.klottr.util.NoteDetailCache
|
import app.klottr.util.NoteDetailCache
|
||||||
import app.klottr.util.OutboxStore
|
import app.klottr.util.OutboxStore
|
||||||
import app.klottr.util.SettingsStore
|
import app.klottr.util.SettingsStore
|
||||||
|
import app.klottr.util.formatCoords
|
||||||
import app.klottr.util.formatDistance
|
import app.klottr.util.formatDistance
|
||||||
import app.klottr.util.formatRelativeOrTime
|
import app.klottr.util.formatRelativeOrTime
|
||||||
import app.klottr.util.formatCoords
|
|
||||||
import app.klottr.work.OutboxWorker
|
import app.klottr.work.OutboxWorker
|
||||||
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
||||||
import com.google.android.gms.common.api.ApiException
|
import com.google.android.gms.common.api.ApiException
|
||||||
import com.google.android.gms.location.LocationServices as GmsLocationServices
|
|
||||||
import com.google.android.gms.location.Priority
|
import com.google.android.gms.location.Priority
|
||||||
|
import com.google.android.gms.maps.CameraUpdateFactory
|
||||||
import com.google.android.gms.maps.model.CameraPosition
|
import com.google.android.gms.maps.model.CameraPosition
|
||||||
import com.google.android.gms.maps.model.LatLng
|
import com.google.android.gms.maps.model.LatLng
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory
|
|
||||||
import com.google.maps.android.compose.GoogleMap
|
import com.google.maps.android.compose.GoogleMap
|
||||||
import com.google.maps.android.compose.MapProperties
|
import com.google.maps.android.compose.MapProperties
|
||||||
import com.google.maps.android.compose.MapType
|
import com.google.maps.android.compose.MapType
|
||||||
@@ -148,6 +166,7 @@ import java.net.URL
|
|||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
import com.google.android.gms.location.LocationServices as GmsLocationServices
|
||||||
|
|
||||||
// Extra lagersträng (vi rör inte FoundStore:s egna konstanter)
|
// Extra lagersträng (vi rör inte FoundStore:s egna konstanter)
|
||||||
private const val LAYER_FORNSOK = "FORNSOK"
|
private const val LAYER_FORNSOK = "FORNSOK"
|
||||||
@@ -581,10 +600,10 @@ private fun KlottrApp(
|
|||||||
var showAbout by remember { mutableStateOf(false) }
|
var showAbout by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
CenterAlignedTopAppBar(
|
CenterAlignedTopAppBar(
|
||||||
title = { Text("") },
|
title = { Text("") }, // [ÅTERSTÄLLD] Standardtitel i appbaren (ingen special-Box, inga extra modifiers)
|
||||||
actions = {
|
actions = { // [OFÖR] Dina befintliga actions (Info/Inställningar)
|
||||||
IconButton(onClick = { showAbout = true }) {
|
IconButton(onClick = { showAbout = true }) {
|
||||||
Icon(imageVector = Icons.Filled.Info, contentDescription = "Om")
|
Icon(imageVector = Icons.Filled.Info, contentDescription = "Om")
|
||||||
}
|
}
|
||||||
@@ -594,6 +613,7 @@ private fun KlottrApp(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
) { padding ->
|
) { padding ->
|
||||||
Column(
|
Column(
|
||||||
Modifier
|
Modifier
|
||||||
@@ -693,14 +713,39 @@ private fun KlottrApp(
|
|||||||
Button(onClick = { showMap = true }) { Text("Karta") }
|
Button(onClick = { showMap = true }) { Text("Karta") }
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedInfoCard() // Visar vår delade CMP-pilot; säkert läge efter knappraden i huvudkolumnen
|
HorizontalDivider() // [OFÖR] Avdelare under knappraden
|
||||||
|
|
||||||
|
// [NY] Sätt textstil för allt inom blocket så även BasicText (i SharedInfoCard) blir läsbar i mörkt läge
|
||||||
|
Column(Modifier.padding(horizontal = 4.dp, vertical = 8.dp)) { // [ÄNDRAD] Tar bort ProvideTextStyle-wrappern (onödig nu)
|
||||||
|
Text(
|
||||||
|
"Senaste",
|
||||||
|
style = MaterialTheme.typography.titleLarge,
|
||||||
|
color = MaterialTheme.colorScheme.onSurface // [NY] Sätt färg direkt så rubriken är tydlig i mörkt läge
|
||||||
|
)
|
||||||
|
Spacer(Modifier.height(6.dp))
|
||||||
|
|
||||||
|
Surface(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
tonalElevation = 2.dp,
|
||||||
|
shadowElevation = 0.dp
|
||||||
|
) {
|
||||||
|
Column(Modifier.padding(12.dp)) {
|
||||||
|
SharedInfoCard(
|
||||||
|
textStyle = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
color = MaterialTheme.colorScheme.onSurface // [OFÖR] Delade kortet får rätt färg i dag/natt
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hittat
|
// Hittat
|
||||||
val foundList =
|
val foundList =
|
||||||
if (forceEmptyFound) emptyList()
|
if (forceEmptyFound) emptyList()
|
||||||
else FoundStore.getAll(context)
|
else FoundStore.getAll(context)
|
||||||
|
val foundKey = foundList.joinToString("|") { "${it.layer}:${it.id}" } // Stabil nyckel som inte ändras vid tema-byte
|
||||||
// Buffra detalj + bild för kända klotter inom radien → snabbare öppning
|
// Buffra detalj + bild för kända klotter inom radien → snabbare öppning
|
||||||
LaunchedEffect(foundList) {
|
LaunchedEffect(foundKey) { // Kör bara när innehållet faktiskt ändras, inte vid tema-byte
|
||||||
val my = LastLocationStore.lastKnownLocation
|
val my = LastLocationStore.lastKnownLocation
|
||||||
val myLat = my?.latitude
|
val myLat = my?.latitude
|
||||||
val myLon = my?.longitude
|
val myLon = my?.longitude
|
||||||
@@ -1333,7 +1378,8 @@ private fun NearbyDialog(
|
|||||||
onMarkedFound()
|
onMarkedFound()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val subtitle = buildString {
|
// ✅ Bygg samma undertext som tidigare (lager + avstånd)
|
||||||
|
val subtitle = buildString {
|
||||||
append(
|
append(
|
||||||
when (e.layer) {
|
when (e.layer) {
|
||||||
FoundStore.LAYER_WIKI -> "Wikipedia"
|
FoundStore.LAYER_WIKI -> "Wikipedia"
|
||||||
@@ -1345,12 +1391,16 @@ private fun NearbyDialog(
|
|||||||
)
|
)
|
||||||
append(" • ${e.distanceM} m")
|
append(" • ${e.distanceM} m")
|
||||||
}
|
}
|
||||||
ListItem(
|
|
||||||
headlineContent = { Text(e.label) },
|
// ✅ Använd delad rad från :shared istället för Android-specifik ListItem
|
||||||
supportingContent = { Text(subtitle) },
|
NearbyEntryRow(
|
||||||
modifier = if (e.click != null) Modifier.clickable { e.click.invoke() } else Modifier
|
label = e.label, // ✅ Titelrad från vår entries-modell
|
||||||
|
subtitle = subtitle, // ✅ Undertexten vi just byggde
|
||||||
|
clickable = (e.click != null), // ✅ Klickbar bara när vi har callback
|
||||||
|
onClick = e.click // ✅ Vid klick → kör medskickad callback
|
||||||
)
|
)
|
||||||
Divider()
|
HorizontalDivider()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.12.2"
|
agp = "8.12.3"
|
||||||
kotlin = "2.2.10"
|
kotlin = "2.2.10"
|
||||||
coreKtx = "1.16.0"
|
coreKtx = "1.16.0"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user