Skip to content

Commit

Permalink
[#254] Center bottom navigation vertically in the demo screen
Browse files Browse the repository at this point in the history
  • Loading branch information
paulinea committed Sep 8, 2022
1 parent 1960ee4 commit 960d345
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
package com.orange.ods.demo.ui.components.bottomnavigation

import androidx.annotation.DrawableRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
Expand Down Expand Up @@ -49,10 +52,14 @@ fun ComponentBottomNavigation() {
bottomSheetContent = {
BottomNavigationCustomizationContent(selectedNavigationItemCount = selectedNavigationItemCount)
}) {
ComponentBottomNavigationBottomBar(
modifier = Modifier.padding(top = dimensionResource(id = R.dimen.spacing_l)),
selectedNavigationItemCount = selectedNavigationItemCount
)
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center
) {
ComponentBottomNavigationBottomBar(
selectedNavigationItemCount = selectedNavigationItemCount
)
}
}
}

Expand All @@ -70,7 +77,7 @@ private fun BottomNavigationCustomizationContent(selectedNavigationItemCount: Mu
}

@Composable
private fun ComponentBottomNavigationBottomBar(modifier: Modifier, selectedNavigationItemCount: MutableState<Int>) {
private fun ComponentBottomNavigationBottomBar(selectedNavigationItemCount: MutableState<Int>) {
val context = LocalContext.current
val navigationItems = listOf(
NavigationItem("Favorites", R.drawable.ic_heart),
Expand All @@ -82,7 +89,7 @@ private fun ComponentBottomNavigationBottomBar(modifier: Modifier, selectedNavig

val selectedNavigationItem = remember { mutableStateOf(navigationItems[0]) }

OdsBottomNavigation(modifier = modifier) {
OdsBottomNavigation {
navigationItems.take(selectedNavigationItemCount.value)
.forEach { navigationItem ->
OdsBottomNavigationItem(
Expand Down

0 comments on commit 960d345

Please sign in to comment.