Remove deprecated transition v1
This CL removes all the Transition v1 APIs and impls. The
remaining work is to remove/update DisableTransitionsTestRule
and its usages.
Relnote: N/A
Bug: 174681955
Test: ./gradlew bOS
Change-Id: Ib608ee26b518fed89bf755348940820e4354b5b4
diff --git a/compose/animation/animation-core/api/current.txt b/compose/animation/animation-core/api/current.txt
index 7a2ea2a..acd2ab7 100644
--- a/compose/animation/animation-core/api/current.txt
+++ b/compose/animation/animation-core/api/current.txt
@@ -150,6 +150,12 @@
}
public final class AnimationSpecKt {
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.InfiniteRepeatableSpec<T> infiniteRepeatable(androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.KeyframesSpec<T> keyframes(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig<T>,kotlin.Unit> init);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.RepeatableSpec<T> repeatable(int iterations, androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SnapSpec<T> snap(optional int delayMillis);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SpringSpec<T> spring(optional float dampingRatio, optional float stiffness, optional T? visibilityThreshold);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.TweenSpec<T> tween(optional int durationMillis, optional int delayMillis, optional androidx.compose.animation.core.Easing easing);
}
public final class AnimationState<T, V extends androidx.compose.animation.core.AnimationVector> implements androidx.compose.runtime.State<T> {
@@ -361,14 +367,6 @@
property public float absVelocityThreshold;
}
- @Deprecated public final class FloatPropKey implements androidx.compose.animation.core.PropKey<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public FloatPropKey(String label);
- ctor @Deprecated public FloatPropKey();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
public final class FloatSpringSpec implements androidx.compose.animation.core.FloatAnimationSpec {
ctor public FloatSpringSpec(float dampingRatio, float stiffness, float visibilityThreshold);
ctor public FloatSpringSpec();
@@ -411,22 +409,10 @@
method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
}
- @Deprecated public final class IntPropKey implements androidx.compose.animation.core.PropKey<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public IntPropKey(String label);
- ctor @Deprecated public IntPropKey();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
@kotlin.RequiresOptIn(message="This API is internal to library.") @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface InternalAnimationApi {
}
- @Deprecated public enum InterruptionHandling {
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling PHYSICS;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling SNAP_TO_END;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling TWEEN;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling UNINTERRUPTIBLE;
+ public final class InternalAnimationApiKt {
}
@androidx.compose.runtime.Immutable public final class KeyframesSpec<T> implements androidx.compose.animation.core.DurationBasedAnimationSpec<T> {
@@ -492,19 +478,6 @@
property public final S! targetState;
}
- @Deprecated public interface PropKey<T, V extends androidx.compose.animation.core.AnimationVector> {
- method @Deprecated public default String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<T,V> getTypeConverter();
- property public default String label;
- property public abstract androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
- }
-
- public final class PropKeyKt {
- method public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.animation.core.TwoWayConverter<T,V> TwoWayConverter(kotlin.jvm.functions.Function1<? super T,? extends V> convertToVector, kotlin.jvm.functions.Function1<? super V,? extends T> convertFromVector);
- method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.FloatCompanionObject);
- method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.IntCompanionObject);
- }
-
public enum RepeatMode {
enum_constant public static final androidx.compose.animation.core.RepeatMode Restart;
enum_constant public static final androidx.compose.animation.core.RepeatMode Reverse;
@@ -593,9 +566,6 @@
property public androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
}
- public final class ToolingGlueKt {
- }
-
public final class Transition<S> {
method public S! getCurrentState();
method public String? getLabel();
@@ -627,50 +597,6 @@
property public T! value;
}
- @Deprecated public final class TransitionAnimation<T> implements androidx.compose.animation.core.TransitionState {
- ctor @Deprecated public TransitionAnimation(androidx.compose.animation.core.TransitionDefinition<T> def, androidx.compose.animation.core.AnimationClockObservable clock, T? initState, String? label);
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> T! get(androidx.compose.animation.core.PropKey<T,V> propKey);
- method @Deprecated public String? getLabel();
- method @Deprecated public kotlin.jvm.functions.Function1<T,kotlin.Unit>? getOnStateChangeFinished();
- method @Deprecated public kotlin.jvm.functions.Function0<kotlin.Unit>? getOnUpdate();
- method @Deprecated public boolean isRunning();
- method @Deprecated public void setMonotonic(boolean value);
- method @Deprecated public void setOnStateChangeFinished(kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? p);
- method @Deprecated public void setOnUpdate(kotlin.jvm.functions.Function0<kotlin.Unit>? p);
- method @Deprecated public void toState(T? name);
- property public final boolean isRunning;
- property public final String? label;
- property public final kotlin.jvm.functions.Function1<T,kotlin.Unit>? onStateChangeFinished;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit>? onUpdate;
- }
-
- public final class TransitionAnimationKt {
- }
-
- @Deprecated public final class TransitionDefinition<T> {
- ctor @Deprecated public TransitionDefinition();
- method @Deprecated public androidx.compose.animation.core.TransitionState getStateFor(T? name);
- method @Deprecated public void snapTransition(kotlin.Pair<? extends T,? extends T>![] fromToPairs, optional T? nextState);
- method @Deprecated public void state(T? name, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionDefinition.MutableTransitionState,kotlin.Unit> init);
- method @Deprecated public void transition(optional T? fromState, optional T? toState, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionSpec<T>,kotlin.Unit> init);
- method @Deprecated public void transition(kotlin.Pair<? extends T,? extends T>![] fromToPairs, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionSpec<T>,kotlin.Unit> init);
- }
-
- @Deprecated public static interface TransitionDefinition.MutableTransitionState {
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> void set(androidx.compose.animation.core.PropKey<T,V> propKey, T? prop);
- }
-
- public final class TransitionDefinitionKt {
- method @Deprecated public static <T> androidx.compose.animation.core.TransitionAnimation<T> createAnimation(androidx.compose.animation.core.TransitionDefinition<T>, androidx.compose.animation.core.AnimationClockObservable clock, optional T? initState);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.InfiniteRepeatableSpec<T> infiniteRepeatable(androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.KeyframesSpec<T> keyframes(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig<T>,kotlin.Unit> init);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.RepeatableSpec<T> repeatable(int iterations, androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SnapSpec<T> snap(optional int delayMillis);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SpringSpec<T> spring(optional float dampingRatio, optional float stiffness, optional T? visibilityThreshold);
- method @Deprecated public static <T> androidx.compose.animation.core.TransitionDefinition<T> transitionDefinition(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionDefinition<T>,kotlin.Unit> init);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.TweenSpec<T> tween(optional int durationMillis, optional int delayMillis, optional androidx.compose.animation.core.Easing easing);
- }
-
public final class TransitionKt {
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.unit.Bounds> animateBounds(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.unit.Bounds>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.unit.Bounds> targetValueByState);
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.unit.Dp> animateDp(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.unit.Dp>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.unit.Dp> targetValueByState);
@@ -686,20 +612,6 @@
method @androidx.compose.runtime.Composable public static <T> androidx.compose.animation.core.Transition<T> updateTransition(androidx.compose.animation.core.MutableTransitionState<T> transitionState, optional String? label);
}
- @Deprecated public final class TransitionSpec<S> {
- method @Deprecated public androidx.compose.animation.core.InterruptionHandling getInterruptionHandling();
- method @Deprecated public S? getNextState();
- method @Deprecated public void setInterruptionHandling(androidx.compose.animation.core.InterruptionHandling p);
- method @Deprecated public void setNextState(S? p);
- method @Deprecated public infix <T, V extends androidx.compose.animation.core.AnimationVector> void using(androidx.compose.animation.core.PropKey<T,V>, androidx.compose.animation.core.AnimationSpec<T> animationSpec);
- property public final androidx.compose.animation.core.InterruptionHandling interruptionHandling;
- property public final S? nextState;
- }
-
- @Deprecated public interface TransitionState {
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> T! get(androidx.compose.animation.core.PropKey<T,V> propKey);
- }
-
@androidx.compose.runtime.Immutable public final class TweenSpec<T> implements androidx.compose.animation.core.DurationBasedAnimationSpec<T> {
ctor public TweenSpec(int durationMillis, int delay, androidx.compose.animation.core.Easing easing);
ctor public TweenSpec();
@@ -720,6 +632,9 @@
}
public final class VectorConvertersKt {
+ method public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.animation.core.TwoWayConverter<T,V> TwoWayConverter(kotlin.jvm.functions.Function1<? super T,? extends V> convertToVector, kotlin.jvm.functions.Function1<? super V,? extends T> convertFromVector);
+ method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.FloatCompanionObject);
+ method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.IntCompanionObject);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.geometry.Rect.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(androidx.compose.ui.unit.Dp.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.DpOffset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.DpOffset.Companion);
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 7a2ea2a..acd2ab7 100644
--- a/compose/animation/animation-core/api/public_plus_experimental_current.txt
+++ b/compose/animation/animation-core/api/public_plus_experimental_current.txt
@@ -150,6 +150,12 @@
}
public final class AnimationSpecKt {
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.InfiniteRepeatableSpec<T> infiniteRepeatable(androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.KeyframesSpec<T> keyframes(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig<T>,kotlin.Unit> init);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.RepeatableSpec<T> repeatable(int iterations, androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SnapSpec<T> snap(optional int delayMillis);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SpringSpec<T> spring(optional float dampingRatio, optional float stiffness, optional T? visibilityThreshold);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.TweenSpec<T> tween(optional int durationMillis, optional int delayMillis, optional androidx.compose.animation.core.Easing easing);
}
public final class AnimationState<T, V extends androidx.compose.animation.core.AnimationVector> implements androidx.compose.runtime.State<T> {
@@ -361,14 +367,6 @@
property public float absVelocityThreshold;
}
- @Deprecated public final class FloatPropKey implements androidx.compose.animation.core.PropKey<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public FloatPropKey(String label);
- ctor @Deprecated public FloatPropKey();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
public final class FloatSpringSpec implements androidx.compose.animation.core.FloatAnimationSpec {
ctor public FloatSpringSpec(float dampingRatio, float stiffness, float visibilityThreshold);
ctor public FloatSpringSpec();
@@ -411,22 +409,10 @@
method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
}
- @Deprecated public final class IntPropKey implements androidx.compose.animation.core.PropKey<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public IntPropKey(String label);
- ctor @Deprecated public IntPropKey();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
@kotlin.RequiresOptIn(message="This API is internal to library.") @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface InternalAnimationApi {
}
- @Deprecated public enum InterruptionHandling {
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling PHYSICS;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling SNAP_TO_END;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling TWEEN;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling UNINTERRUPTIBLE;
+ public final class InternalAnimationApiKt {
}
@androidx.compose.runtime.Immutable public final class KeyframesSpec<T> implements androidx.compose.animation.core.DurationBasedAnimationSpec<T> {
@@ -492,19 +478,6 @@
property public final S! targetState;
}
- @Deprecated public interface PropKey<T, V extends androidx.compose.animation.core.AnimationVector> {
- method @Deprecated public default String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<T,V> getTypeConverter();
- property public default String label;
- property public abstract androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
- }
-
- public final class PropKeyKt {
- method public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.animation.core.TwoWayConverter<T,V> TwoWayConverter(kotlin.jvm.functions.Function1<? super T,? extends V> convertToVector, kotlin.jvm.functions.Function1<? super V,? extends T> convertFromVector);
- method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.FloatCompanionObject);
- method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.IntCompanionObject);
- }
-
public enum RepeatMode {
enum_constant public static final androidx.compose.animation.core.RepeatMode Restart;
enum_constant public static final androidx.compose.animation.core.RepeatMode Reverse;
@@ -593,9 +566,6 @@
property public androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
}
- public final class ToolingGlueKt {
- }
-
public final class Transition<S> {
method public S! getCurrentState();
method public String? getLabel();
@@ -627,50 +597,6 @@
property public T! value;
}
- @Deprecated public final class TransitionAnimation<T> implements androidx.compose.animation.core.TransitionState {
- ctor @Deprecated public TransitionAnimation(androidx.compose.animation.core.TransitionDefinition<T> def, androidx.compose.animation.core.AnimationClockObservable clock, T? initState, String? label);
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> T! get(androidx.compose.animation.core.PropKey<T,V> propKey);
- method @Deprecated public String? getLabel();
- method @Deprecated public kotlin.jvm.functions.Function1<T,kotlin.Unit>? getOnStateChangeFinished();
- method @Deprecated public kotlin.jvm.functions.Function0<kotlin.Unit>? getOnUpdate();
- method @Deprecated public boolean isRunning();
- method @Deprecated public void setMonotonic(boolean value);
- method @Deprecated public void setOnStateChangeFinished(kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? p);
- method @Deprecated public void setOnUpdate(kotlin.jvm.functions.Function0<kotlin.Unit>? p);
- method @Deprecated public void toState(T? name);
- property public final boolean isRunning;
- property public final String? label;
- property public final kotlin.jvm.functions.Function1<T,kotlin.Unit>? onStateChangeFinished;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit>? onUpdate;
- }
-
- public final class TransitionAnimationKt {
- }
-
- @Deprecated public final class TransitionDefinition<T> {
- ctor @Deprecated public TransitionDefinition();
- method @Deprecated public androidx.compose.animation.core.TransitionState getStateFor(T? name);
- method @Deprecated public void snapTransition(kotlin.Pair<? extends T,? extends T>![] fromToPairs, optional T? nextState);
- method @Deprecated public void state(T? name, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionDefinition.MutableTransitionState,kotlin.Unit> init);
- method @Deprecated public void transition(optional T? fromState, optional T? toState, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionSpec<T>,kotlin.Unit> init);
- method @Deprecated public void transition(kotlin.Pair<? extends T,? extends T>![] fromToPairs, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionSpec<T>,kotlin.Unit> init);
- }
-
- @Deprecated public static interface TransitionDefinition.MutableTransitionState {
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> void set(androidx.compose.animation.core.PropKey<T,V> propKey, T? prop);
- }
-
- public final class TransitionDefinitionKt {
- method @Deprecated public static <T> androidx.compose.animation.core.TransitionAnimation<T> createAnimation(androidx.compose.animation.core.TransitionDefinition<T>, androidx.compose.animation.core.AnimationClockObservable clock, optional T? initState);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.InfiniteRepeatableSpec<T> infiniteRepeatable(androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.KeyframesSpec<T> keyframes(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig<T>,kotlin.Unit> init);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.RepeatableSpec<T> repeatable(int iterations, androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SnapSpec<T> snap(optional int delayMillis);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SpringSpec<T> spring(optional float dampingRatio, optional float stiffness, optional T? visibilityThreshold);
- method @Deprecated public static <T> androidx.compose.animation.core.TransitionDefinition<T> transitionDefinition(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionDefinition<T>,kotlin.Unit> init);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.TweenSpec<T> tween(optional int durationMillis, optional int delayMillis, optional androidx.compose.animation.core.Easing easing);
- }
-
public final class TransitionKt {
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.unit.Bounds> animateBounds(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.unit.Bounds>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.unit.Bounds> targetValueByState);
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.unit.Dp> animateDp(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.unit.Dp>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.unit.Dp> targetValueByState);
@@ -686,20 +612,6 @@
method @androidx.compose.runtime.Composable public static <T> androidx.compose.animation.core.Transition<T> updateTransition(androidx.compose.animation.core.MutableTransitionState<T> transitionState, optional String? label);
}
- @Deprecated public final class TransitionSpec<S> {
- method @Deprecated public androidx.compose.animation.core.InterruptionHandling getInterruptionHandling();
- method @Deprecated public S? getNextState();
- method @Deprecated public void setInterruptionHandling(androidx.compose.animation.core.InterruptionHandling p);
- method @Deprecated public void setNextState(S? p);
- method @Deprecated public infix <T, V extends androidx.compose.animation.core.AnimationVector> void using(androidx.compose.animation.core.PropKey<T,V>, androidx.compose.animation.core.AnimationSpec<T> animationSpec);
- property public final androidx.compose.animation.core.InterruptionHandling interruptionHandling;
- property public final S? nextState;
- }
-
- @Deprecated public interface TransitionState {
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> T! get(androidx.compose.animation.core.PropKey<T,V> propKey);
- }
-
@androidx.compose.runtime.Immutable public final class TweenSpec<T> implements androidx.compose.animation.core.DurationBasedAnimationSpec<T> {
ctor public TweenSpec(int durationMillis, int delay, androidx.compose.animation.core.Easing easing);
ctor public TweenSpec();
@@ -720,6 +632,9 @@
}
public final class VectorConvertersKt {
+ method public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.animation.core.TwoWayConverter<T,V> TwoWayConverter(kotlin.jvm.functions.Function1<? super T,? extends V> convertToVector, kotlin.jvm.functions.Function1<? super V,? extends T> convertFromVector);
+ method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.FloatCompanionObject);
+ method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.IntCompanionObject);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.geometry.Rect.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(androidx.compose.ui.unit.Dp.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.DpOffset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.DpOffset.Companion);
diff --git a/compose/animation/animation-core/api/restricted_current.txt b/compose/animation/animation-core/api/restricted_current.txt
index 49e5b19..47a95c9 100644
--- a/compose/animation/animation-core/api/restricted_current.txt
+++ b/compose/animation/animation-core/api/restricted_current.txt
@@ -150,6 +150,12 @@
}
public final class AnimationSpecKt {
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.InfiniteRepeatableSpec<T> infiniteRepeatable(androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.KeyframesSpec<T> keyframes(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig<T>,kotlin.Unit> init);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.RepeatableSpec<T> repeatable(int iterations, androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SnapSpec<T> snap(optional int delayMillis);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SpringSpec<T> spring(optional float dampingRatio, optional float stiffness, optional T? visibilityThreshold);
+ method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.TweenSpec<T> tween(optional int durationMillis, optional int delayMillis, optional androidx.compose.animation.core.Easing easing);
}
public final class AnimationState<T, V extends androidx.compose.animation.core.AnimationVector> implements androidx.compose.runtime.State<T> {
@@ -361,14 +367,6 @@
property public float absVelocityThreshold;
}
- @Deprecated public final class FloatPropKey implements androidx.compose.animation.core.PropKey<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public FloatPropKey(String label);
- ctor @Deprecated public FloatPropKey();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
public final class FloatSpringSpec implements androidx.compose.animation.core.FloatAnimationSpec {
ctor public FloatSpringSpec(float dampingRatio, float stiffness, float visibilityThreshold);
ctor public FloatSpringSpec();
@@ -411,22 +409,10 @@
method @androidx.compose.runtime.Composable public static androidx.compose.animation.core.InfiniteTransition rememberInfiniteTransition();
}
- @Deprecated public final class IntPropKey implements androidx.compose.animation.core.PropKey<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public IntPropKey(String label);
- ctor @Deprecated public IntPropKey();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
@kotlin.RequiresOptIn(message="This API is internal to library.") @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface InternalAnimationApi {
}
- @Deprecated public enum InterruptionHandling {
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling PHYSICS;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling SNAP_TO_END;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling TWEEN;
- enum_constant @Deprecated public static final androidx.compose.animation.core.InterruptionHandling UNINTERRUPTIBLE;
+ public final class InternalAnimationApiKt {
}
@androidx.compose.runtime.Immutable public final class KeyframesSpec<T> implements androidx.compose.animation.core.DurationBasedAnimationSpec<T> {
@@ -492,19 +478,6 @@
property public final S! targetState;
}
- @Deprecated public interface PropKey<T, V extends androidx.compose.animation.core.AnimationVector> {
- method @Deprecated public default String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<T,V> getTypeConverter();
- property public default String label;
- property public abstract androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
- }
-
- public final class PropKeyKt {
- method public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.animation.core.TwoWayConverter<T,V> TwoWayConverter(kotlin.jvm.functions.Function1<? super T,? extends V> convertToVector, kotlin.jvm.functions.Function1<? super V,? extends T> convertFromVector);
- method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.FloatCompanionObject);
- method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.IntCompanionObject);
- }
-
public enum RepeatMode {
enum_constant public static final androidx.compose.animation.core.RepeatMode Restart;
enum_constant public static final androidx.compose.animation.core.RepeatMode Reverse;
@@ -593,9 +566,6 @@
property public androidx.compose.animation.core.TwoWayConverter<T,V> typeConverter;
}
- public final class ToolingGlueKt {
- }
-
public final class Transition<S> {
method @kotlin.PublishedApi internal boolean addAnimation(androidx.compose.animation.core.Transition<S>.TransitionAnimationState<?,?> animation);
method public S! getCurrentState();
@@ -635,50 +605,6 @@
field @kotlin.PublishedApi internal final androidx.compose.runtime.MutableState? targetValue$delegate;
}
- @Deprecated public final class TransitionAnimation<T> implements androidx.compose.animation.core.TransitionState {
- ctor @Deprecated public TransitionAnimation(androidx.compose.animation.core.TransitionDefinition<T> def, androidx.compose.animation.core.AnimationClockObservable clock, T? initState, String? label);
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> T! get(androidx.compose.animation.core.PropKey<T,V> propKey);
- method @Deprecated public String? getLabel();
- method @Deprecated public kotlin.jvm.functions.Function1<T,kotlin.Unit>? getOnStateChangeFinished();
- method @Deprecated public kotlin.jvm.functions.Function0<kotlin.Unit>? getOnUpdate();
- method @Deprecated public boolean isRunning();
- method @Deprecated public void setMonotonic(boolean value);
- method @Deprecated public void setOnStateChangeFinished(kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? p);
- method @Deprecated public void setOnUpdate(kotlin.jvm.functions.Function0<kotlin.Unit>? p);
- method @Deprecated public void toState(T? name);
- property public final boolean isRunning;
- property public final String? label;
- property public final kotlin.jvm.functions.Function1<T,kotlin.Unit>? onStateChangeFinished;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit>? onUpdate;
- }
-
- public final class TransitionAnimationKt {
- }
-
- @Deprecated public final class TransitionDefinition<T> {
- ctor @Deprecated public TransitionDefinition();
- method @Deprecated public androidx.compose.animation.core.TransitionState getStateFor(T? name);
- method @Deprecated public void snapTransition(kotlin.Pair<? extends T,? extends T>![] fromToPairs, optional T? nextState);
- method @Deprecated public void state(T? name, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionDefinition.MutableTransitionState,kotlin.Unit> init);
- method @Deprecated public void transition(optional T? fromState, optional T? toState, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionSpec<T>,kotlin.Unit> init);
- method @Deprecated public void transition(kotlin.Pair<? extends T,? extends T>![] fromToPairs, kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionSpec<T>,kotlin.Unit> init);
- }
-
- @Deprecated public static interface TransitionDefinition.MutableTransitionState {
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> void set(androidx.compose.animation.core.PropKey<T,V> propKey, T? prop);
- }
-
- public final class TransitionDefinitionKt {
- method @Deprecated public static <T> androidx.compose.animation.core.TransitionAnimation<T> createAnimation(androidx.compose.animation.core.TransitionDefinition<T>, androidx.compose.animation.core.AnimationClockObservable clock, optional T? initState);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.InfiniteRepeatableSpec<T> infiniteRepeatable(androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.KeyframesSpec<T> keyframes(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig<T>,kotlin.Unit> init);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.RepeatableSpec<T> repeatable(int iterations, androidx.compose.animation.core.DurationBasedAnimationSpec<T> animation, optional androidx.compose.animation.core.RepeatMode repeatMode);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SnapSpec<T> snap(optional int delayMillis);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.SpringSpec<T> spring(optional float dampingRatio, optional float stiffness, optional T? visibilityThreshold);
- method @Deprecated public static <T> androidx.compose.animation.core.TransitionDefinition<T> transitionDefinition(kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionDefinition<T>,kotlin.Unit> init);
- method @androidx.compose.runtime.Stable public static <T> androidx.compose.animation.core.TweenSpec<T> tween(optional int durationMillis, optional int delayMillis, optional androidx.compose.animation.core.Easing easing);
- }
-
public final class TransitionKt {
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.unit.Bounds> animateBounds(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.unit.Bounds>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.unit.Bounds> targetValueByState);
method @androidx.compose.runtime.Composable public static inline <S> androidx.compose.runtime.State<androidx.compose.ui.unit.Dp> animateDp(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.unit.Dp>> transitionSpec, optional String label, kotlin.jvm.functions.Function1<? super S,androidx.compose.ui.unit.Dp> targetValueByState);
@@ -694,20 +620,6 @@
method @androidx.compose.runtime.Composable public static <T> androidx.compose.animation.core.Transition<T> updateTransition(androidx.compose.animation.core.MutableTransitionState<T> transitionState, optional String? label);
}
- @Deprecated public final class TransitionSpec<S> {
- method @Deprecated public androidx.compose.animation.core.InterruptionHandling getInterruptionHandling();
- method @Deprecated public S? getNextState();
- method @Deprecated public void setInterruptionHandling(androidx.compose.animation.core.InterruptionHandling p);
- method @Deprecated public void setNextState(S? p);
- method @Deprecated public infix <T, V extends androidx.compose.animation.core.AnimationVector> void using(androidx.compose.animation.core.PropKey<T,V>, androidx.compose.animation.core.AnimationSpec<T> animationSpec);
- property public final androidx.compose.animation.core.InterruptionHandling interruptionHandling;
- property public final S? nextState;
- }
-
- @Deprecated public interface TransitionState {
- method @Deprecated public operator <T, V extends androidx.compose.animation.core.AnimationVector> T! get(androidx.compose.animation.core.PropKey<T,V> propKey);
- }
-
@androidx.compose.runtime.Immutable public final class TweenSpec<T> implements androidx.compose.animation.core.DurationBasedAnimationSpec<T> {
ctor public TweenSpec(int durationMillis, int delay, androidx.compose.animation.core.Easing easing);
ctor public TweenSpec();
@@ -728,6 +640,9 @@
}
public final class VectorConvertersKt {
+ method public static <T, V extends androidx.compose.animation.core.AnimationVector> androidx.compose.animation.core.TwoWayConverter<T,V> TwoWayConverter(kotlin.jvm.functions.Function1<? super T,? extends V> convertToVector, kotlin.jvm.functions.Function1<? super V,? extends T> convertFromVector);
+ method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.FloatCompanionObject);
+ method public static androidx.compose.animation.core.TwoWayConverter<java.lang.Integer,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(kotlin.jvm.internal.IntCompanionObject);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> getVectorConverter(androidx.compose.ui.geometry.Rect.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> getVectorConverter(androidx.compose.ui.unit.Dp.Companion);
method public static androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.DpOffset,androidx.compose.animation.core.AnimationVector2D> getVectorConverter(androidx.compose.ui.unit.DpOffset.Companion);
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/AnimationSpec.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/AnimationSpec.kt
index f5f22e0..12208b8 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/AnimationSpec.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/AnimationSpec.kt
@@ -19,6 +19,7 @@
import androidx.compose.animation.core.AnimationConstants.DefaultDurationMillis
import androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig
import androidx.compose.runtime.Immutable
+import androidx.compose.runtime.Stable
import androidx.compose.ui.unit.IntOffset
object AnimationConstants {
@@ -395,3 +396,96 @@
}
}
}
+
+/**
+ * Creates a [TweenSpec] configured with the given duration, delay and easing curve.
+ *
+ * @param durationMillis duration of the animation spec
+ * @param delayMillis the amount of time in milliseconds that animation waits before starting
+ * @param easing the easing curve that will be used to interpolate between start and end
+ */
+@Stable
+fun <T> tween(
+ durationMillis: Int = DefaultDurationMillis,
+ delayMillis: Int = 0,
+ easing: Easing = FastOutSlowInEasing
+): TweenSpec<T> = TweenSpec(durationMillis, delayMillis, easing)
+
+/**
+ * Creates a [SpringSpec] that uses the given spring constants (i.e. [dampingRatio] and
+ * [stiffness]. The optional [visibilityThreshold] defines when the animation
+ * should be considered to be visually close enough to round off to its target.
+ *
+ * @param dampingRatio damping ratio of the spring. [Spring.DampingRatioNoBouncy] by default.
+ * @param stiffness stiffness of the spring. [Spring.StiffnessMedium] by default.
+ * @param visibilityThreshold optionally specifies the visibility threshold.
+ */
+@Stable
+fun <T> spring(
+ dampingRatio: Float = Spring.DampingRatioNoBouncy,
+ stiffness: Float = Spring.StiffnessMedium,
+ visibilityThreshold: T? = null
+): SpringSpec<T> =
+ SpringSpec(dampingRatio, stiffness, visibilityThreshold)
+
+/**
+ * Creates a [KeyframesSpec] animation, initialized with [init]. For example:
+ *
+ * @param init Initialization function for the [KeyframesSpec] animation
+ * @See KeyframesSpec.KeyframesSpecConfig
+ */
+@Stable
+fun <T> keyframes(
+ init: KeyframesSpec.KeyframesSpecConfig<T>.() -> Unit
+): KeyframesSpec<T> {
+ return KeyframesSpec(KeyframesSpec.KeyframesSpecConfig<T>().apply(init))
+}
+
+/**
+ * Creates a [RepeatableSpec] that plays a [DurationBasedAnimationSpec] (e.g.
+ * [TweenSpec], [KeyframesSpec]) the amount of iterations specified by [iterations].
+ *
+ * The iteration count describes the amount of times the animation will run.
+ * 1 means no repeat. Recommend [infiniteRepeatable] for creating an infinity repeating animation.
+ *
+ * __Note__: When repeating in the [RepeatMode.Reverse] mode, it's highly recommended to have an
+ * __odd__ number of iterations. Otherwise, the animation may jump to the end value when it finishes
+ * the last iteration.
+ *
+ * @param iterations the total count of iterations, should be greater than 1 to repeat.
+ * @param animation animation that will be repeated
+ * @param repeatMode whether animation should repeat by starting from the beginning (i.e.
+ * [RepeatMode.Restart]) or from the end (i.e. [RepeatMode.Reverse])
+ */
+@Stable
+fun <T> repeatable(
+ iterations: Int,
+ animation: DurationBasedAnimationSpec<T>,
+ repeatMode: RepeatMode = RepeatMode.Restart
+): RepeatableSpec<T> =
+ RepeatableSpec(iterations, animation, repeatMode)
+
+/**
+ * Creates a [InfiniteRepeatableSpec] that plays a [DurationBasedAnimationSpec] (e.g.
+ * [TweenSpec], [KeyframesSpec]) infinite amount of iterations.
+ *
+ * For non-infinitely repeating animations, consider [repeatable].
+ *
+ * @param animation animation that will be repeated
+ * @param repeatMode whether animation should repeat by starting from the beginning (i.e.
+ * [RepeatMode.Restart]) or from the end (i.e. [RepeatMode.Reverse])
+ */
+@Stable
+fun <T> infiniteRepeatable(
+ animation: DurationBasedAnimationSpec<T>,
+ repeatMode: RepeatMode = RepeatMode.Restart
+): InfiniteRepeatableSpec<T> =
+ InfiniteRepeatableSpec(animation, repeatMode)
+
+/**
+ * Creates a Snap animation for immediately switching the animating value to the end value.
+ *
+ * @param delayMillis the number of milliseconds to wait before the animation runs. 0 by default.
+ */
+@Stable
+fun <T> snap(delayMillis: Int = 0) = SnapSpec<T>(delayMillis)
\ No newline at end of file
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InternalAnimationApi.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InternalAnimationApi.kt
new file mode 100644
index 0000000..b785b5b
--- /dev/null
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/InternalAnimationApi.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation.core
+
+@RequiresOptIn(message = "This API is internal to library.")
+@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
+annotation class InternalAnimationApi
+
+/**
+ * Stores the enabled state for [transition] animations. Useful for tests to disable
+ * animations and have reliable screenshot tests.
+ * @suppress
+ */
+@InternalAnimationApi
+@Deprecated(
+ level = DeprecationLevel.ERROR,
+ message = "Transitions should not be disabled. Instead, " +
+ "pause the animation clock and advance it manually"
+)
+var transitionsEnabled = true
\ No newline at end of file
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/PropKey.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/PropKey.kt
deleted file mode 100644
index fa74946..0000000
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/PropKey.kt
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:Suppress("DEPRECATION")
-
-package androidx.compose.animation.core
-
-/**
- * [TwoWayConverter] class contains the definition on how to convert from an arbitrary type [T]
- * to a [AnimationVector], and convert the [AnimationVector] back to the type [T]. This allows
- * animations to run on any type of objects, e.g. position, rectangle, color, etc.
- */
-interface TwoWayConverter<T, V : AnimationVector> {
- /**
- * Defines how a type [T] should be converted to a Vector type (i.e. [AnimationVector1D],
- * [AnimationVector2D], [AnimationVector3D] or [AnimationVector4D], depends on the dimensions of
- * type T).
- */
- val convertToVector: (T) -> V
- /**
- * Defines how to convert a Vector type (i.e. [AnimationVector1D], [AnimationVector2D],
- * [AnimationVector3D] or [AnimationVector4D], depends on the dimensions of type T) back to type
- * [T].
- */
- val convertFromVector: (V) -> T
-}
-
-/**
- * Factory method to create a [TwoWayConverter] that converts a type [T] from and to an
- * [AnimationVector] type.
- *
- * @param convertToVector converts from type [T] to [AnimationVector]
- * @param convertFromVector converts from [AnimationVector] to type [T]
- */
-fun <T, V : AnimationVector> TwoWayConverter(
- convertToVector: (T) -> V,
- convertFromVector: (V) -> T
-): TwoWayConverter<T, V> = TwoWayConverterImpl(convertToVector, convertFromVector)
-
-/**
- * Type converter to convert type [T] to and from a [AnimationVector1D].
- */
-private class TwoWayConverterImpl<T, V : AnimationVector>(
- override val convertToVector: (T) -> V,
- override val convertFromVector: (V) -> T
-) : TwoWayConverter<T, V>
-
-/**
- * Property key of [T] type.
- *
- * [PropKey]s are used when defining a [TransitionDefinition], as a part of creating a
- * state-based animation. Each property (to be animated) needs to be associated with a [PropKey] of
- * the type of the property. For example, this creates an alpha property:
- * `val alpha = FloatPropKey()`. [PropKey]s for common data types are
- * provided out of the box: such as [androidx.compose.animation.DpPropKey],
- * etc. To create a custom [PropKey] of type [T], a
- * [typeConverter] needs to be supplied to define how the animated data type can be converted to
- * and from an [AnimationVector], so that animations can support multi-dimensional data types.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-interface PropKey<T, V : AnimationVector> {
- /**
- * A [TwoWayConverter] that converts [T] (the data type to be animated) to and from [V] (any
- * subclass of [AnimationVector]).
- */
- val typeConverter: TwoWayConverter<T, V>
-
- /**
- * A label for distinguishing different prop keys in Tools (i.e. Android Studio).
- */
- val label: String
- get() = "PropKey"
-}
-
-internal fun lerp(start: Float, stop: Float, fraction: Float) =
- (start * (1 - fraction) + stop * fraction)
-
-internal fun lerp(start: Int, stop: Int, fraction: Float) =
- (start * (1 - fraction) + stop * fraction).toInt()
-
-/**
- * Built-in property key for [Float] properties.
- *
- * @param label Label for distinguishing different prop keys in Android Studio.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class FloatPropKey(
- override val label: String = "FloatPropKey"
-) : PropKey<Float, AnimationVector1D> {
- override val typeConverter = Float.VectorConverter
-}
-
-/**
- * Built-in property key for [Int] properties.
- *
- * @param label Label for distinguishing different prop keys in Android Studio.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class IntPropKey(override val label: String = "IntPropKey") : PropKey<Int, AnimationVector1D> {
- override val typeConverter = Int.VectorConverter
-}
-
-/**
- * A [TwoWayConverter] that converts [Float] from and to [AnimationVector1D]
- */
-val Float.Companion.VectorConverter: TwoWayConverter<Float, AnimationVector1D>
- get() = FloatToVector
-
-/**
- * A [TwoWayConverter] that converts [Int] from and to [AnimationVector1D]
- */
-val Int.Companion.VectorConverter: TwoWayConverter<Int, AnimationVector1D>
- get() = IntToVector
-
-private val FloatToVector: TwoWayConverter<Float, AnimationVector1D> =
- TwoWayConverter({ AnimationVector1D(it) }, { it.value })
-
-private val IntToVector: TwoWayConverter<Int, AnimationVector1D> =
- TwoWayConverter({ AnimationVector1D(it.toFloat()) }, { it.value.toInt() })
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/ToolingGlue.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/ToolingGlue.kt
deleted file mode 100644
index 8b447eb..0000000
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/ToolingGlue.kt
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:Suppress("DEPRECATION")
-
-package androidx.compose.animation.core
-
-@RequiresOptIn(message = "This API is internal to library.")
-@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
-annotation class InternalAnimationApi
-
-/**
- * Seekable animation class provides utilities to create an animation using a state pair, and
- * supports querying animation values based on a specific time. This class is designed to be
- * entirely stateless in terms of animation lifecycle. This design makes it easy for higher level
- * stateful construct to be built on top of it.
- *
- * This API is intended for tools' use only. Hence the @InternalAnimationApi.
- */
-/** @suppress */
-@InternalAnimationApi
-class SeekableAnimation<T>(
- val def: TransitionDefinition<T>,
- val fromState: T,
- val toState: T
-) {
- private val currentValues: MutableMap<PropKey<Any, AnimationVector>, Any> = mutableMapOf()
- private val currentAnimWrappers: MutableMap<PropKey<Any, AnimationVector>,
- Animation<Any, AnimationVector>> = mutableMapOf()
-
- init {
- val to = def.states[toState]!!
- val from = def.states[fromState]!!
- currentValues.putAll(from.props)
- val transSpec: TransitionSpec<T> = def.getSpec(fromState, toState)
- // Initialize currentAnimWrappers
- for ((prop, _) in to.props) {
- currentAnimWrappers[prop] = prop.createAnimationWrapper(
- transSpec.getAnimationForProp(prop), from[prop], null, to[prop]
- )
- }
- }
-
- /**
- * Duration of the animation. When there are multiple properties being animated in a
- * transition, this will be the duration of the longest running animation.
- */
- val duration: Long =
- currentAnimWrappers.asSequence().map { it.value.durationMillis }.maxOrNull()!!
-
- /**
- * Max duration for a single iteration (including delay) of all animations in the list.
- * Non-repeatable animations are factored in as animations with one iteration.
- */
- val maxDurationPerIteration: Long =
- currentAnimWrappers.asSequence().map {
- ((it.value as? TargetBasedAnimation)?.animationSpec as? VectorizedRepeatableSpec)
- ?.duration?.toLong()
- ?: it.value.durationMillis
- }.maxOrNull()!!
-
- /**
- * Returns the animation values at the given playtime. This time could be any time between 0
- * and duration, where 0 means the beginning of the animation.
- *
- * @param playTime animation play time in [0, duration]
- */
- fun getAnimValuesAt(playTime: Long): Map<PropKey<Any, AnimationVector>, Any> {
- if (playTime <= 0) {
- currentValues.putAll(def.states[fromState]!!.props)
- } else if (playTime >= duration) {
- currentValues.putAll(def.states[toState]!!.props)
- } else {
- for ((prop, animation) in currentAnimWrappers) {
- currentValues[prop] = animation.getValue(playTime)
- }
- }
- return currentValues
- }
-}
-
-/**
- * Creates a [SeekableAnimation] using the same [TransitionDefinition] that the
- * [TransitionAnimation] is created from.
- *
- * Note: This API is intended for tools' use only. Hence the @InternalAnimationApi.
- *
- * @param fromState The state that a [SeekableAnimation] will start from.
- * @param toState The state that a [SeekableAnimation] will end in.
- * @suppress
- */
-@InternalAnimationApi
-fun <T> TransitionAnimation<T>.createSeekableAnimation(fromState: T, toState: T) =
- SeekableAnimation<T>(def, fromState, toState)
-
-/**
- * Returns the all states available in a [TransitionDefinition].
- *
- * This API is intended for tools' use only. Hence the @InternalAnimationApi.
- * @suppress
- */
-@InternalAnimationApi
-fun <T> TransitionAnimation<T>.getStates(): Set<T> = def.states.keys
\ No newline at end of file
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionAnimation.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionAnimation.kt
deleted file mode 100644
index a441766..0000000
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionAnimation.kt
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:Suppress("DEPRECATION")
-
-package androidx.compose.animation.core
-
-import androidx.compose.animation.core.InterruptionHandling.UNINTERRUPTIBLE
-
-/**
- * [TransitionAnimation] is the underlying animation used in
- * [androidx.compose.animation.transition] for animating from one set of property values (i.e.
- * one [TransitionState]) to another. In compose, it is recommended to create such an animation
- * using [androidx.compose.animation.transition], instead of instantiating [TransitionAnimation]
- * directly.
- *
- * [TransitionAnimation] reads the property values out of the start and end state, as well as the
- * animations defined for each state pair for each property, and run these animations until all
- * properties have reached their pre-defined values in the new state. When no animation is specified
- * for a property, a default [FloatSpringSpec] animation will be used.
- *
- * [TransitionAnimation] may be interrupted while the animation is on-going by a request to go
- * to another state. [TransitionAnimation] ensures that all the animating properties preserve their
- * current value and velocity as they createAnimation to the new state.
- *
- * Once a [TransitionDefinition] is instantiated, a [TransitionAnimation] can be created via
- * [TransitionDefinition.createAnimation].
- *
- * @param def Transition definition that defines states and transitions
- * @param clock Optional animation clock that pulses animations when time changes. By default,
- * the system uses a choreographer based clock read from the [AnimationClockAmbient].
- * A custom implementation of the [AnimationClockObservable] (such as a
- * [androidx.compose.animation.core.ManualAnimationClock]) can be supplied here if
- * there’s a need to manually control the clock (for example in tests).
- * @param initState Optional initial state for the transition. When undefined, the initial state
- * will be set to the first [toState] seen in the transition.
- * @param label Optional label for distinguishing different transitions in Android Studio.
- *
- * @see [androidx.compose.animation.transition]
- */
-@OptIn(InternalAnimationApi::class)
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class TransitionAnimation<T>(
- internal val def: TransitionDefinition<T>,
- private val clock: AnimationClockObservable,
- initState: T? = null,
- val label: String? = null
-) : TransitionState {
-
- var onUpdate: (() -> Unit)? = null
- var onStateChangeFinished: ((T) -> Unit)? = null
- var isRunning = false
- private set
-
- private val UNSET = -1L
- private var fromState: StateImpl<T>
- private var toState: StateImpl<T>
- private val currentState: InternalAnimationState<T>
- private var startTime: Long = UNSET
- private var lastFrameTime: Long = UNSET
- private var pendingState: StateImpl<T>? = null
-
- // These animation wrappers contains the start/end value and start velocities for each animation
- // run, to make it convenient to query current values/velocities based on play time. They will
- // be thrown away after each animation run, as we expect start/end value and start
- // velocities to be dynamic. The stateless animation that the wrapper wraps around will be
- // re-used as they are stateless.
- private var currentAnimWrappers: MutableMap<
- PropKey<Any, AnimationVector>,
- Animation<Any, AnimationVector>
- > = mutableMapOf()
- private var startVelocityMap: MutableMap<PropKey<Any, AnimationVector>, Any> = mutableMapOf()
-
- /**
- * Named class for animation clock observer to help with tools' reflection.
- * @suppress
- */
- @InternalAnimationApi
- inner class TransitionAnimationClockObserver : AnimationClockObserver {
- // This API is intended for tools' use only. Hence the @InternalAnimationApi.
- val animation: TransitionAnimation<T> = this@TransitionAnimation
-
- override fun onAnimationFrame(frameTimeMillis: Long) {
- doAnimationFrame(frameTimeMillis)
- }
- }
-
- /**
- * This should be private. It's marked as InternalAnimationApi to give ui-tooling access to the
- * observer.
- * @suppress
- */
- @InternalAnimationApi
- val animationClockObserver: AnimationClockObserver = TransitionAnimationClockObserver()
-
- // TODO("Create a more efficient code path for default only transition def")
-
- init {
- // If an initial state is specified in the ctor, use that instead of the default state.
- val defaultState: StateImpl<T>
- if (initState == null) {
- defaultState = def.defaultState
- } else {
- defaultState = def.states[initState]!!
- }
- currentState = InternalAnimationState(defaultState, defaultState.name)
- // Need to come up with a better plan to avoid the foot gun of accidentally modifying state
- fromState = defaultState
- toState = defaultState
- }
-
- // Interpolate current state and the new state
- private fun setState(newState: StateImpl<T>) {
- if (isRunning) {
- val currentSpec = def.getSpec(fromState.name, toState.name)
- if (currentSpec.interruptionHandling == UNINTERRUPTIBLE) {
- pendingState = newState
- return
- }
- }
-
- val transitionSpec = def.getSpec(toState.name, newState.name)
- val playTime = getPlayTime()
- // TODO: handle the states that have only partial properties defined
- // For now assume all the properties are defined in all states
-
- // TODO: Support different interruption types
- // For now assume continuing with the same value, and for floats the same velocity
- for ((prop, _) in newState.props) {
- val currentVelocity = currentAnimWrappers[prop]?.getVelocityVector(playTime)
- currentAnimWrappers[prop] = prop.createAnimationWrapper(
- transitionSpec.getAnimationForProp(prop), currentState[prop], currentVelocity,
- newState[prop]
- )
-
- // TODO: Will need to track a few timelines if we support partially defined list of
- // props in each state.
- }
-
- fromState = InternalAnimationState(currentState, toState.name)
- toState = newState
-
- // Start animation should be called after all the setup has been done
- startAnimation()
- }
-
- private fun getPlayTime(): Long {
- if (startTime == UNSET) {
- return 0L
- }
- return lastFrameTime - startTime
- }
-
- /**
- * Starts the animation to go to a new state with the given state name.
- *
- * @param name Name of the [TransitionState] that is defined in the [TransitionDefinition].
- */
- fun toState(name: T) {
- val nextState = def.states[name]
- if (nextState == null) {
- // Throw exception or ignore?
- } else if (pendingState != null && toState.name == name) {
- // just canceling the pending state
- pendingState = null
- } else if ((pendingState ?: toState).name == name) {
- // already targeting this state
- } else {
- setState(nextState)
- }
- }
-
- /**
- * This indicates whether animation assumes time stamps increase monotonically. If false,
- * animation will anticipate that the time may go backwards, therefore it won't ever finish,
- * until it's set to true again.
- * @suppress
- */
- @InternalAnimationApi
- var monotonic: Boolean = true
- set(value) {
- if (field == value) {
- return
- }
- field = value
- // Changing from false to true
- if (value && isRunning) {
- // Pump in another frame to properly finish
- doAnimationFrame(lastFrameTime)
- }
- }
-
- /**
- * This immediately and violently snaps the animation to the new state, regardless whether
- * there's an on-going animation. This will also put the animation in an finished state,
- * effectively unsubscribing the animation from the clock.
- *
- * @param toState the state that animation will be snapped to
- *
- * @suppress
- */
- @InternalAnimationApi
- fun snapToState(toState: T) {
- val stateChanged = toState == fromState.name
-
- // Snap all values to end value
- val newState = def.states[toState]!!
- for (prop in newState.props.keys) {
- currentState[prop] = newState[prop]
- }
- startVelocityMap.clear()
-
- if (isRunning) {
- endAnimation()
- currentAnimWrappers.clear()
- fromState = newState
- this.toState = newState
- pendingState = null
- }
-
- if (stateChanged) {
- onStateChangeFinished?.invoke(toState)
- }
- }
-
- /**
- * Gets the value of a property with a given property key.
- *
- * @param propKey Property key (defined in [TransitionDefinition]) for a specific property
- */
- override operator fun <T, V : AnimationVector> get(propKey: PropKey<T, V>): T {
- return currentState[propKey]
- }
-
- // Start animation if not running, otherwise reset start time
- private fun startAnimation() {
- if (!isRunning) {
- isRunning = true
- clock.subscribe(animationClockObserver)
- } else {
- startTime = lastFrameTime
- }
- }
-
- private fun doAnimationFrame(frameTimeMillis: Long) {
- // Remove finished animations
- lastFrameTime = frameTimeMillis
- if (startTime == UNSET) {
- startTime = frameTimeMillis
- }
-
- val playTime = getPlayTime()
- var finished = true
- for ((prop, animation) in currentAnimWrappers) {
- if (!animation.isFinished(playTime)) {
- currentState[prop] = animation.getValue(playTime)
- finished = false
- } else {
- currentState[prop] = toState[prop]
- }
- }
-
- onUpdate?.invoke()
-
- // When all the sub-animations have finished, we'll only end the transition or move on to
- // the pending state when the transition is monotonic, as we know time won't go backward.
- // Otherwise, we'll stay subscribed to the animation clock indefinitely.
- if (finished && monotonic) {
- // All animations have finished. Snap all values to end value
- for (prop in toState.props.keys) {
- currentState[prop] = toState[prop]
- }
- startVelocityMap.clear()
-
- endAnimation()
- val currentStateName = toState.name
- val spec = def.getSpec(fromState.name, toState.name)
- val nextState = def.states[spec.nextState]
- fromState = toState
-
- // Uninterruptible transition to the next state takes a priority over the pending state.
- if (nextState != null && spec.interruptionHandling == UNINTERRUPTIBLE) {
- setState(nextState)
- } else if (pendingState != null) {
- setState(pendingState!!)
- pendingState = null
- } else if (nextState != null) {
- setState(nextState)
- }
- onStateChangeFinished?.invoke(currentStateName)
- }
- }
-
- private fun endAnimation() {
- clock.unsubscribe(animationClockObserver)
- startTime = UNSET
- lastFrameTime = UNSET
- isRunning = false
- }
-}
-
-internal fun <T, V : AnimationVector> PropKey<T, V>.createAnimationWrapper(
- anim: VectorizedAnimationSpec<V>,
- start: T,
- startVelocity: V?,
- end: T
-): Animation<T, V> =
- TargetBasedAnimation(anim, typeConverter, start, end, startVelocity)
-
-/**
- * Private class allows mutation on the prop values.
- */
-private class InternalAnimationState<T>(state: StateImpl<T>, name: T) : StateImpl<T>(name) {
-
- init {
- for ((prop, value) in state.props) {
- // Make a copy of the new values
- props[prop] = value
- }
- }
-
- override operator fun <T, V : AnimationVector> set(propKey: PropKey<T, V>, prop: T) {
- @Suppress("UNCHECKED_CAST")
- propKey as PropKey<Any, AnimationVector>
- props[propKey] = prop as Any
- }
-}
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionDefinition.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionDefinition.kt
deleted file mode 100644
index e94f0b6..0000000
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionDefinition.kt
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:Suppress("DEPRECATION")
-
-package androidx.compose.animation.core
-
-import androidx.compose.animation.core.AnimationConstants.DefaultDurationMillis
-import androidx.compose.runtime.Stable
-import androidx.compose.ui.util.fastFirstOrNull
-
-/**
- * Static specification for the transition from one state to another.
- *
- * Each property involved in the states that the transition is from and to can have an animation
- * associated with it. When such an animation is defined, the animation system will be using it
- * instead of the default [FloatSpringSpec] animation to animate the value change for that
- * property.
- *
- **/
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class TransitionSpec<S> internal constructor(private val fromToPairs: Array<out Pair<S?, S?>>) {
-
- /**
- * Optional state where should we start switching after this transition finishing.
- */
- var nextState: S? = null
-
- /**
- * The interruption handling mechanism. The default interruption handling is
- * [InterruptionHandling.PHYSICS]. Meaning both value and velocity of the property will be
- * preserved as the target state (and therefore target animation value) changes.
- * [InterruptionHandling.TWEEN], which only ensures the continuity of current animation value.
- * [InterruptionHandling.UNINTERRUPTIBLE] defines a scenario where an animation is so important
- * that it cannot be interrupted, so the new state request has to be queued.
- * [InterruptionHandling.SNAP_TO_END] can be used for cases where higher priority events (such
- * as user gesture) come in and the on-going animation needs to finish immediately to give way
- * to the user events.
- */
- var interruptionHandling: InterruptionHandling = InterruptionHandling.PHYSICS
-
- /**
- * The default animation to use when it wasn't explicitly provided for a property
- */
- internal enum class DefaultAnimation {
- Spring,
- Snap
- }
-
- internal var defaultAnimation: DefaultAnimation = DefaultAnimation.Spring
-
- private val propAnimation: MutableMap<PropKey<*, *>, VectorizedAnimationSpec<*>> =
- mutableMapOf()
-
- internal fun <T, V : AnimationVector> getAnimationForProp(
- prop: PropKey<T, V>
- ): VectorizedAnimationSpec<V> {
- @Suppress("UNCHECKED_CAST")
- return (
- propAnimation.getOrPut(
- prop,
- { createSpec<V>(defaultAnimation) }
- )
- ) as VectorizedAnimationSpec<V>
- }
-
- private fun <V : AnimationVector> createSpec(
- anim: DefaultAnimation
- ): VectorizedAnimationSpec<V> =
- when (anim) {
- DefaultAnimation.Spring -> VectorizedSpringSpec()
- DefaultAnimation.Snap -> VectorizedSnapSpec()
- }
-
- internal fun defines(from: S?, to: S?) =
- fromToPairs.any { it.first == from && it.second == to }
-
- /**
- * Associates a property with an [AnimationSpec]
- *
- * @param animationSpec: [AnimationSpec] for animating [this] property value changes
- */
- infix fun <T, V : AnimationVector> PropKey<T, V>.using(animationSpec: AnimationSpec<T>) {
- propAnimation[this] =
- animationSpec.vectorize(this.typeConverter) as VectorizedAnimationSpec<*>
- }
-}
-
-/**
- * Creates a [TweenSpec] configured with the given duration, delay and easing curve.
- *
- * @param durationMillis duration of the animation spec
- * @param delayMillis the amount of time in milliseconds that animation waits before starting
- * @param easing the easing curve that will be used to interpolate between start and end
- */
-@Stable
-fun <T> tween(
- durationMillis: Int = DefaultDurationMillis,
- delayMillis: Int = 0,
- easing: Easing = FastOutSlowInEasing
-): TweenSpec<T> = TweenSpec(durationMillis, delayMillis, easing)
-
-/**
- * Creates a [SpringSpec] that uses the given spring constants (i.e. [dampingRatio] and
- * [stiffness]. The optional [visibilityThreshold] defines when the animation
- * should be considered to be visually close enough to round off to its target.
- *
- * @param dampingRatio damping ratio of the spring. [Spring.DampingRatioNoBouncy] by default.
- * @param stiffness stiffness of the spring. [Spring.StiffnessMedium] by default.
- * @param visibilityThreshold optionally specifies the visibility threshold.
- */
-@Stable
-fun <T> spring(
- dampingRatio: Float = Spring.DampingRatioNoBouncy,
- stiffness: Float = Spring.StiffnessMedium,
- visibilityThreshold: T? = null
-): SpringSpec<T> =
- SpringSpec(dampingRatio, stiffness, visibilityThreshold)
-
-/**
- * Creates a [KeyframesSpec] animation, initialized with [init]. For example:
- *
- * @param init Initialization function for the [KeyframesSpec] animation
- * @See KeyframesSpec.KeyframesSpecConfig
- */
-@Stable
-fun <T> keyframes(
- init: KeyframesSpec.KeyframesSpecConfig<T>.() -> Unit
-): KeyframesSpec<T> {
- return KeyframesSpec(KeyframesSpec.KeyframesSpecConfig<T>().apply(init))
-}
-
-/**
- * Creates a [RepeatableSpec] that plays a [DurationBasedAnimationSpec] (e.g.
- * [TweenSpec], [KeyframesSpec]) the amount of iterations specified by [iterations].
- *
- * The iteration count describes the amount of times the animation will run.
- * 1 means no repeat. Recommend [infiniteRepeatable] for creating an infinity repeating animation.
- *
- * __Note__: When repeating in the [RepeatMode.Reverse] mode, it's highly recommended to have an
- * __odd__ number of iterations. Otherwise, the animation may jump to the end value when it finishes
- * the last iteration.
- *
- * @param iterations the total count of iterations, should be greater than 1 to repeat.
- * @param animation animation that will be repeated
- * @param repeatMode whether animation should repeat by starting from the beginning (i.e.
- * [RepeatMode.Restart]) or from the end (i.e. [RepeatMode.Reverse])
- */
-@Stable
-fun <T> repeatable(
- iterations: Int,
- animation: DurationBasedAnimationSpec<T>,
- repeatMode: RepeatMode = RepeatMode.Restart
-): RepeatableSpec<T> =
- RepeatableSpec(iterations, animation, repeatMode)
-
-/**
- * Creates a [InfiniteRepeatableSpec] that plays a [DurationBasedAnimationSpec] (e.g.
- * [TweenSpec], [KeyframesSpec]) infinite amount of iterations.
- *
- * For non-infinitely repeating animations, consider [repeatable].
- *
- * @param animation animation that will be repeated
- * @param repeatMode whether animation should repeat by starting from the beginning (i.e.
- * [RepeatMode.Restart]) or from the end (i.e. [RepeatMode.Reverse])
- */
-@Stable
-fun <T> infiniteRepeatable(
- animation: DurationBasedAnimationSpec<T>,
- repeatMode: RepeatMode = RepeatMode.Restart
-): InfiniteRepeatableSpec<T> =
- InfiniteRepeatableSpec(animation, repeatMode)
-
-/**
- * Creates a Snap animation for immediately switching the animating value to the end value.
- *
- * @param delayMillis the number of milliseconds to wait before the animation runs. 0 by default.
- */
-@Stable
-fun <T> snap(delayMillis: Int = 0) = SnapSpec<T>(delayMillis)
-
-/**
- * [TransitionDefinition] contains all the animation related configurations that will be used in
- * a state-based transition. It holds a set of [TransitionState]s and an optional set of
- * [TransitionSpec]s. It can be used in [androidx.compose.animation.transition] to create a
- * state-based animation in Compose.
- *
- * Each [TransitionState] specifies how the UI should look in terms of values
- * associated with properties that differentiates the UI from one conceptual state to anther. Each
- * [TransitionState] can be considered as a snapshot of the UI in the form of property values.
- *
- * [TransitionSpec] defines how to animate from one state to another with a specific animation for
- * each property defined in the states. [TransitionSpec] can be created using [transition] method
- * inside of a [TransitionDefinition]. Currently the animations supported in a [transition] are:
- * [tween], [keyframes], [spring], [snap], [repeatable]. When no [TransitionSpec] is specified,
- * the default [spring] animation will be used for all properties involved.
- * Similarly, when no animation is provided in a [TransitionSpec] for a particular property,
- * the default physics animation will be used. For each [transition], both the from and the to state
- * can be omitted. Omitting in this case is equivalent to a wildcard on the starting state or ending
- * state. When both are omitted at the same time, it means this transition applies to all the state
- * transitions unless a more specific transition have been defined.
- *
- * To create a [TransitionDefinition], there are generally 3 steps involved:
- *
- * __Step 1__: Create PropKeys. One [PropKey] is required for each property/value that needs to
- * be animated. These should be file level properties, so they are visible to
- * [TransitionDefinition] ( which will be created in step 3).
- *
- * val radius = FloatPropKey()
- * val alpha = FloatPropKey()
- *
- * __Step 2__ (optional): Create state names.
- *
- * This is an optional but recommended step to create a reference for different states that the
- * animation should end at. State names can be of type [T], which means they can be string,
- * integer, etc, or any custom object, so long as they are consistent.
-
- * It is recommended to either reuse the states that you already defined (e.g.
- * TogglableState.On, TogglableState.Off, etc) for animating those state changes, or create
- * an enum class for all the animation states.
- *
- * enum class ButtonState {
- * Released, Pressed, Disabled
- * }
- *
- * __Step 3__: Create a [TransitionDefinition] using the animation DSL.
- *
- * [TransitionDefinition] is conceptually an animation configuration that defines:
- * 1) States, each of which are described as a set of values. Each value is associated with a
- * PropKey.
- * 2) Optional transitions, for how to animate from one state to another.
- *
- * Once a [TransitionDefinition] is created, [androidx.compose.animation.transition] composable can take
- * it as an input and create a state-based transition in compose.
- *
- * @see [androidx.compose.animation.transition]
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class TransitionDefinition<T> {
- internal val states: MutableMap<T, StateImpl<T>> = mutableMapOf()
- internal lateinit var defaultState: StateImpl<T>
- private val transitionSpecs: MutableList<TransitionSpec<T>> = mutableListOf()
-
- // TODO: Consider also having the initial defined at call site for cases where many components
- // share the same transition def
- // TODO: (Optimization) Type param in TransitionSpec requires this defaultTransitionSpec to be
- // re-created at least for each state type T. Consider dropping this T beyond initial sanity
- // check.
- private val defaultTransitionSpec = TransitionSpec<T>(arrayOf(null to null))
-
- /**
- * [MutableTransitionState] is used in [TransitionDefinition] for constructing various
- * [TransitionState]s with corresponding properties and their values.
- */
- @Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
- interface MutableTransitionState {
- operator fun <T, V : AnimationVector> set(propKey: PropKey<T, V>, prop: T)
- }
-
- /**
- * Defines all the properties and their values associated with the state with the name: [name]
- * The first state defined in the transition definition will be the default state, whose
- * property values will be used as its initial values to createAnimation from.
- *
- * Note that the first [MutableTransitionState] created with [state] in a [TransitionDefinition]
- * will be used as the initial state.
- *
- * @param name The name of the state, which can be used to createAnimation from or to this state
- * @param init Lambda to initialize a state
- */
- fun state(name: T, init: MutableTransitionState.() -> Unit) {
- val newState = StateImpl(name).apply(init)
- states[name] = newState
- if (!::defaultState.isInitialized) {
- defaultState = newState
- }
- }
-
- /**
- * Defines a transition from state [fromState] to [toState]. When animating from one state to
- * another, [TransitionAnimation] will find the most specific matching transition, and use the
- * animations defined in it for the state transition. Both [fromState] and [toState] are
- * optional. When undefined, it means a wildcard transition going from/to any state.
- *
- * @param fromState The state that the transition will be animated from
- * @param toState The state that the transition will be animated to
- * @param init Lambda to initialize the transition
- */
- fun transition(fromState: T? = null, toState: T? = null, init: TransitionSpec<T>.() -> Unit) {
- transition(fromState to toState, init = init)
- }
-
- /**
- * Defines a transition from state first value to the second value of the [fromToPairs].
- * When animating from one state to another, [TransitionAnimation] will find the most specific
- * matching transition, and use the animations defined in it for the state transition. Both
- * values in the pair can be null. When they are null, it means a wildcard transition going
- * from/to any state.
- *
- * Sample of usage with [Pair]s infix extension [to]:
- *
- * @param fromToPairs The pairs of from and to states for this transition
- * @param init Lambda to initialize the transition
- */
- fun transition(vararg fromToPairs: Pair<T?, T?>, init: TransitionSpec<T>.() -> Unit) {
- val newSpec = TransitionSpec(fromToPairs).apply(init)
- transitionSpecs.add(newSpec)
- }
-
- /**
- * With this transition definition we are saying that every time we reach the
- * state 'from' we should immediately snap to 'to' state instead.
- *
- * Sample of usage with [Pair]s infix extension [to]:
- * snapTransition(State.Released to State.Pressed)
- *
- * @param fromToPairs The pairs of states for this transition
- * @param nextState Optional state where should we start switching after snap
- */
- fun snapTransition(vararg fromToPairs: Pair<T?, T?>, nextState: T? = null) =
- transition(*fromToPairs) {
- this.nextState = nextState
- defaultAnimation = TransitionSpec.DefaultAnimation.Snap
- }
-
- internal fun getSpec(fromState: T, toState: T): TransitionSpec<T> {
- return transitionSpecs.fastFirstOrNull { it.defines(fromState, toState) }
- ?: transitionSpecs.fastFirstOrNull { it.defines(fromState, null) }
- ?: transitionSpecs.fastFirstOrNull { it.defines(null, toState) }
- ?: transitionSpecs.fastFirstOrNull { it.defines(null, null) }
- ?: defaultTransitionSpec
- }
-
- /**
- * Returns a state holder for the specific state [name]. Useful for the cases
- * where we don't need actual animation to be happening like in tests.
- */
- fun getStateFor(name: T): TransitionState = states.getValue(name)
-}
-
-/**
- * Creates a transition animation using the transition definition and the given clock.
- *
- * @param clock The clock source for animation to get frame time from.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-fun <T> TransitionDefinition<T>.createAnimation(
- clock: AnimationClockObservable,
- initState: T? = null
-) = TransitionAnimation(this, clock, initState)
-
-/**
- * Creates a [TransitionDefinition] using the [init] function to initialize it.
- *
- * @param init Initialization function for the [TransitionDefinition]
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-fun <T> transitionDefinition(init: TransitionDefinition<T>.() -> Unit) =
- TransitionDefinition<T>().apply(init)
-
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-enum class InterruptionHandling {
- PHYSICS,
- SNAP_TO_END, // Not yet supported
- TWEEN, // Not yet supported
- UNINTERRUPTIBLE
-}
\ No newline at end of file
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionState.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionState.kt
deleted file mode 100644
index 80a6817..0000000
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/TransitionState.kt
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:Suppress("DEPRECATION")
-
-package androidx.compose.animation.core
-
-internal open class StateImpl<T>(
- val name: T
-) : TransitionDefinition.MutableTransitionState, TransitionState {
-
- internal val props: MutableMap<PropKey<Any, AnimationVector>, Any> = mutableMapOf()
-
- override operator fun <T, V : AnimationVector> set(propKey: PropKey<T, V>, prop: T) {
- @Suppress("UNCHECKED_CAST")
- propKey as PropKey<Any, AnimationVector>
- if (props[propKey] != null) {
- throw IllegalArgumentException("prop name $propKey already exists")
- }
-
- props[propKey] = prop as Any
- }
-
- @Suppress("UNCHECKED_CAST")
- override operator fun <T, V : AnimationVector> get(propKey: PropKey<T, V>): T {
- propKey as PropKey<Any, AnimationVector>
- return props[propKey] as T
- }
-}
-
-/**
- * [TransitionState] holds a number of property values. The value of a property can be queried via
- * [get], providing its property key.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-interface TransitionState {
- operator fun <T, V : AnimationVector> get(propKey: PropKey<T, V>): T
-}
\ No newline at end of file
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/VectorConverters.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/VectorConverters.kt
index 7bbc09f..00832c4 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/VectorConverters.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/VectorConverters.kt
@@ -28,6 +28,66 @@
import kotlin.math.roundToInt
/**
+ * [TwoWayConverter] class contains the definition on how to convert from an arbitrary type [T]
+ * to a [AnimationVector], and convert the [AnimationVector] back to the type [T]. This allows
+ * animations to run on any type of objects, e.g. position, rectangle, color, etc.
+ */
+interface TwoWayConverter<T, V : AnimationVector> {
+ /**
+ * Defines how a type [T] should be converted to a Vector type (i.e. [AnimationVector1D],
+ * [AnimationVector2D], [AnimationVector3D] or [AnimationVector4D], depends on the dimensions of
+ * type T).
+ */
+ val convertToVector: (T) -> V
+ /**
+ * Defines how to convert a Vector type (i.e. [AnimationVector1D], [AnimationVector2D],
+ * [AnimationVector3D] or [AnimationVector4D], depends on the dimensions of type T) back to type
+ * [T].
+ */
+ val convertFromVector: (V) -> T
+}
+
+/**
+ * Factory method to create a [TwoWayConverter] that converts a type [T] from and to an
+ * [AnimationVector] type.
+ *
+ * @param convertToVector converts from type [T] to [AnimationVector]
+ * @param convertFromVector converts from [AnimationVector] to type [T]
+ */
+fun <T, V : AnimationVector> TwoWayConverter(
+ convertToVector: (T) -> V,
+ convertFromVector: (V) -> T
+): TwoWayConverter<T, V> = TwoWayConverterImpl(convertToVector, convertFromVector)
+
+/**
+ * Type converter to convert type [T] to and from a [AnimationVector1D].
+ */
+private class TwoWayConverterImpl<T, V : AnimationVector>(
+ override val convertToVector: (T) -> V,
+ override val convertFromVector: (V) -> T
+) : TwoWayConverter<T, V>
+
+internal fun lerp(start: Float, stop: Float, fraction: Float) =
+ (start * (1 - fraction) + stop * fraction)
+
+/**
+ * A [TwoWayConverter] that converts [Float] from and to [AnimationVector1D]
+ */
+val Float.Companion.VectorConverter: TwoWayConverter<Float, AnimationVector1D>
+ get() = FloatToVector
+
+/**
+ * A [TwoWayConverter] that converts [Int] from and to [AnimationVector1D]
+ */
+val Int.Companion.VectorConverter: TwoWayConverter<Int, AnimationVector1D>
+ get() = IntToVector
+
+private val FloatToVector: TwoWayConverter<Float, AnimationVector1D> =
+ TwoWayConverter({ AnimationVector1D(it) }, { it.value })
+
+private val IntToVector: TwoWayConverter<Int, AnimationVector1D> =
+ TwoWayConverter({ AnimationVector1D(it.toFloat()) }, { it.value.toInt() })
+/**
* A type converter that converts a [Rect] to a [AnimationVector4D], and vice versa.
*/
val Rect.Companion.VectorConverter: TwoWayConverter<Rect, AnimationVector4D>
diff --git a/compose/animation/animation-core/src/test/java/androidx/compose/animation/core/ToolingGlueTest.kt b/compose/animation/animation-core/src/test/java/androidx/compose/animation/core/ToolingGlueTest.kt
deleted file mode 100644
index 25b4f6a7..0000000
--- a/compose/animation/animation-core/src/test/java/androidx/compose/animation/core/ToolingGlueTest.kt
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:Suppress("DEPRECATION")
-
-package androidx.compose.animation.core
-
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertTrue
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-import java.lang.Long.max
-
-@RunWith(JUnit4::class)
-@OptIn(InternalAnimationApi::class)
-class ToolingGlueTest {
- @Test
- fun testSeekableAnimation() {
- val animation = SeekableAnimation(def, "start", "end")
- val defaultAnim = FloatSpringSpec()
- assertEquals(
- max(defaultAnim.getDurationMillis(0f, 100f, 0f), 500L),
- animation.duration
- )
-
- var playtime = 0L
- while (playtime <= animation.duration) {
- val expectedAlpha = 1.0f - playtime / 1000f
- val expectedScale = defaultAnim.getValue(playtime, 0f, 100f, 0f)
- val animValues = animation.getAnimValuesAt(playtime)
-
- @Suppress("UNCHECKED_CAST")
- val actualAlpha = animValues[alpha as PropKey<Any, AnimationVector>] as Float
- @Suppress("UNCHECKED_CAST")
- val actualScale = animValues[scale as PropKey<Any, AnimationVector>] as Float
-
- assertEquals(actualAlpha, expectedAlpha, 0.01f)
- assertEquals(actualScale, expectedScale, 0.01f)
- playtime += 50L
- }
- }
-
- @Test
- fun testCreatingSeekableAnimation() {
- val anim = def.createAnimation(ManualAnimationClock(0L)).createSeekableAnimation(
- "end", "start"
- )
- assertEquals(600, anim.duration)
- assertEquals(def, anim.def)
- }
-
- @Test
- fun testGetStates() {
- val anim = def.createAnimation(ManualAnimationClock(0L))
- val states = anim.getStates()
- assertEquals(2, states.size)
- assertTrue(states.contains("start"))
- assertTrue(states.contains("end"))
- }
-
- @Test
- fun testMaxDurationPerIteration() {
- val anim = def2.createAnimation(ManualAnimationClock(0L)).createSeekableAnimation(
- "end", "start"
- )
- assertEquals(1200L, anim.maxDurationPerIteration)
-
- val anim2 = def2.createAnimation(ManualAnimationClock(0L)).createSeekableAnimation(
- "start", "end"
- )
- assertEquals(2000L, anim2.maxDurationPerIteration)
- }
-}
-
-private val scale = FloatPropKey("Scale")
-private val alpha = FloatPropKey("Alpha")
-private val test = FloatPropKey()
-
-private val def = transitionDefinition<String> {
- state("start") {
- this[scale] = 0f
- this[alpha] = 1f
- }
-
- state("end") {
- this[scale] = 100f
- this[alpha] = 0.5f
- }
-
- transition("start" to "end") {
- alpha using tween(
- easing = LinearEasing,
- durationMillis = 500
- )
- }
-
- transition("end" to "start") {
- scale using tween(
- durationMillis = 600
- )
- alpha using tween(
- durationMillis = 600
- )
- }
-}
-
-private val def2 = transitionDefinition<String> {
- state("start") {
- this[scale] = 0f
- this[alpha] = 1f
- this[test] = 10f
- }
-
- state("end") {
- this[scale] = 100f
- this[alpha] = 0.5f
- this[test] = 0f
- }
-
- transition("start" to "end") {
- alpha using repeatable(
- 100,
- tween(
- easing = LinearEasing,
- durationMillis = 200
- )
- )
- scale using repeatable(
- 18,
- tween(
- easing = LinearEasing,
- durationMillis = 1000
- )
- )
- test using tween(durationMillis = 2000)
- }
-
- transition("end" to "start") {
- alpha using repeatable(
- 100,
- tween(
- easing = LinearEasing,
- durationMillis = 200
- )
- )
- scale using repeatable(
- 18,
- tween(
- easing = LinearEasing,
- durationMillis = 1000,
- delayMillis = 200
- )
- )
- test using tween(durationMillis = 200)
- }
-}
\ No newline at end of file
diff --git a/compose/animation/animation/api/current.txt b/compose/animation/animation/api/current.txt
index 4912dc0..0272b58 100644
--- a/compose/animation/animation/api/current.txt
+++ b/compose/animation/animation/api/current.txt
@@ -31,13 +31,8 @@
method public static androidx.compose.ui.Modifier animateContentSize(androidx.compose.ui.Modifier, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip, optional kotlin.jvm.functions.Function2<? super androidx.compose.ui.unit.IntSize,? super androidx.compose.ui.unit.IntSize,kotlin.Unit>? endListener);
}
- @Deprecated public final class ColorPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> {
- ctor @Deprecated public ColorPropKey(androidx.compose.ui.graphics.colorspace.ColorSpace colorSpace, String label);
- ctor @Deprecated public ColorPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> typeConverter;
+ public final class ColorVectorConverterKt {
+ method public static kotlin.jvm.functions.Function1<androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D>> getVectorConverter(androidx.compose.ui.graphics.Color.Companion);
}
public final class CrossfadeKt {
@@ -57,15 +52,6 @@
method @androidx.compose.runtime.Composable public static androidx.compose.animation.DisposableAnimationClock asDisposableClock(androidx.compose.animation.core.AnimationClockObservable);
}
- @Deprecated public final class DpPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public DpPropKey(String label);
- ctor @Deprecated public DpPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
public final class EnterExitTransitionKt {
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Stable public static androidx.compose.animation.EnterTransition expandHorizontally(optional androidx.compose.ui.Alignment.Horizontal expandFrom, optional kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> initialWidth, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip);
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Stable public static androidx.compose.animation.EnterTransition expandIn(optional androidx.compose.ui.Alignment expandFrom, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntSize> initialSize, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip);
@@ -94,37 +80,6 @@
@kotlin.RequiresOptIn(message="This is an experimental animation API.") @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ExperimentalAnimationApi {
}
- @Deprecated public final class OffsetPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> {
- ctor @Deprecated public OffsetPropKey(String label);
- ctor @Deprecated public OffsetPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> typeConverter;
- }
-
- public final class PropertyKeysKt {
- method public static kotlin.jvm.functions.Function1<androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D>> getVectorConverter(androidx.compose.ui.graphics.Color.Companion);
- }
-
- @Deprecated public final class PxPropKey implements androidx.compose.animation.core.PropKey<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public PxPropKey(String label);
- ctor @Deprecated public PxPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
- @Deprecated public final class RectPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> {
- ctor @Deprecated public RectPropKey(String label);
- ctor @Deprecated public RectPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> typeConverter;
- }
-
public final class SingleValueAnimationKt {
method public static androidx.compose.animation.core.Animatable<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> Animatable-8_81llA(long initialValue);
method @Deprecated @androidx.compose.runtime.Composable public static float animate(float target, optional androidx.compose.animation.core.AnimationSpec<java.lang.Float> animSpec, optional float visibilityThreshold, optional kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener);
@@ -144,7 +99,6 @@
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-Baa6hxQ(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
- method @Deprecated @androidx.compose.runtime.Composable public static <T> androidx.compose.animation.core.TransitionState transition(androidx.compose.animation.core.TransitionDefinition<T> definition, T? toState, optional androidx.compose.animation.core.AnimationClockObservable clock, optional T? initState, optional String? label, optional kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished);
}
}
diff --git a/compose/animation/animation/api/public_plus_experimental_current.txt b/compose/animation/animation/api/public_plus_experimental_current.txt
index 4912dc0..0272b58 100644
--- a/compose/animation/animation/api/public_plus_experimental_current.txt
+++ b/compose/animation/animation/api/public_plus_experimental_current.txt
@@ -31,13 +31,8 @@
method public static androidx.compose.ui.Modifier animateContentSize(androidx.compose.ui.Modifier, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip, optional kotlin.jvm.functions.Function2<? super androidx.compose.ui.unit.IntSize,? super androidx.compose.ui.unit.IntSize,kotlin.Unit>? endListener);
}
- @Deprecated public final class ColorPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> {
- ctor @Deprecated public ColorPropKey(androidx.compose.ui.graphics.colorspace.ColorSpace colorSpace, String label);
- ctor @Deprecated public ColorPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> typeConverter;
+ public final class ColorVectorConverterKt {
+ method public static kotlin.jvm.functions.Function1<androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D>> getVectorConverter(androidx.compose.ui.graphics.Color.Companion);
}
public final class CrossfadeKt {
@@ -57,15 +52,6 @@
method @androidx.compose.runtime.Composable public static androidx.compose.animation.DisposableAnimationClock asDisposableClock(androidx.compose.animation.core.AnimationClockObservable);
}
- @Deprecated public final class DpPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public DpPropKey(String label);
- ctor @Deprecated public DpPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
public final class EnterExitTransitionKt {
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Stable public static androidx.compose.animation.EnterTransition expandHorizontally(optional androidx.compose.ui.Alignment.Horizontal expandFrom, optional kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> initialWidth, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip);
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Stable public static androidx.compose.animation.EnterTransition expandIn(optional androidx.compose.ui.Alignment expandFrom, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntSize> initialSize, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip);
@@ -94,37 +80,6 @@
@kotlin.RequiresOptIn(message="This is an experimental animation API.") @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ExperimentalAnimationApi {
}
- @Deprecated public final class OffsetPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> {
- ctor @Deprecated public OffsetPropKey(String label);
- ctor @Deprecated public OffsetPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> typeConverter;
- }
-
- public final class PropertyKeysKt {
- method public static kotlin.jvm.functions.Function1<androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D>> getVectorConverter(androidx.compose.ui.graphics.Color.Companion);
- }
-
- @Deprecated public final class PxPropKey implements androidx.compose.animation.core.PropKey<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public PxPropKey(String label);
- ctor @Deprecated public PxPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
- @Deprecated public final class RectPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> {
- ctor @Deprecated public RectPropKey(String label);
- ctor @Deprecated public RectPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> typeConverter;
- }
-
public final class SingleValueAnimationKt {
method public static androidx.compose.animation.core.Animatable<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> Animatable-8_81llA(long initialValue);
method @Deprecated @androidx.compose.runtime.Composable public static float animate(float target, optional androidx.compose.animation.core.AnimationSpec<java.lang.Float> animSpec, optional float visibilityThreshold, optional kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener);
@@ -144,7 +99,6 @@
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-Baa6hxQ(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
- method @Deprecated @androidx.compose.runtime.Composable public static <T> androidx.compose.animation.core.TransitionState transition(androidx.compose.animation.core.TransitionDefinition<T> definition, T? toState, optional androidx.compose.animation.core.AnimationClockObservable clock, optional T? initState, optional String? label, optional kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished);
}
}
diff --git a/compose/animation/animation/api/restricted_current.txt b/compose/animation/animation/api/restricted_current.txt
index 4912dc0..0272b58 100644
--- a/compose/animation/animation/api/restricted_current.txt
+++ b/compose/animation/animation/api/restricted_current.txt
@@ -31,13 +31,8 @@
method public static androidx.compose.ui.Modifier animateContentSize(androidx.compose.ui.Modifier, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip, optional kotlin.jvm.functions.Function2<? super androidx.compose.ui.unit.IntSize,? super androidx.compose.ui.unit.IntSize,kotlin.Unit>? endListener);
}
- @Deprecated public final class ColorPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> {
- ctor @Deprecated public ColorPropKey(androidx.compose.ui.graphics.colorspace.ColorSpace colorSpace, String label);
- ctor @Deprecated public ColorPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> typeConverter;
+ public final class ColorVectorConverterKt {
+ method public static kotlin.jvm.functions.Function1<androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D>> getVectorConverter(androidx.compose.ui.graphics.Color.Companion);
}
public final class CrossfadeKt {
@@ -57,15 +52,6 @@
method @androidx.compose.runtime.Composable public static androidx.compose.animation.DisposableAnimationClock asDisposableClock(androidx.compose.animation.core.AnimationClockObservable);
}
- @Deprecated public final class DpPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public DpPropKey(String label);
- ctor @Deprecated public DpPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.unit.Dp,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
public final class EnterExitTransitionKt {
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Stable public static androidx.compose.animation.EnterTransition expandHorizontally(optional androidx.compose.ui.Alignment.Horizontal expandFrom, optional kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> initialWidth, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip);
method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Stable public static androidx.compose.animation.EnterTransition expandIn(optional androidx.compose.ui.Alignment expandFrom, optional kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntSize> initialSize, optional androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec, optional boolean clip);
@@ -94,37 +80,6 @@
@kotlin.RequiresOptIn(message="This is an experimental animation API.") @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface ExperimentalAnimationApi {
}
- @Deprecated public final class OffsetPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> {
- ctor @Deprecated public OffsetPropKey(String label);
- ctor @Deprecated public OffsetPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Offset,androidx.compose.animation.core.AnimationVector2D> typeConverter;
- }
-
- public final class PropertyKeysKt {
- method public static kotlin.jvm.functions.Function1<androidx.compose.ui.graphics.colorspace.ColorSpace,androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D>> getVectorConverter(androidx.compose.ui.graphics.Color.Companion);
- }
-
- @Deprecated public final class PxPropKey implements androidx.compose.animation.core.PropKey<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> {
- ctor @Deprecated public PxPropKey(String label);
- ctor @Deprecated public PxPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<java.lang.Float,androidx.compose.animation.core.AnimationVector1D> typeConverter;
- }
-
- @Deprecated public final class RectPropKey implements androidx.compose.animation.core.PropKey<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> {
- ctor @Deprecated public RectPropKey(String label);
- ctor @Deprecated public RectPropKey();
- method @Deprecated public String getLabel();
- method @Deprecated public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> getTypeConverter();
- property public String label;
- property public androidx.compose.animation.core.TwoWayConverter<androidx.compose.ui.geometry.Rect,androidx.compose.animation.core.AnimationVector4D> typeConverter;
- }
-
public final class SingleValueAnimationKt {
method public static androidx.compose.animation.core.Animatable<androidx.compose.ui.graphics.Color,androidx.compose.animation.core.AnimationVector4D> Animatable-8_81llA(long initialValue);
method @Deprecated @androidx.compose.runtime.Composable public static float animate(float target, optional androidx.compose.animation.core.AnimationSpec<java.lang.Float> animSpec, optional float visibilityThreshold, optional kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit>? endListener);
@@ -144,7 +99,6 @@
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-Baa6hxQ(androidx.compose.animation.core.InfiniteTransition, long initialValue, long targetValue, androidx.compose.animation.core.InfiniteRepeatableSpec<androidx.compose.ui.graphics.Color> animationSpec);
- method @Deprecated @androidx.compose.runtime.Composable public static <T> androidx.compose.animation.core.TransitionState transition(androidx.compose.animation.core.TransitionDefinition<T> definition, T? toState, optional androidx.compose.animation.core.AnimationClockObservable clock, optional T? initState, optional String? label, optional kotlin.jvm.functions.Function1<? super T,kotlin.Unit>? onStateChangeFinished);
}
}
diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/ColorVectorConverter.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/ColorVectorConverter.kt
new file mode 100644
index 0000000..738b6b4
--- /dev/null
+++ b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/ColorVectorConverter.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.animation
+
+import androidx.compose.animation.core.AnimationVector4D
+import androidx.compose.animation.core.TwoWayConverter
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.colorspace.ColorSpace
+import androidx.compose.ui.graphics.colorspace.ColorSpaces
+
+/**
+ * A lambda that takes a [ColorSpace] and returns a converter that can both convert a [Color] to
+ * a [AnimationVector4D], and convert a [AnimationVector4D]) back to a [Color] in the given
+ * [ColorSpace].
+ */
+private val ColorToVector: (colorSpace: ColorSpace) -> TwoWayConverter<Color, AnimationVector4D> =
+ { colorSpace ->
+ TwoWayConverter(
+ convertToVector = {
+ val linearColor = it.convert(ColorSpaces.LinearExtendedSrgb)
+ AnimationVector4D(
+ linearColor.alpha, linearColor.red, linearColor.green,
+ linearColor.blue
+ )
+ },
+ convertFromVector = {
+ Color(
+ alpha = it.v1.coerceIn(0.0f, 1.0f),
+ red = it.v2.coerceIn(0.0f, 1.0f),
+ green = it.v3.coerceIn(0.0f, 1.0f),
+ blue = it.v4.coerceIn(0.0f, 1.0f),
+ colorSpace = ColorSpaces.LinearExtendedSrgb
+ ).convert(colorSpace)
+ }
+ )
+ }
+
+/**
+ * A lambda that takes a [ColorSpace] and returns a converter that can both convert a [Color] to
+ * a [AnimationVector4D], and convert a [AnimationVector4D]) back to a [Color] in the given
+ * [ColorSpace].
+ */
+val Color.Companion.VectorConverter:
+ (colorSpace: ColorSpace) -> TwoWayConverter<Color, AnimationVector4D>
+ get() = ColorToVector
\ No newline at end of file
diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/PropertyKeys.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/PropertyKeys.kt
deleted file mode 100644
index 76b46e6..0000000
--- a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/PropertyKeys.kt
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:Suppress("DEPRECATION")
-
-package androidx.compose.animation
-
-import androidx.compose.animation.core.AnimationVector1D
-import androidx.compose.animation.core.AnimationVector2D
-import androidx.compose.animation.core.AnimationVector4D
-import androidx.compose.animation.core.PropKey
-import androidx.compose.animation.core.TwoWayConverter
-import androidx.compose.animation.core.VectorConverter
-import androidx.compose.ui.geometry.Offset
-import androidx.compose.ui.geometry.Rect
-import androidx.compose.ui.geometry.Size
-import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.graphics.colorspace.ColorSpace
-import androidx.compose.ui.graphics.colorspace.ColorSpaces
-import androidx.compose.ui.unit.Bounds
-import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.IntOffset
-import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.unit.DpOffset
-import androidx.compose.ui.unit.dp
-import kotlin.math.roundToInt
-
-/**
- * Built-in property key for pixel properties.
- *
- * @param label Label for distinguishing different prop keys in Android Studio.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class PxPropKey(override val label: String = "PxPropKey") : PropKey<Float, AnimationVector1D> {
- override val typeConverter = Float.VectorConverter
-}
-
-/**
- * Built-in property key for [Dp] properties.
- *
- * @param label Label for distinguishing different prop keys in Android Studio.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class DpPropKey(override val label: String = "DpPropKey") : PropKey<Dp, AnimationVector1D> {
- override val typeConverter = Dp.VectorConverter
-}
-
-/**
- * Built-in property key for [Offset] properties.
- *
- * @param label Label for distinguishing different prop keys in Android Studio.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class OffsetPropKey(
- override val label: String = "OffsetPropKey"
-) : PropKey<Offset, AnimationVector2D> {
- override val typeConverter = Offset.VectorConverter
-}
-
-/**
- * Built-in property key for [Color] properties.
- *
- * @param label Label for distinguishing different prop keys in Android Studio.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class ColorPropKey(
- colorSpace: ColorSpace = ColorSpaces.Srgb,
- override val label: String = "ColorPropKey"
-) : PropKey<Color, AnimationVector4D> {
- override val typeConverter = (Color.VectorConverter)(colorSpace)
-}
-
-/**
- * Built-in property key for [Rect] properties.
- *
- * @param label Label for distinguishing different prop keys in Android Studio.
- */
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-class RectPropKey(
- override val label: String = "RectPropKey"
-) : PropKey<Rect, AnimationVector4D> {
- override val typeConverter = Rect.VectorConverter
-}
-
-/**
- * A lambda that takes a [ColorSpace] and returns a converter that can both convert a [Color] to
- * a [AnimationVector4D], and convert a [AnimationVector4D]) back to a [Color] in the given
- * [ColorSpace].
- */
-private val ColorToVector: (colorSpace: ColorSpace) -> TwoWayConverter<Color, AnimationVector4D> =
- { colorSpace ->
- TwoWayConverter(
- convertToVector = {
- val linearColor = it.convert(ColorSpaces.LinearExtendedSrgb)
- AnimationVector4D(
- linearColor.alpha, linearColor.red, linearColor.green,
- linearColor.blue
- )
- },
- convertFromVector = {
- Color(
- alpha = it.v1.coerceIn(0.0f, 1.0f),
- red = it.v2.coerceIn(0.0f, 1.0f),
- green = it.v3.coerceIn(0.0f, 1.0f),
- blue = it.v4.coerceIn(0.0f, 1.0f),
- colorSpace = ColorSpaces.LinearExtendedSrgb
- ).convert(colorSpace)
- }
- )
- }
-
-/**
- * A type converter that converts a [Rect] to a [AnimationVector4D], and vice versa.
- */
-private val RectToVector: TwoWayConverter<Rect, AnimationVector4D> =
- TwoWayConverter(
- convertToVector = {
- AnimationVector4D(it.left, it.top, it.right, it.bottom)
- },
- convertFromVector = {
- Rect(it.v1, it.v2, it.v3, it.v4)
- }
- )
-
-/**
- * A type converter that converts a [Dp] to a [AnimationVector1D], and vice versa.
- */
-private val DpToVector: TwoWayConverter<Dp, AnimationVector1D> = TwoWayConverter(
- convertToVector = { AnimationVector1D(it.value) },
- convertFromVector = { Dp(it.value) }
-)
-
-/**
- * A type converter that converts a [DpOffset] to a [AnimationVector2D], and vice versa.
- */
-private val DpOffsetToVector: TwoWayConverter<DpOffset, AnimationVector2D> =
- TwoWayConverter(
- convertToVector = { AnimationVector2D(it.x.value, it.y.value) },
- convertFromVector = { DpOffset(it.v1.dp, it.v2.dp) }
- )
-
-/**
- * A type converter that converts a [Size] to a [AnimationVector2D], and vice versa.
- */
-private val SizeToVector: TwoWayConverter<Size, AnimationVector2D> =
- TwoWayConverter(
- convertToVector = { AnimationVector2D(it.width, it.height) },
- convertFromVector = { Size(it.v1, it.v2) }
- )
-
-/**
- * A type converter that converts a [Bounds] to a [AnimationVector4D], and vice versa.
- */
-private val BoundsToVector: TwoWayConverter<Bounds, AnimationVector4D> =
- TwoWayConverter(
- convertToVector = {
- AnimationVector4D(it.left.value, it.top.value, it.right.value, it.bottom.value)
- },
- convertFromVector = { Bounds(it.v1.dp, it.v2.dp, it.v3.dp, it.v4.dp) }
- )
-
-/**
- * A type converter that converts a [Offset] to a [AnimationVector2D], and vice versa.
- */
-private val OffsetToVector: TwoWayConverter<Offset, AnimationVector2D> =
- TwoWayConverter(
- convertToVector = { AnimationVector2D(it.x, it.y) },
- convertFromVector = { Offset(it.v1, it.v2) }
- )
-
-/**
- * A type converter that converts a [IntOffset] to a [AnimationVector2D], and vice versa.
- */
-private val IntOffsetToVector: TwoWayConverter<IntOffset, AnimationVector2D> =
- TwoWayConverter(
- convertToVector = { AnimationVector2D(it.x.toFloat(), it.y.toFloat()) },
- convertFromVector = { IntOffset(it.v1.roundToInt(), it.v2.roundToInt()) }
- )
-
-/**
- * A type converter that converts a [IntSize] to a [AnimationVector2D], and vice versa.
- */
-private val IntSizeToVector: TwoWayConverter<IntSize, AnimationVector2D> =
- TwoWayConverter(
- { AnimationVector2D(it.width.toFloat(), it.height.toFloat()) },
- { IntSize(it.v1.roundToInt(), it.v2.roundToInt()) }
- )
-
-/**
- * A lambda that takes a [ColorSpace] and returns a converter that can both convert a [Color] to
- * a [AnimationVector4D], and convert a [AnimationVector4D]) back to a [Color] in the given
- * [ColorSpace].
- */
-val Color.Companion.VectorConverter:
- (colorSpace: ColorSpace) -> TwoWayConverter<Color, AnimationVector4D>
- get() = ColorToVector
\ No newline at end of file
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 3013eaf..509501e 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
@@ -14,23 +14,13 @@
* limitations under the License.
*/
-@file:Suppress("DEPRECATION")
-
package androidx.compose.animation
-import androidx.compose.animation.core.AnimationClockObservable
-import androidx.compose.animation.core.AnimationVector
import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.InfiniteRepeatableSpec
import androidx.compose.animation.core.InfiniteTransition
-import androidx.compose.animation.core.InternalAnimationApi
-import androidx.compose.animation.core.PropKey
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.Transition
-import androidx.compose.animation.core.TransitionAnimation
-import androidx.compose.animation.core.TransitionDefinition
-import androidx.compose.animation.core.TransitionState
-import androidx.compose.animation.core.animate
import androidx.compose.animation.core.animateValue
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.keyframes
@@ -38,129 +28,9 @@
import androidx.compose.animation.core.spring
import androidx.compose.animation.core.tween
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.DisposableEffect
-import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
-import androidx.compose.runtime.getValue
-import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
-import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientAnimationClock
-
-/**
- * [transition] composable creates a state-based transition using the animation configuration
- * defined in [TransitionDefinition]. This can be especially useful when animating multiple
- * values from a predefined set of values to another. For animating a single value, consider using
- * [animatedValue], [animatedFloat], [animatedColor] or the more light-weight [animate] APIs.
- *
- * [transition] starts a new animation or changes the on-going animation when the [toState]
- * parameter is changed to a different value. It dutifully ensures that the animation will head
- * towards new [toState] regardless of what state (or in-between state) it’s currently in: If the
- * transition is not currently animating, having a new [toState] value will start a new animation,
- * otherwise the in-flight animation will correct course and animate towards the new [toState]
- * based on the interruption handling logic.
- *
- * [transition] takes a transition definition, a target state and child composables.
- * These child composables will be receiving a [TransitionState] object as an argument, which
- * captures all the current values of the animation. Child composables should read the animation
- * values from the [TransitionState] object, and apply the value wherever necessary.
- *
- * @param definition Transition definition that defines states and transitions
- * @param toState New state to transition to
- * @param clock Optional animation clock that pulses animations when time changes. By default,
- * the system uses a choreographer based clock read from the [AnimationClockAmbient].
- * A custom implementation of the [AnimationClockObservable] (such as a
- * [androidx.compose.animation.core.ManualAnimationClock]) can be supplied here if there’s a need to
- * manually control the clock (for example in tests).
- * @param initState Optional initial state for the transition. When undefined, the initial state
- * will be set to the first [toState] seen in the transition.
- * @param label Optional label for distinguishing different transitions in Android Studio.
- * @param onStateChangeFinished An optional listener to get notified when state change animation
- * has completed
- *
- * @return a [TransitionState] instance, from which the animation values can be read
- *
- * @see [TransitionDefinition]
- */
-// TODO: The list of params is getting a bit long. Consider grouping them.
-@Deprecated("Please use updateTransition or rememberInfiniteTransition instead.")
-@OptIn(InternalAnimationApi::class)
-@Composable
-fun <T> transition(
- definition: TransitionDefinition<T>,
- toState: T,
- clock: AnimationClockObservable = AmbientAnimationClock.current,
- initState: T = toState,
- label: String? = null,
- onStateChangeFinished: ((T) -> Unit)? = null
-): TransitionState {
- if (@Suppress("DEPRECATION_ERROR") transitionsEnabled) {
- val disposableClock = clock.asDisposableClock()
- val model = remember(definition, disposableClock) {
- TransitionModel(definition, initState, disposableClock, label)
- }
-
- model.anim.>
- // TODO(b/150674848): Should be onCommit, but that posts to the Choreographer. Until that
- // callback is executed, nothing is aware that the animation is kicked off, so if
- // Espresso checks for idleness between now and then, it will think all is idle.
- DisposableEffect(model, toState) {
- model.anim.toState(toState)
- onDispose { }
- }
- return model
- } else {
- return remember(definition, toState) { definition.getStateFor(toState) }
- }
-}
-
-/**
- * Stores the enabled state for [transition] animations. Useful for tests to disable
- * animations and have reliable screenshot tests.
- * @suppress
- */
-@InternalAnimationApi
-@Deprecated(
- level = DeprecationLevel.ERROR,
- message = "Transitions should not be disabled. Instead, " +
- "pause the animation clock and advance it manually"
-)
-var transitionsEnabled = true
- /*@VisibleForTesting
- set*/
-
-// TODO(Doris): Use Clock idea instead of TransitionModel with pulse
-/**
- * This class is marked as internal animation API to allow access from tools
- * @suppress
- */
-@Stable
-@InternalAnimationApi
-class TransitionModel<T>(
- transitionDef: TransitionDefinition<T>,
- initState: T,
- clock: AnimationClockObservable,
- label: String?
-) : TransitionState {
-
- private var animationPulse by mutableStateOf(0L)
-
- @InternalAnimationApi
- val anim: TransitionAnimation<T> =
- TransitionAnimation(transitionDef, clock, initState, label).apply {
- >
- animationPulse++
- }
- }
-
- override fun <T, V : AnimationVector> get(propKey: PropKey<T, V>): T {
- // we need to access the animationPulse so Compose will record this state values usage.
- @Suppress("UNUSED_VARIABLE")
- val pulse = animationPulse
- return anim[propKey]
- }
-}
/**
* Creates a [Color] animation as a part of the given [Transition]. This means the lifecycle
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt
index 34d72c4..80e984a 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt
@@ -22,7 +22,6 @@
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
-import androidx.compose.animation.transition
import androidx.compose.foundation.Interaction
import androidx.compose.foundation.InteractionState
import androidx.compose.foundation.background
@@ -266,7 +265,7 @@
}
/**
- * [transition] defining how the tint color for a tab animates, when a new tab is selected. This
+ * Transition defining how the tint color for a tab animates, when a new tab is selected. This
* component uses [AmbientContentColor] to provide an interpolated value between [activeColor]
* and [inactiveColor] depending on the animation status.
*/
diff --git a/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/DisableTransitionsTestRule.kt b/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/DisableTransitionsTestRule.kt
index 9048acfc..946eb89 100644
--- a/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/DisableTransitionsTestRule.kt
+++ b/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/DisableTransitionsTestRule.kt
@@ -17,15 +17,14 @@
package androidx.compose.ui.test.junit4
import androidx.compose.animation.core.InternalAnimationApi
-import androidx.compose.animation.transition
-import androidx.compose.animation.transitionsEnabled
+import androidx.compose.animation.core.transitionsEnabled
import androidx.compose.ui.test.InternalTestApi
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
/**
- * This rule will disable all [transition] animations for the test. As a convenience, the rule
+ * This rule will disable all Transition animations for the test. As a convenience, the rule
* can be turned into a no-op by setting [disableTransitions] to `false`, allowing you to put it
* into a rule chain without branching logic.
*/