Add label to InfiniteTransition
RelNote: Label is required for tooling to differente animations
Test: Existing tests pass
Bug: 261569436
Change-Id: I56ef7627431ba19c7462719e2be3af7245249573
diff --git a/compose/animation/animation-core/api/current.ignore b/compose/animation/animation-core/api/current.ignore
new file mode 100644
index 0000000..7507c59
--- /dev/null
+++ b/compose/animation/animation-core/api/current.ignore
@@ -0,0 +1,11 @@
+// Baseline format: 1.0
+ChangedType: androidx.compose.animation.core.InfiniteTransitionKt#animateFloat(androidx.compose.animation.core.InfiniteTransition, float, float, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float>):
+ Method androidx.compose.animation.core.InfiniteTransitionKt.animateFloat has changed return type from androidx.compose.runtime.State<java.lang.Float> to androidx.compose.runtime.State<? extends java.lang.Float>
+ChangedType: androidx.compose.animation.core.InfiniteTransitionKt#animateValue(androidx.compose.animation.core.InfiniteTransition, T, T, androidx.compose.animation.core.TwoWayConverter<T,V>, androidx.compose.animation.core.InfiniteRepeatableSpec<T>):
+ Method androidx.compose.animation.core.InfiniteTransitionKt.animateValue has changed return type from androidx.compose.runtime.State<T> to androidx.compose.runtime.State<? extends T>
+
+
+InvalidNullConversion: androidx.compose.animation.core.InfiniteTransitionKt#animateFloat(androidx.compose.animation.core.InfiniteTransition, float, float, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float>):
+ Attempted to remove @NonNull annotation from method androidx.compose.animation.core.InfiniteTransitionKt.animateFloat(androidx.compose.animation.core.InfiniteTransition,float,float,androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float>)
+InvalidNullConversion: androidx.compose.animation.core.InfiniteTransitionKt#animateValue(androidx.compose.animation.core.InfiniteTransition, T, T, androidx.compose.animation.core.TwoWayConverter<T,V>, androidx.compose.animation.core.InfiniteRepeatableSpec<T>):
+ Attempted to remove @NonNull annotation from method androidx.compose.animation.core.InfiniteTransitionKt.animateValue(androidx.compose.animation.core.InfiniteTransition,T,T,androidx.compose.animation.core.TwoWayConverter<T,V>,androidx.compose.animation.core.InfiniteRepeatableSpec<T>)
diff --git a/compose/animation/animation-core/api/current.txt b/compose/animation/animation-core/api/current.txt
index 67d0595..26d75c7 100644
--- a/compose/animation/animation-core/api/current.txt
+++ b/compose/animation/animation-core/api/current.txt
@@ -414,24 +414,31 @@
public final class InfiniteTransition {
method public java.util.List<androidx.compose.animation.core.InfiniteTransition.TransitionAnimationState<?,?>> getAnimations();
+ method public String getLabel();
property public final java.util.List<androidx.compose.animation.core.InfiniteTransition.TransitionAnimationState<?,?>> animations;
+ property public final String label;
}
public final class InfiniteTransition.TransitionAnimationState<T, V extends androidx.compose.animation.core.AnimationVector> implements androidx.compose.runtime.State<T> {
method public androidx.compose.animation.core.TargetBasedAnimation<T,V> getAnimation();
method public androidx.compose.animation.core.AnimationSpec<T> getAnimationSpec();
+ method public String getLabel();
method public androidx.compose.animation.core.TwoWayConverter<T,V> getTypeConverter();
method public T! getValue();
property public final androidx.compose.animation.core.TargetBasedAnimation<T,V> animation;
property public final androidx.compose.animation.core.AnimationSpec<T> animationSpec;
+ property public final String label;
property public final androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
property public T! value;
}
public final class InfiniteTransitionKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec);
- method @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec);
- method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<? extends java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec);
+ method @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<? extends T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec);
+ method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition(optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
}
@androidx.compose.runtime.Immutable public final class KeyframesSpec<T> implements androidx.compose.animation.core.DurationBasedAnimationSpec<T> {
diff --git a/compose/animation/animation-core/api/public_plus_experimental_current.txt b/compose/animation/animation-core/api/public_plus_experimental_current.txt
index af20639..230d118 100644
--- a/compose/animation/animation-core/api/public_plus_experimental_current.txt
+++ b/compose/animation/animation-core/api/public_plus_experimental_current.txt
@@ -417,24 +417,31 @@
public final class InfiniteTransition {
method public java.util.List<androidx.compose.animation.core.InfiniteTransition.TransitionAnimationState<?,?>> getAnimations();
+ method public String getLabel();
property public final java.util.List<androidx.compose.animation.core.InfiniteTransition.TransitionAnimationState<?,?>> animations;
+ property public final String label;
}
public final class InfiniteTransition.TransitionAnimationState<T, V extends androidx.compose.animation.core.AnimationVector> implements androidx.compose.runtime.State<T> {
method public androidx.compose.animation.core.TargetBasedAnimation<T,V> getAnimation();
method public androidx.compose.animation.core.AnimationSpec<T> getAnimationSpec();
+ method public String getLabel();
method public androidx.compose.animation.core.TwoWayConverter<T,V> getTypeConverter();
method public T! getValue();
property public final androidx.compose.animation.core.TargetBasedAnimation<T,V> animation;
property public final androidx.compose.animation.core.AnimationSpec<T> animationSpec;
+ property public final String label;
property public final androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
property public T! value;
}
public final class InfiniteTransitionKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec);
- method @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec);
- method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<? extends java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec);
+ method @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<? extends T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec);
+ method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition(optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
}
@kotlin.RequiresOptIn(message="This API is internal to library.") @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.CLASS, kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.PROPERTY, kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.PROPERTY_GETTER}) public @interface InternalAnimationApi {
diff --git a/compose/animation/animation-core/api/restricted_current.ignore b/compose/animation/animation-core/api/restricted_current.ignore
new file mode 100644
index 0000000..7507c59
--- /dev/null
+++ b/compose/animation/animation-core/api/restricted_current.ignore
@@ -0,0 +1,11 @@
+// Baseline format: 1.0
+ChangedType: androidx.compose.animation.core.InfiniteTransitionKt#animateFloat(androidx.compose.animation.core.InfiniteTransition, float, float, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float>):
+ Method androidx.compose.animation.core.InfiniteTransitionKt.animateFloat has changed return type from androidx.compose.runtime.State<java.lang.Float> to androidx.compose.runtime.State<? extends java.lang.Float>
+ChangedType: androidx.compose.animation.core.InfiniteTransitionKt#animateValue(androidx.compose.animation.core.InfiniteTransition, T, T, androidx.compose.animation.core.TwoWayConverter<T,V>, androidx.compose.animation.core.InfiniteRepeatableSpec<T>):
+ Method androidx.compose.animation.core.InfiniteTransitionKt.animateValue has changed return type from androidx.compose.runtime.State<T> to androidx.compose.runtime.State<? extends T>
+
+
+InvalidNullConversion: androidx.compose.animation.core.InfiniteTransitionKt#animateFloat(androidx.compose.animation.core.InfiniteTransition, float, float, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float>):
+ Attempted to remove @NonNull annotation from method androidx.compose.animation.core.InfiniteTransitionKt.animateFloat(androidx.compose.animation.core.InfiniteTransition,float,float,androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float>)
+InvalidNullConversion: androidx.compose.animation.core.InfiniteTransitionKt#animateValue(androidx.compose.animation.core.InfiniteTransition, T, T, androidx.compose.animation.core.TwoWayConverter<T,V>, androidx.compose.animation.core.InfiniteRepeatableSpec<T>):
+ Attempted to remove @NonNull annotation from method androidx.compose.animation.core.InfiniteTransitionKt.animateValue(androidx.compose.animation.core.InfiniteTransition,T,T,androidx.compose.animation.core.TwoWayConverter<T,V>,androidx.compose.animation.core.InfiniteRepeatableSpec<T>)
diff --git a/compose/animation/animation-core/api/restricted_current.txt b/compose/animation/animation-core/api/restricted_current.txt
index b51e3a5..7e756ae 100644
--- a/compose/animation/animation-core/api/restricted_current.txt
+++ b/compose/animation/animation-core/api/restricted_current.txt
@@ -414,24 +414,31 @@
public final class InfiniteTransition {
method public java.util.List<androidx.compose.animation.core.InfiniteTransition.TransitionAnimationState<?,?>> getAnimations();
+ method public String getLabel();
property public final java.util.List<androidx.compose.animation.core.InfiniteTransition.TransitionAnimationState<?,?>> animations;
+ property public final String label;
}
public final class InfiniteTransition.TransitionAnimationState<T, V extends androidx.compose.animation.core.AnimationVector> implements androidx.compose.runtime.State<T> {
method public androidx.compose.animation.core.TargetBasedAnimation<T,V> getAnimation();
method public androidx.compose.animation.core.AnimationSpec<T> getAnimationSpec();
+ method public String getLabel();
method public androidx.compose.animation.core.TwoWayConverter<T,V> getTypeConverter();
method public T! getValue();
property public final androidx.compose.animation.core.TargetBasedAnimation<T,V> animation;
property public final androidx.compose.animation.core.AnimationSpec<T> animationSpec;
+ property public final String label;
property public final androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
property public T! value;
}
public final class InfiniteTransitionKt {
- method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec);
- method @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec);
- method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<? extends java.lang.Float> animateFloat(androidx.compose.animation.core.InfiniteTransition, float initialValue, float targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<java.lang.Float> animationSpec);
+ method @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.runtime.State<? extends T> animateValue(androidx.compose.animation.core.InfiniteTransition, T? initialValue, T? targetValue, androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter, androidx.compose.animation.core.InfiniteRepeatableSpec<T> animationSpec);
+ method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition(optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
}
@androidx.compose.runtime.Immutable public final class KeyframesSpec<T> implements androidx.compose.animation.core.DurationBasedAnimationSpec<T> {
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InfiniteTransition.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InfiniteTransition.kt
index 5bdedf7..a8eeb79 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InfiniteTransition.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InfiniteTransition.kt
@@ -38,11 +38,12 @@
* start running as soon as they enter the composition, and will not stop until they are removed
* from the composition.
*
+ * @param label A label for differentiating this animation from others in android studio.
* @sample androidx.compose.animation.core.samples.InfiniteTransitionSample
*/
@Composable
-fun rememberInfiniteTransition(): InfiniteTransition {
- val infiniteTransition = remember { InfiniteTransition() }
+fun rememberInfiniteTransition(label: String = "InfiniteTransition"): InfiniteTransition {
+ val infiniteTransition = remember { InfiniteTransition(label) }
infiniteTransition.run()
return infiniteTransition
}
@@ -54,21 +55,23 @@
* start running as soon as they enter the composition, and will not stop until they are removed
* from the composition.
*
+ * @param label A label for differentiating this animation from others in android studio.
* @sample androidx.compose.animation.core.samples.InfiniteTransitionSample
*/
-class InfiniteTransition internal constructor() {
+class InfiniteTransition internal constructor(val label: String) {
/**
* Each animation created using [InfiniteTransition.animateColor][androidx.compose.animation.animateColor],
* [InfiniteTransition.animateFloat], or [InfiniteTransition.animateValue] is represented as a
* [TransitionAnimationState] in [InfiniteTransition]. [typeConverter] converts the animation
- * value from/to an [AnimationVector].
+ * value from/to an [AnimationVector]. [label] differentiates this animation from others in android studio.
*/
inner class TransitionAnimationState<T, V : AnimationVector> internal constructor(
internal var initialValue: T,
internal var targetValue: T,
val typeConverter: TwoWayConverter<T, V>,
- animationSpec: AnimationSpec<T>
+ animationSpec: AnimationSpec<T>,
+ val label: String
) : State<T> {
override var value by mutableStateOf(initialValue)
internal set
@@ -236,6 +239,8 @@
* will be restarted with the new [initialValue] and [targetValue]. __Note__: this means
* continuity will *not* be preserved.
*
+ * A [label] for differentiating this animation from others in android studio.
+ *
* @sample androidx.compose.animation.core.samples.InfiniteTransitionAnimateValueSample
*
* @see [InfiniteTransition.animateFloat]
@@ -246,12 +251,13 @@
initialValue: T,
targetValue: T,
typeConverter: TwoWayConverter<T, V>,
- animationSpec: InfiniteRepeatableSpec<T>
+ animationSpec: InfiniteRepeatableSpec<T>,
+ label: String = "ValueAnimation"
): State<T> {
val transitionAnimation =
remember {
TransitionAnimationState(
- initialValue, targetValue, typeConverter, animationSpec
+ initialValue, targetValue, typeConverter, animationSpec, label
)
}
@@ -289,6 +295,8 @@
* will be restarted with the new [initialValue] and [targetValue]. __Note__: this means
* continuity will *not* be preserved.
*
+ * A [label] for differentiating this animation from others in android studio.
+ *
* @sample androidx.compose.animation.core.samples.InfiniteTransitionSample
*
* @see [InfiniteTransition.animateValue]
@@ -298,6 +306,53 @@
fun InfiniteTransition.animateFloat(
initialValue: Float,
targetValue: Float,
- animationSpec: InfiniteRepeatableSpec<Float>
+ animationSpec: InfiniteRepeatableSpec<Float>,
+ label: String = "FloatAnimation"
): State<Float> =
- animateValue(initialValue, targetValue, Float.VectorConverter, animationSpec)
+ animateValue(initialValue, targetValue, Float.VectorConverter, animationSpec, label)
+
+@Deprecated(
+ "rememberInfiniteTransition APIs now have a new label parameter added.",
+ level = DeprecationLevel.HIDDEN
+)
+@Composable
+fun rememberInfiniteTransition(): InfiniteTransition {
+ return rememberInfiniteTransition("InfiniteTransition")
+}
+
+@Deprecated(
+ "animateValue APIs now have a new label parameter added.",
+ level = DeprecationLevel.HIDDEN
+)
+@Composable
+fun <T, V : AnimationVector> InfiniteTransition.animateValue(
+ initialValue: T,
+ targetValue: T,
+ typeConverter: TwoWayConverter<T, V>,
+ animationSpec: InfiniteRepeatableSpec<T>,
+): State<T> {
+ return animateValue(
+ initialValue = initialValue,
+ targetValue = targetValue,
+ typeConverter = typeConverter,
+ animationSpec = animationSpec,
+ label = "ValueAnimation"
+ )
+}
+
+@Deprecated(
+ "animateFloat APIs now have a new label parameter added.",
+ level = DeprecationLevel.HIDDEN
+)
+@Composable
+fun InfiniteTransition.animateFloat(
+ initialValue: Float,
+ targetValue: Float,
+ animationSpec: InfiniteRepeatableSpec<Float>
+): State<Float> {
+ return animateFloat(
+ initialValue = initialValue,
+ targetValue = targetValue,
+ animationSpec = animationSpec, label = "FloatAnimation"
+ )
+}
diff --git a/compose/animation/animation/api/current.ignore b/compose/animation/animation/api/current.ignore
new file mode 100644
index 0000000..c62b405
--- /dev/null
+++ b/compose/animation/animation/api/current.ignore
@@ -0,0 +1,7 @@
+// Baseline format: 1.0
+ChangedType: androidx.compose.animation.TransitionKt#animateColor(androidx.compose.animation.core.InfiniteTransition, long, long, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color>):
+ Method androidx.compose.animation.TransitionKt.animateColor has changed return type from androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> to androidx.compose.runtime.State<? extends androidx.compose.ui.graphics.Color>
+
+
+InvalidNullConversion: androidx.compose.animation.TransitionKt#animateColor(androidx.compose.animation.core.InfiniteTransition, long, long, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color>):
+ Attempted to remove @NonNull annotation from method androidx.compose.animation.TransitionKt.animateColor(androidx.compose.animation.core.InfiniteTransition,long,long,androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color>)
diff --git a/compose/animation/animation/api/current.txt b/compose/animation/animation/api/current.txt
index fd0050f..9a6e17a 100644
--- a/compose/animation/animation/api/current.txt
+++ b/compose/animation/animation/api/current.txt
@@ -100,7 +100,8 @@
public final class TransitionKt {
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.Transition<S>, optional kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.Transition.Segment<S>,? extends androidx.compose.animation.core.FiniteAnimationSpec<androidx.compose.ui.graphics.Color>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.graphics.Color> targetValueByState);
- method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<? extends androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
}
}
diff --git a/compose/animation/animation/api/public_plus_experimental_current.txt b/compose/animation/animation/api/public_plus_experimental_current.txt
index 9cb61c3..b34adcc 100644
--- a/compose/animation/animation/api/public_plus_experimental_current.txt
+++ b/compose/animation/animation/api/public_plus_experimental_current.txt
@@ -172,7 +172,8 @@
public final class TransitionKt {
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.Transition<S>, optional kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.Transition.Segment<S>,? extends androidx.compose.animation.core.FiniteAnimationSpec<androidx.compose.ui.graphics.Color>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.graphics.Color> targetValueByState);
- method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<? extends androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
}
}
diff --git a/compose/animation/animation/api/restricted_current.ignore b/compose/animation/animation/api/restricted_current.ignore
new file mode 100644
index 0000000..c62b405
--- /dev/null
+++ b/compose/animation/animation/api/restricted_current.ignore
@@ -0,0 +1,7 @@
+// Baseline format: 1.0
+ChangedType: androidx.compose.animation.TransitionKt#animateColor(androidx.compose.animation.core.InfiniteTransition, long, long, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color>):
+ Method androidx.compose.animation.TransitionKt.animateColor has changed return type from androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> to androidx.compose.runtime.State<? extends androidx.compose.ui.graphics.Color>
+
+
+InvalidNullConversion: androidx.compose.animation.TransitionKt#animateColor(androidx.compose.animation.core.InfiniteTransition, long, long, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color>):
+ Attempted to remove @NonNull annotation from method androidx.compose.animation.TransitionKt.animateColor(androidx.compose.animation.core.InfiniteTransition,long,long,androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color>)
diff --git a/compose/animation/animation/api/restricted_current.txt b/compose/animation/animation/api/restricted_current.txt
index fd0050f..9a6e17a 100644
--- a/compose/animation/animation/api/restricted_current.txt
+++ b/compose/animation/animation/api/restricted_current.txt
@@ -100,7 +100,8 @@
public final class TransitionKt {
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.Transition<S>, optional kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.Transition.Segment<S>,? extends androidx.compose.animation.core.FiniteAnimationSpec<androidx.compose.ui.graphics.Color>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.graphics.Color> targetValueByState);
- method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
+ method @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec, optional String label);
+ method @Deprecated @androidx.compose.runtime.Composable public static androidx.compose.runtime.State<? extends androidx.compose.ui.graphics.Color> animateColor(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
}
}
diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
index 990334a..0641c57 100644
--- a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
+++ b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
@@ -62,7 +62,7 @@
@Composable
inline fun <S> Transition<S>.animateColor(
noinline transitionSpec:
- @Composable Transition.Segment<S>.() -> FiniteAnimationSpec<Color> = { spring() },
+ @Composable Transition.Segment<S>.() -> FiniteAnimationSpec<Color> = { spring() },
label: String = "ColorAnimation",
targetValueByState: @Composable() (state: S) -> Color
): State<Color> {
@@ -86,6 +86,8 @@
* will be restarted with the new initial/targetValue. __Note__: this means animation continuity
* will *not* be preserved when changing either [initialValue] or [targetValue].
*
+ * A [label] for differentiating this animation from others in android studio.
+ *
* @sample androidx.compose.animation.samples.InfiniteTransitionSample
*
* @see InfiniteTransition.animateValue
@@ -95,10 +97,27 @@
fun InfiniteTransition.animateColor(
initialValue: Color,
targetValue: Color,
- animationSpec: InfiniteRepeatableSpec<Color>
+ animationSpec: InfiniteRepeatableSpec<Color>,
+ label: String = "ColorAnimation"
): State<Color> {
val converter = remember {
(Color.VectorConverter)(targetValue.colorSpace)
}
- return animateValue(initialValue, targetValue, converter, animationSpec)
+ return animateValue(initialValue, targetValue, converter, animationSpec, label)
}
+
+@Deprecated(
+ "animateColor APIs now have a new label parameter added.",
+ level = DeprecationLevel.HIDDEN
+)
+@Composable
+fun InfiniteTransition.animateColor(
+ initialValue: Color,
+ targetValue: Color,
+ animationSpec: InfiniteRepeatableSpec<Color>
+): State<Color> = this.animateColor(
+ initialValue = initialValue,
+ targetValue = targetValue,
+ animationSpec = animationSpec,
+ label = "ColorAnimation"
+)