Skip to content

Commit

Permalink
NavigationBars - Make label optional and icon mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
Tweener committed Sep 5, 2024
1 parent e825332 commit bbd98bd
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,58 +41,58 @@ fun NavigationBar(

@Composable
fun RowScope.NavigationBarItem(
label: String,
icon: ImageVector,
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
label: String? = null,
colors: NavigationBarItemColors = NavigationBarItemDefaults.colors(),
icon: ImageVector? = null,
) {
NavigationBarIem(
modifier = modifier,
icon = { Icon(imageVector = icon, contentDescription = label) },
label = label,
selected = selected,
onClick = onClick,
itemColors = colors,
icon = { icon?.let { Icon(imageVector = it, contentDescription = label) } },
)
}

@Composable
fun RowScope.NavigationBarItem(
label: String,
icon: Painter,
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
label: String? = null,
colors: NavigationBarItemColors = NavigationBarItemDefaults.colors(),
icon: Painter? = null,
) {
NavigationBarIem(
modifier = modifier,
icon = { Icon(painter = icon, contentDescription = label) },
label = label,
selected = selected,
onClick = onClick,
itemColors = colors,
icon = { icon?.let { Icon(painter = it, contentDescription = label) } },
)
}

@OptIn(ExperimentalAdaptiveApi::class)
@Composable
private fun RowScope.NavigationBarIem(
label: String,
icon: @Composable () -> Unit,
selected: Boolean,
onClick: () -> Unit,
icon: @Composable () -> Unit,
modifier: Modifier = Modifier,
label: String? = null,
itemColors: NavigationBarItemColors = NavigationBarItemDefaults.colors(),
) {
AdaptiveNavigationBarItem(
modifier = modifier,
selected = selected,
onClick = onClick,
icon = icon,
label = { Text(text = label) },
label = label?.let { { Text(text = label) } },
adaptation = {
material {
colors = androidx.compose.material3.NavigationBarItemDefaults.colors(
Expand Down

0 comments on commit bbd98bd

Please sign in to comment.