Reorder parameters for consistency across the API
This change reorders the parameters within the Material 3 API components to be
consistent.
This change affects Navigation Bar and Navigation Rail.
Bug: 240580664, 240580178
Test: Ran existing tests.
Relnote: "Reorder NavigationBar and NavigationRail parameters to maintain consistency within the API"
Change-Id: I51cda43da7eb060d14ad72e4194cbec6c4ced88a
diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationBar.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationBar.kt
index 5de0980..7209ef9 100644
--- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationBar.kt
+++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationBar.kt
@@ -140,11 +140,11 @@
* @param label optional text label for this item
* @param alwaysShowLabel whether to always show the label for this item. If `false`, the label will
* only be shown when this item is selected.
+ * @param colors [NavigationBarItemColors] that will be used to resolve the colors used for this
+ * item in different states. See [NavigationBarItemDefaults.colors].
* @param interactionSource the [MutableInteractionSource] representing the stream of [Interaction]s
* for this item. You can create and pass in your own `remember`ed instance to observe
* [Interaction]s and customize the appearance / behavior of this item in different states.
- * @param colors [NavigationBarItemColors] that will be used to resolve the colors used for this
- * item in different states. See [NavigationBarItemDefaults.colors].
*/
@Composable
fun RowScope.NavigationBarItem(
@@ -155,8 +155,8 @@
enabled: Boolean = true,
label: @Composable (() -> Unit)? = null,
alwaysShowLabel: Boolean = true,
- interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
- colors: NavigationBarItemColors = NavigationBarItemDefaults.colors()
+ colors: NavigationBarItemColors = NavigationBarItemDefaults.colors(),
+ interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }
) {
val styledIcon = @Composable {
val iconColor by colors.iconColor(selected = selected)
@@ -262,19 +262,19 @@
* specification.
*
* @param selectedIconColor the color to use for the icon when the item is selected.
- * @param unselectedIconColor the color to use for the icon when the item is unselected.
* @param selectedTextColor the color to use for the text label when the item is selected.
- * @param unselectedTextColor the color to use for the text label when the item is unselected.
* @param indicatorColor the color to use for the indicator when the item is selected.
+ * @param unselectedIconColor the color to use for the icon when the item is unselected.
+ * @param unselectedTextColor the color to use for the text label when the item is unselected.
* @return the resulting [NavigationBarItemColors] used for [NavigationBarItem]
*/
@Composable
fun colors(
selectedIconColor: Color = NavigationBarTokens.ActiveIconColor.toColor(),
- unselectedIconColor: Color = NavigationBarTokens.InactiveIconColor.toColor(),
selectedTextColor: Color = NavigationBarTokens.ActiveLabelTextColor.toColor(),
- unselectedTextColor: Color = NavigationBarTokens.InactiveLabelTextColor.toColor(),
indicatorColor: Color = NavigationBarTokens.ActiveIndicatorColor.toColor(),
+ unselectedIconColor: Color = NavigationBarTokens.InactiveIconColor.toColor(),
+ unselectedTextColor: Color = NavigationBarTokens.InactiveLabelTextColor.toColor(),
): NavigationBarItemColors = remember(
selectedIconColor,
unselectedIconColor,
@@ -284,10 +284,10 @@
) {
DefaultNavigationBarItemColors(
selectedIconColor = selectedIconColor,
- unselectedIconColor = unselectedIconColor,
selectedTextColor = selectedTextColor,
- unselectedTextColor = unselectedTextColor,
selectedIndicatorColor = indicatorColor,
+ unselectedIconColor = unselectedIconColor,
+ unselectedTextColor = unselectedTextColor,
)
}
}
@@ -319,10 +319,10 @@
@Stable
private class DefaultNavigationBarItemColors(
private val selectedIconColor: Color,
- private val unselectedIconColor: Color,
private val selectedTextColor: Color,
- private val unselectedTextColor: Color,
private val selectedIndicatorColor: Color,
+ private val unselectedIconColor: Color,
+ private val unselectedTextColor: Color,
) : NavigationBarItemColors {
@Composable
override fun iconColor(selected: Boolean): State<Color> {