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/api/current.txt b/compose/material3/material3/api/current.txt
index bb51857..a791ab5 100644
--- a/compose/material3/material3/api/current.txt
+++ b/compose/material3/material3/api/current.txt
@@ -399,13 +399,13 @@
}
public final class NavigationBarItemDefaults {
- method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors(optional long selectedIconColor, optional long unselectedIconColor, optional long selectedTextColor, optional long unselectedTextColor, optional long indicatorColor);
+ method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors(optional long selectedIconColor, optional long selectedTextColor, optional long indicatorColor, optional long unselectedIconColor, optional long unselectedTextColor);
field public static final androidx.compose.material3.NavigationBarItemDefaults INSTANCE;
}
public final class NavigationBarKt {
method @androidx.compose.runtime.Composable public static void NavigationBar(optional androidx.compose.ui.Modifier modifier, optional long containerColor, optional long contentColor, optional float tonalElevation, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void NavigationBarItem(androidx.compose.foundation.layout.RowScope, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.material3.NavigationBarItemColors colors);
+ method @androidx.compose.runtime.Composable public static void NavigationBarItem(androidx.compose.foundation.layout.RowScope, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.material3.NavigationBarItemColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource);
}
public final class NavigationDrawerKt {
@@ -425,13 +425,13 @@
}
public final class NavigationRailItemDefaults {
- method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationRailItemColors colors(optional long selectedIconColor, optional long unselectedIconColor, optional long selectedTextColor, optional long unselectedTextColor, optional long indicatorColor);
+ method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationRailItemColors colors(optional long selectedIconColor, optional long selectedTextColor, optional long indicatorColor, optional long unselectedIconColor, optional long unselectedTextColor);
field public static final androidx.compose.material3.NavigationRailItemDefaults INSTANCE;
}
public final class NavigationRailKt {
method @androidx.compose.runtime.Composable public static void NavigationRail(optional androidx.compose.ui.Modifier modifier, optional long containerColor, optional long contentColor, optional kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit>? header, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void NavigationRailItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.material3.NavigationRailItemColors colors);
+ method @androidx.compose.runtime.Composable public static void NavigationRailItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.material3.NavigationRailItemColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource);
}
public final class OutlinedTextFieldKt {
diff --git a/compose/material3/material3/api/public_plus_experimental_current.txt b/compose/material3/material3/api/public_plus_experimental_current.txt
index 9c0fe22..713c422 100644
--- a/compose/material3/material3/api/public_plus_experimental_current.txt
+++ b/compose/material3/material3/api/public_plus_experimental_current.txt
@@ -577,13 +577,13 @@
}
public final class NavigationBarItemDefaults {
- method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors(optional long selectedIconColor, optional long unselectedIconColor, optional long selectedTextColor, optional long unselectedTextColor, optional long indicatorColor);
+ method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors(optional long selectedIconColor, optional long selectedTextColor, optional long indicatorColor, optional long unselectedIconColor, optional long unselectedTextColor);
field public static final androidx.compose.material3.NavigationBarItemDefaults INSTANCE;
}
public final class NavigationBarKt {
method @androidx.compose.runtime.Composable public static void NavigationBar(optional androidx.compose.ui.Modifier modifier, optional long containerColor, optional long contentColor, optional float tonalElevation, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void NavigationBarItem(androidx.compose.foundation.layout.RowScope, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.material3.NavigationBarItemColors colors);
+ method @androidx.compose.runtime.Composable public static void NavigationBarItem(androidx.compose.foundation.layout.RowScope, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.material3.NavigationBarItemColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource);
}
@androidx.compose.material3.ExperimentalMaterial3Api @androidx.compose.runtime.Stable public interface NavigationDrawerItemColors {
@@ -626,13 +626,13 @@
}
public final class NavigationRailItemDefaults {
- method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationRailItemColors colors(optional long selectedIconColor, optional long unselectedIconColor, optional long selectedTextColor, optional long unselectedTextColor, optional long indicatorColor);
+ method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationRailItemColors colors(optional long selectedIconColor, optional long selectedTextColor, optional long indicatorColor, optional long unselectedIconColor, optional long unselectedTextColor);
field public static final androidx.compose.material3.NavigationRailItemDefaults INSTANCE;
}
public final class NavigationRailKt {
method @androidx.compose.runtime.Composable public static void NavigationRail(optional androidx.compose.ui.Modifier modifier, optional long containerColor, optional long contentColor, optional kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit>? header, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void NavigationRailItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.material3.NavigationRailItemColors colors);
+ method @androidx.compose.runtime.Composable public static void NavigationRailItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.material3.NavigationRailItemColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource);
}
public final class OutlinedTextFieldKt {
diff --git a/compose/material3/material3/api/restricted_current.txt b/compose/material3/material3/api/restricted_current.txt
index bb51857..a791ab5 100644
--- a/compose/material3/material3/api/restricted_current.txt
+++ b/compose/material3/material3/api/restricted_current.txt
@@ -399,13 +399,13 @@
}
public final class NavigationBarItemDefaults {
- method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors(optional long selectedIconColor, optional long unselectedIconColor, optional long selectedTextColor, optional long unselectedTextColor, optional long indicatorColor);
+ method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors(optional long selectedIconColor, optional long selectedTextColor, optional long indicatorColor, optional long unselectedIconColor, optional long unselectedTextColor);
field public static final androidx.compose.material3.NavigationBarItemDefaults INSTANCE;
}
public final class NavigationBarKt {
method @androidx.compose.runtime.Composable public static void NavigationBar(optional androidx.compose.ui.Modifier modifier, optional long containerColor, optional long contentColor, optional float tonalElevation, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void NavigationBarItem(androidx.compose.foundation.layout.RowScope, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.material3.NavigationBarItemColors colors);
+ method @androidx.compose.runtime.Composable public static void NavigationBarItem(androidx.compose.foundation.layout.RowScope, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.material3.NavigationBarItemColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource);
}
public final class NavigationDrawerKt {
@@ -425,13 +425,13 @@
}
public final class NavigationRailItemDefaults {
- method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationRailItemColors colors(optional long selectedIconColor, optional long unselectedIconColor, optional long selectedTextColor, optional long unselectedTextColor, optional long indicatorColor);
+ method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationRailItemColors colors(optional long selectedIconColor, optional long selectedTextColor, optional long indicatorColor, optional long unselectedIconColor, optional long unselectedTextColor);
field public static final androidx.compose.material3.NavigationRailItemDefaults INSTANCE;
}
public final class NavigationRailKt {
method @androidx.compose.runtime.Composable public static void NavigationRail(optional androidx.compose.ui.Modifier modifier, optional long containerColor, optional long contentColor, optional kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit>? header, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.ColumnScope,kotlin.Unit> content);
- method @androidx.compose.runtime.Composable public static void NavigationRailItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource, optional androidx.compose.material3.NavigationRailItemColors colors);
+ method @androidx.compose.runtime.Composable public static void NavigationRailItem(boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.material3.NavigationRailItemColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource interactionSource);
}
public final class OutlinedTextFieldKt {
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> {
diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationRail.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationRail.kt
index fcfc11a..2e593e8 100644
--- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationRail.kt
+++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationRail.kt
@@ -144,11 +144,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 [NavigationRailItemColors] that will be used to resolve the colors used for this
+ * item in different states. See [NavigationRailItemDefaults.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 [NavigationRailItemColors] that will be used to resolve the colors used for this
- * item in different states. See [NavigationRailItemDefaults.colors].
*/
@Composable
fun NavigationRailItem(
@@ -159,8 +159,8 @@
enabled: Boolean = true,
label: @Composable (() -> Unit)? = null,
alwaysShowLabel: Boolean = true,
- interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
colors: NavigationRailItemColors = NavigationRailItemDefaults.colors(),
+ interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
) {
val styledIcon = @Composable {
val iconColor by colors.iconColor(selected = selected)
@@ -264,19 +264,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 [NavigationRailItemColors] used for [NavigationRailItem]
*/
@Composable
fun colors(
selectedIconColor: Color = NavigationRailTokens.ActiveIconColor.toColor(),
- unselectedIconColor: Color = NavigationRailTokens.InactiveIconColor.toColor(),
selectedTextColor: Color = NavigationRailTokens.ActiveLabelTextColor.toColor(),
- unselectedTextColor: Color = NavigationRailTokens.InactiveLabelTextColor.toColor(),
indicatorColor: Color = NavigationRailTokens.ActiveIndicatorColor.toColor(),
+ unselectedIconColor: Color = NavigationRailTokens.InactiveIconColor.toColor(),
+ unselectedTextColor: Color = NavigationRailTokens.InactiveLabelTextColor.toColor(),
): NavigationRailItemColors = remember(
selectedIconColor,
unselectedIconColor,
@@ -321,10 +321,10 @@
@Stable
private class DefaultNavigationRailItemColors(
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,
) : NavigationRailItemColors {
@Composable
override fun iconColor(selected: Boolean): State<Color> {