|
|
@ -31,7 +31,6 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.Scaffold
|
|
|
|
import androidx.compose.material3.Scaffold
|
|
|
|
import androidx.compose.material3.Surface
|
|
|
|
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowSizeClass
|
|
|
|
import androidx.compose.material3.windowsizeclass.WindowSizeClass
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
@ -73,6 +72,7 @@ fun NiaApp(
|
|
|
|
},
|
|
|
|
},
|
|
|
|
containerColor = Color.Transparent,
|
|
|
|
containerColor = Color.Transparent,
|
|
|
|
contentColor = MaterialTheme.colorScheme.onBackground,
|
|
|
|
contentColor = MaterialTheme.colorScheme.onBackground,
|
|
|
|
|
|
|
|
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
|
|
|
bottomBar = {
|
|
|
|
bottomBar = {
|
|
|
|
if (appState.shouldShowBottomBar) {
|
|
|
|
if (appState.shouldShowBottomBar) {
|
|
|
|
NiaBottomBar(
|
|
|
|
NiaBottomBar(
|
|
|
@ -158,42 +158,32 @@ private fun NiaBottomBar(
|
|
|
|
onNavigateToDestination: (TopLevelDestination) -> Unit,
|
|
|
|
onNavigateToDestination: (TopLevelDestination) -> Unit,
|
|
|
|
currentDestination: NavDestination?
|
|
|
|
currentDestination: NavDestination?
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
// Wrap the navigation bar in a surface so the color behind the system
|
|
|
|
NiaNavigationBar {
|
|
|
|
// navigation is equal to the container color of the navigation bar.
|
|
|
|
destinations.forEach { destination ->
|
|
|
|
Surface(color = MaterialTheme.colorScheme.surface) {
|
|
|
|
val selected =
|
|
|
|
NiaNavigationBar(
|
|
|
|
currentDestination?.hierarchy?.any { it.route == destination.route } == true
|
|
|
|
modifier = Modifier.windowInsetsPadding(
|
|
|
|
NiaNavigationBarItem(
|
|
|
|
WindowInsets.safeDrawing.only(
|
|
|
|
selected = selected,
|
|
|
|
WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom
|
|
|
|
onClick = { onNavigateToDestination(destination) },
|
|
|
|
)
|
|
|
|
icon = {
|
|
|
|
|
|
|
|
val icon = if (selected) {
|
|
|
|
|
|
|
|
destination.selectedIcon
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
destination.unselectedIcon
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
when (icon) {
|
|
|
|
|
|
|
|
is ImageVectorIcon -> Icon(
|
|
|
|
|
|
|
|
imageVector = icon.imageVector,
|
|
|
|
|
|
|
|
contentDescription = null
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
is DrawableResourceIcon -> Icon(
|
|
|
|
|
|
|
|
painter = painterResource(id = icon.id),
|
|
|
|
|
|
|
|
contentDescription = null
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
label = { Text(stringResource(destination.iconTextId)) }
|
|
|
|
)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
|
|
|
|
destinations.forEach { destination ->
|
|
|
|
|
|
|
|
val selected =
|
|
|
|
|
|
|
|
currentDestination?.hierarchy?.any { it.route == destination.route } == true
|
|
|
|
|
|
|
|
NiaNavigationBarItem(
|
|
|
|
|
|
|
|
selected = selected,
|
|
|
|
|
|
|
|
onClick = { onNavigateToDestination(destination) },
|
|
|
|
|
|
|
|
icon = {
|
|
|
|
|
|
|
|
val icon = if (selected) {
|
|
|
|
|
|
|
|
destination.selectedIcon
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
destination.unselectedIcon
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
when (icon) {
|
|
|
|
|
|
|
|
is ImageVectorIcon -> Icon(
|
|
|
|
|
|
|
|
imageVector = icon.imageVector,
|
|
|
|
|
|
|
|
contentDescription = null
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
is DrawableResourceIcon -> Icon(
|
|
|
|
|
|
|
|
painter = painterResource(id = icon.id),
|
|
|
|
|
|
|
|
contentDescription = null
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
label = { Text(stringResource(destination.iconTextId)) }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|