Skip to content

Commit

Permalink
chore: Center NavigationRail
Browse files Browse the repository at this point in the history
  • Loading branch information
wba2hi committed Feb 9, 2024
1 parent a3be81b commit 6caf440
Showing 1 changed file with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.eclipse.kuksa.companion.feature.home.view.navigation

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationRail
Expand All @@ -30,7 +30,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -48,28 +47,28 @@ fun VerticalNavigationView(

val pages = NavigationPage.entries.toTypedArray()

Box(contentAlignment = Alignment.Center, modifier = modifier) {
NavigationRail {
pages.forEachIndexed { index, page ->
NavigationRailItem(
label = { Text(page.title) },
icon = {
Icon(
painterResource(id = page.iconRes),
contentDescription = page.title,
modifier = Modifier.size(30.dp),
)
},
selected = selectedItemIndex == index,
onClick = {
selectedItemIndex = index
viewModel.selectedNavigationIndex = index
viewModel.selectedNavigationPage = page
onPageSelected(page)
},
)
}
NavigationRail(modifier) {
Spacer(Modifier.weight(1f))
pages.forEachIndexed { index, page ->
NavigationRailItem(
label = { Text(page.title) },
icon = {
Icon(
painterResource(id = page.iconRes),
contentDescription = page.title,
modifier = Modifier.size(30.dp),
)
},
selected = selectedItemIndex == index,
onClick = {
selectedItemIndex = index
viewModel.selectedNavigationIndex = index
viewModel.selectedNavigationPage = page
onPageSelected(page)
},
)
}
Spacer(Modifier.weight(1f))
}
}

Expand Down

0 comments on commit 6caf440

Please sign in to comment.