Added dynamic top app bar titles and proper padding adjustments for all tabs
This commit is contained in:
@@ -13,12 +13,15 @@ import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.safeDrawing
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.statusBars
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
@@ -81,6 +84,7 @@ import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.Popup
|
||||
@@ -198,7 +202,8 @@ fun KlottrAppShell(
|
||||
var dmRadius by remember { mutableStateOf(SettingsStore.getDigitaltMuseumRadiusMeters()) }
|
||||
var showFornsok by remember { mutableStateOf(SettingsStore.getShowFornsok()) }
|
||||
var fornsokRadius by remember { mutableStateOf(SettingsStore.getFornsokRadiusMeters()) }
|
||||
|
||||
// Aktiv flik (lyfts upp så top-baren kan läsa den)
|
||||
var selectedTab by rememberSaveable { mutableStateOf("home") }
|
||||
|
||||
|
||||
// UI-state
|
||||
@@ -324,12 +329,28 @@ fun KlottrAppShell(
|
||||
Scaffold(
|
||||
topBar = {
|
||||
CenterAlignedTopAppBar(
|
||||
title = { Text("") }, // Standardtitel i appbaren (ingen special-Box, inga extra modifiers)
|
||||
title = {
|
||||
val titleText = when (selectedTab) {
|
||||
"home" -> "Hem"
|
||||
"layers" -> "Lager"
|
||||
"nearby" -> "Nära"
|
||||
"menu" -> "Meny"
|
||||
"account" -> "Konto"
|
||||
"settings"-> "Inställningar"
|
||||
"about" -> "Om"
|
||||
"mynotes" -> "Mitt klotter"
|
||||
else -> ""
|
||||
}
|
||||
Text(
|
||||
titleText,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
) { padding ->
|
||||
|
||||
var selectedTab by rememberSaveable { mutableStateOf("home") }
|
||||
var showChangeUsernameDialog by remember { mutableStateOf(false) }
|
||||
Scaffold(
|
||||
bottomBar = {
|
||||
@@ -376,8 +397,12 @@ fun KlottrAppShell(
|
||||
}
|
||||
// VIKTIGT: vi komponerar ALLA flikar alltid, och växlar bara synlighet.
|
||||
// => MapContent förstörs inte när du byter flik, så kartan slipper “blinka”.
|
||||
Box(Modifier.fillMaxSize().consumeWindowInsets(innerPadding)) {
|
||||
|
||||
Box(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.consumeWindowInsets(innerPadding)
|
||||
.padding(top = innerPadding.calculateTopPadding()) // Lägger till top-padding
|
||||
) {
|
||||
// === HEM ===
|
||||
Box(
|
||||
modifier = Modifier
|
||||
@@ -477,8 +502,6 @@ fun KlottrAppShell(
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Text("Lager", style = MaterialTheme.typography.headlineMedium)
|
||||
|
||||
// Klotter
|
||||
SwitchRow(
|
||||
label = "Visa klotter",
|
||||
@@ -593,7 +616,11 @@ fun KlottrAppShell(
|
||||
}
|
||||
|
||||
// Layout: dragbar delare mellan karta (top) och lista (bottom)
|
||||
Column(Modifier.fillMaxSize()) {
|
||||
Column(
|
||||
Modifier
|
||||
.fillMaxSize()
|
||||
.padding(bottom = innerPadding.calculateBottomPadding())
|
||||
) {
|
||||
// hasLocOrCache måste ligga kvar här om du använde det innan:
|
||||
val hasLocOrCache =
|
||||
(lastKnownLat != null && lastKnownLon != null) ||
|
||||
@@ -690,13 +717,13 @@ fun KlottrAppShell(
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding)
|
||||
.padding(
|
||||
start = 16.dp,
|
||||
end = 16.dp,
|
||||
top = innerPadding.calculateTopPadding() + 12.dp,
|
||||
bottom = innerPadding.calculateBottomPadding()
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
"Meny",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
modifier = Modifier.padding(16.dp)
|
||||
)
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(3),
|
||||
modifier = Modifier
|
||||
@@ -1458,8 +1485,6 @@ fun AccountScreen(
|
||||
.padding(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Text("Konto", style = MaterialTheme.typography.headlineMedium)
|
||||
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp)
|
||||
|
||||
Reference in New Issue
Block a user