feat: enhance CompactNavigation with CMS submenu and toggle functionality
All checks were successful
Code Analysis and Production Deploy / analyze (push) Successful in 7m39s
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 1m57s

This commit is contained in:
Torsten Schulz (local)
2026-05-30 23:51:41 +02:00
parent 6507afea5f
commit 31d20f1bff

View File

@@ -72,6 +72,11 @@ private fun CompactNavigation(
onNavigate: (String) -> Unit, onNavigate: (String) -> Unit,
navigationState: NavigationUiState = NavigationUiState(), navigationState: NavigationUiState = NavigationUiState(),
) { ) {
val section = menuSection(selectedRoute)
val subItems = submenu(section, navigationState)
var cmsExpanded = androidx.compose.runtime.remember { androidx.compose.runtime.mutableStateOf(false) }
val navigateAndClose: (String) -> Unit = { route -> cmsExpanded.value = false; onNavigate(route) }
BrandRow(onLogin = { onNavigate(Destinations.Login.route) }) BrandRow(onLogin = { onNavigate(Destinations.Login.route) })
Row( Row(
modifier = Modifier.horizontalScroll(rememberScrollState()), modifier = Modifier.horizontalScroll(rememberScrollState()),
@@ -83,6 +88,7 @@ private fun CompactNavigation(
CompactLink("Training", Destinations.Training.route, selectedRoute, onNavigate) CompactLink("Training", Destinations.Training.route, selectedRoute, onNavigate)
CompactLink("Termine", Destinations.Termine.route, selectedRoute, onNavigate) CompactLink("Termine", Destinations.Termine.route, selectedRoute, onNavigate)
CompactLink("Spielplan", Destinations.Spielplan.route, selectedRoute, onNavigate) CompactLink("Spielplan", Destinations.Spielplan.route, selectedRoute, onNavigate)
CompactLink("Newsletter", Destinations.NewsletterSubscribe.route, selectedRoute, onNavigate)
if (navigationState.showGallery) { if (navigationState.showGallery) {
CompactLink("Galerie", Destinations.Gallery.route, selectedRoute, onNavigate) CompactLink("Galerie", Destinations.Gallery.route, selectedRoute, onNavigate)
} }
@@ -94,6 +100,46 @@ private fun CompactNavigation(
CompactLink("CMS", Destinations.Cms.route, selectedRoute, onNavigate) CompactLink("CMS", Destinations.Cms.route, selectedRoute, onNavigate)
} }
} }
val cmsIndex = subItems.indexOfFirst { it.label == "CMS" }
val cmsChildren = if (cmsIndex >= 0) subItems.subList(cmsIndex + 1, subItems.size) else emptyList<MenuTarget>()
if (cmsChildren.any { it.route == selectedRoute }) {
cmsExpanded.value = true
}
Row(
modifier = Modifier
.fillMaxWidth()
.horizontalScroll(rememberScrollState())
.padding(top = 3.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
subItems.forEachIndexed { idx, item ->
if (idx == cmsIndex) {
SubLink(item.label, item.route == selectedRoute) {
cmsExpanded.value = !cmsExpanded.value
}
} else if (idx > cmsIndex && cmsIndex >= 0) {
// CMS children are rendered below when expanded.
} else {
SubLink(item.label, item.route == selectedRoute) { navigateAndClose(item.route) }
}
}
}
if (cmsExpanded.value && cmsChildren.isNotEmpty()) {
Row(
modifier = Modifier
.fillMaxWidth()
.horizontalScroll(rememberScrollState())
.padding(top = 6.dp, bottom = 3.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
cmsChildren.forEach { child ->
SubLink(child.label, child.route == selectedRoute) { onNavigate(child.route) }
}
}
}
} }
@Composable @Composable