[go: nahoru, domu]

Introduce AnimatedVisibility

Relnote: "AnimatedVisibilty composable animates the appearance
and disappearance of the child content.

EnterTransition and ExitTransition are introduced to work with
AnimatedVisibilty composable to provide 3 different typs of
appearance and disappearance animation: fade, slide, and
expand/shrink the content. The different types of animations
can be combined to achieve more bespoke look and feel.
"

Bug: 147610583
Bug: 147610432
Test: unit tests added
Change-Id: Idda1162e0d7f777f64dfd91b3192c2548d1c2c29
diff --git a/ui/ui-animation/api/restricted_current.txt b/ui/ui-animation/api/restricted_current.txt
index ec7c6bb..a6b632e 100644
--- a/ui/ui-animation/api/restricted_current.txt
+++ b/ui/ui-animation/api/restricted_current.txt
@@ -21,6 +21,12 @@
     property public T! value;
   }
 
+  public final class AnimatedVisibilityKt {
+    method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Composable public static void AnimatedVisibility(boolean visible, androidx.compose.ui.Modifier modifier = Modifier, androidx.compose.animation.EnterTransition enter = fadeIn() + expandIn(), androidx.compose.animation.ExitTransition exit = shrinkOut() + fadeOut(), boolean initiallyVisible = visible, kotlin.jvm.functions.Function0<kotlin.Unit> content);
+    method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Composable public static void AnimatedVisibility(androidx.compose.foundation.layout.RowScope, boolean visible, androidx.compose.ui.Modifier modifier = Modifier, androidx.compose.animation.EnterTransition enter = fadeIn() + expandHorizontally(), androidx.compose.animation.ExitTransition exit = fadeOut() + shrinkHorizontally(), boolean initiallyVisible = visible, kotlin.jvm.functions.Function0<kotlin.Unit> content);
+    method @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Composable public static void AnimatedVisibility(androidx.compose.foundation.layout.ColumnScope, boolean visible, androidx.compose.ui.Modifier modifier = Modifier, androidx.compose.animation.EnterTransition enter = fadeIn() + expandVertically(), androidx.compose.animation.ExitTransition exit = fadeOut() + shrinkVertically(), boolean initiallyVisible = visible, kotlin.jvm.functions.Function0<kotlin.Unit> content);
+  }
+
   public final class AnimationModifierKt {
     method public static androidx.compose.ui.Modifier animateContentSize(androidx.compose.ui.Modifier, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec = spring(), boolean clip = true, kotlin.jvm.functions.Function2<? super androidx.compose.ui.unit.IntSize,? super androidx.compose.ui.unit.IntSize,kotlin.Unit>? endListener = null);
   }
@@ -58,6 +64,34 @@
     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 public static androidx.compose.animation.EnterTransition expandHorizontally(androidx.compose.ui.Alignment.Horizontal expandFrom = Alignment.End, kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> initialWidth = { return 0 }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec = spring(), boolean clip = true);
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.EnterTransition expandIn(androidx.compose.ui.Alignment expandFrom = Alignment.BottomEnd, kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntSize> initialSize = { return IntSize(0, 0) }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec = spring(), boolean clip = true);
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.EnterTransition expandVertically(androidx.compose.ui.Alignment.Vertical expandFrom = Alignment.Bottom, kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> initialHeight = { return 0 }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec = spring(), boolean clip = true);
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.EnterTransition fadeIn(float initialAlpha = 0f, androidx.compose.animation.core.AnimationSpec<java.lang.Float> animSpec = spring());
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.ExitTransition fadeOut(float targetAlpha = 0f, androidx.compose.animation.core.AnimationSpec<java.lang.Float> animSpec = spring());
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.ExitTransition shrinkHorizontally(androidx.compose.ui.Alignment.Horizontal shrinkTowards = Alignment.End, kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> targetWidth = { return 0 }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec = spring(), boolean clip = true);
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.ExitTransition shrinkOut(androidx.compose.ui.Alignment shrinkTowards = Alignment.BottomEnd, kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntSize> targetSize = { return IntSize(0, 0) }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec = spring(), boolean clip = true);
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.ExitTransition shrinkVertically(androidx.compose.ui.Alignment.Vertical shrinkTowards = Alignment.Bottom, kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> targetHeight = { return 0 }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntSize> animSpec = spring(), boolean clip = true);
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.EnterTransition slideIn(kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntOffset> initialOffset, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntOffset> animSpec = spring());
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.EnterTransition slideInHorizontally(kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> initialOffsetX = { return -it / 2 }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntOffset> animSpec = spring());
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.EnterTransition slideInVertically(kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> initialOffsetY = { return -it / 2 }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntOffset> animSpec = spring());
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.ExitTransition slideOut(kotlin.jvm.functions.Function1<? super androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.IntOffset> targetOffset, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntOffset> animSpec = spring());
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.ExitTransition slideOutHorizontally(kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> targetOffsetX = { return -it / 2 }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntOffset> animSpec = spring());
+    method @androidx.compose.animation.ExperimentalAnimationApi public static androidx.compose.animation.ExitTransition slideOutVertically(kotlin.jvm.functions.Function1<? super java.lang.Integer,java.lang.Integer> targetOffsetY = { return -it / 2 }, androidx.compose.animation.core.AnimationSpec<androidx.compose.ui.unit.IntOffset> animSpec = spring());
+  }
+
+  @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Immutable public abstract sealed class EnterTransition {
+    method public final operator androidx.compose.animation.EnterTransition plus(androidx.compose.animation.EnterTransition enter);
+  }
+
+  @androidx.compose.animation.ExperimentalAnimationApi @androidx.compose.runtime.Immutable public abstract sealed class ExitTransition {
+    method public final operator androidx.compose.animation.ExitTransition plus(androidx.compose.animation.ExitTransition exit);
+  }
+
+  @kotlin.RequiresOptIn(message="This is an experimental animation API.") @kotlin.annotation.Target(allowedTargets={AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public @interface ExperimentalAnimationApi {
+  }
+
   public final class LegacyTransitionKt {
     method @Deprecated @androidx.compose.runtime.Composable public static <T> void Transition(androidx.compose.animation.core.TransitionDefinition<T> definition, T? toState, androidx.compose.animation.core.AnimationClockObservable clock = AnimationClockAmbient.current, T? initState = toState, kotlin.jvm.functions.Function1<? super T,kotlin.Unit>?  kotlin.jvm.functions.Function1<? super androidx.compose.animation.core.TransitionState,kotlin.Unit> children);
   }