Package-level declarations

Types

Link copied to clipboard

进入状态,表示页面即将进入,是Transform的开始

Link copied to clipboard
Link copied to clipboard
data class ExitingState(val progress: Float) : TransformState

ResumeStateExitState的中间态,用于手势过程,代表正在退出

Link copied to clipboard

退出状态/结束状态;transform的结束

Link copied to clipboard
Link copied to clipboard
sealed interface GestureModel
Link copied to clipboard
class ModalTransformWrap(proportion: Float, gestureModel: GestureModel) : TransformWrap

类ios的Modal手势实现,在页面route时设置modal即可使用

Link copied to clipboard

普通的默认手势实现,在页面route时设置normal即可使用

Link copied to clipboard

显示状态

Link copied to clipboard
data class StoppingState(val progress: Float) : TransformState

StopStateResumeState的中间态,用于手势过程,代表正在暂停

Link copied to clipboard

暂停状态;代表后一个页面已经显示了,当前界面已经变为前一个页面,该页面暂停

Link copied to clipboard
data class Transform

一个transform代表的是一次页面变换

Link copied to clipboard

变换构造类,用于构造Transform

Link copied to clipboard

描述界面变换的状态,以及进度。需要注意的是TransformState类簇仅描述界面变换,不代表页面生命周期。

Link copied to clipboard
abstract class TransformWrap(gestureModel: GestureModel = GestureModel.Local)

变换包裹层,在这里可以同时控制当前页面和前一个页面的变化。

Link copied to clipboard

手势包裹层的作用域,该类主要是管理一些工作,比如:让页面内容也可以控制页面的手势

Functions

Link copied to clipboard
fun TransformState.between(resume: Offset, exit: Offset, enter: Offset = exit, pause: Offset = resume): Offset
fun TransformState.between(resume: Rect, exit: Rect, enter: Rect = exit, pause: Rect = resume): Rect
fun TransformState.between(resume: Size, exit: Size, enter: Size = exit, pause: Size = resume): Size
fun TransformState.between(resume: Color, exit: Color, enter: Color = exit, pause: Color = resume): Color
fun TransformState.between(resume: Dp, exit: Dp, enter: Dp = exit, pause: Dp = resume): Dp
fun TransformState.between(resume: DpOffset, exit: DpOffset, enter: DpOffset = exit, pause: DpOffset = resume): DpOffset
fun TransformState.between(resume: DpSize, exit: DpSize, enter: DpSize = exit, pause: DpSize = resume): DpSize
fun TransformState.between(resume: IntOffset, exit: IntOffset, enter: IntOffset = exit, pause: IntOffset = resume): IntOffset
fun TransformState.between(resume: IntSize, exit: IntSize, enter: IntSize = exit, pause: IntSize = resume): IntSize
fun TransformState.between(resume: Int, exit: Int, enter: Int = exit, pause: Int = resume): Int

fun TransformState.between(resume: Float, exit: Float, enter: Float = exit, pause: Float = resume): Float

该方法用于计算页面状态变化时各种数值的流转变化

Link copied to clipboard

transform构造方法

Link copied to clipboard
fun expandHorizontally(animationSpec: FiniteAnimationSpec<IntSize> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntSize.VisibilityThreshold ), expandFrom: Alignment.Horizontal = Alignment.End, clip: Boolean = true, initialWidth: (fullWidth: Int) -> Int = { 0 }): EnterTransition
Link copied to clipboard
fun expandIn(animationSpec: FiniteAnimationSpec<IntSize> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntSize.VisibilityThreshold ), expandFrom: Alignment = Alignment.BottomEnd, clip: Boolean = true, initialSize: (fullSize: IntSize) -> IntSize = { IntSize(0, 0) }): EnterTransition
Link copied to clipboard
fun expandVertically(animationSpec: FiniteAnimationSpec<IntSize> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntSize.VisibilityThreshold ), expandFrom: Alignment.Vertical = Alignment.Bottom, clip: Boolean = true, initialHeight: (fullHeight: Int) -> Int = { 0 }): EnterTransition
Link copied to clipboard
fun fadeIn(animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), initialOffset: Float = 0.0f): EnterTransition
Link copied to clipboard
fun fadeOut(animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), targetAlpha: Float = 0.0f): ExitTransition
Link copied to clipboard

modal的页面过渡动画,类ios的modal效果

Link copied to clipboard

没有任何过渡动画和手势

Link copied to clipboard
fun normal(gesture: SimpleGesture = normalSimpleGesture): Transform

普通的页面过渡动画,主要为:页面从右到左进入,上一个页面也是从右到左进入到栈内,但是幅度较小,支持从左到右滑动手势退出。

Link copied to clipboard
fun <T : Any> rememberAnchoredDraggableState(any: Any, initialValue: T, anchors: DraggableAnchors<T>, animationSpec: AnimationSpec<Float> = spring(), positionalThreshold: (distance: Float) -> Float = { it * 0.5f }, velocityThreshold: () -> Float = { 10f }, confirmValueChange: (T) -> Boolean = { true }): AnchoredDraggableState<T>
Link copied to clipboard
fun rememberDraggableModifier(orientation: Orientation = Orientation.Horizontal, reverseDirection: Boolean = false): Modifier

由拖拽手势生成的两个modifier,具体可参考ModalTransformWrapNormalTransformWrap 该方法有一定的局限性,如果需要不同的手势操作请自行实现

Link copied to clipboard
fun rememberDraggableState(orientation: Orientation = Orientation.Horizontal): AnchoredDraggableState<Float>
Link copied to clipboard
Link copied to clipboard
fun scaleIn(animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), initialScale: Float = 0.0f, transformOrigin: TransformOrigin = TransformOrigin.Center): EnterTransition
Link copied to clipboard
fun scaleOut(animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), targetScale: Float = 0.0f, transformOrigin: TransformOrigin = TransformOrigin.Center): ExitTransition
Link copied to clipboard
fun share(vararg keys: Any, animationSpec: FiniteAnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow), shareAnimationSpec: FiniteAnimationSpec<Rect> = spring(visibilityThreshold = Rect.VisibilityThreshold), gesture: SimpleGesture = normalSimpleGesture): Transform

共享元素,当需要使用共享元素动画时,需要使用该transform

Link copied to clipboard

是否应该有手势

Link copied to clipboard
fun shrinkHorizontally(animationSpec: FiniteAnimationSpec<IntSize> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntSize.VisibilityThreshold ), shrinkTowards: Alignment.Horizontal = Alignment.End, clip: Boolean = true, targetWidth: (fullWidth: Int) -> Int = { 0 }): ExitTransition
Link copied to clipboard
fun shrinkOut(animationSpec: FiniteAnimationSpec<IntSize> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntSize.VisibilityThreshold ), shrinkTowards: Alignment = Alignment.BottomEnd, clip: Boolean = true, targetSize: (fullSize: IntSize) -> IntSize = { IntSize(0, 0) }): ExitTransition
Link copied to clipboard
fun shrinkVertically(animationSpec: FiniteAnimationSpec<IntSize> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntSize.VisibilityThreshold ), shrinkTowards: Alignment.Vertical = Alignment.Bottom, clip: Boolean = true, targetHeight: (fullHeight: Int) -> Int = { 0 }): ExitTransition
Link copied to clipboard
fun slideIn(animationSpec: FiniteAnimationSpec<IntOffset> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntOffset.VisibilityThreshold ), initialOffset: (fullSize: IntSize) -> IntOffset): EnterTransition
Link copied to clipboard
fun slideInHorizontally(animationSpec: FiniteAnimationSpec<IntOffset> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntOffset.VisibilityThreshold ), initialOffsetX: (fullWidth: Int) -> Int = { -it / 2 }): EnterTransition
Link copied to clipboard
fun slideInVertically(animationSpec: FiniteAnimationSpec<IntOffset> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntOffset.VisibilityThreshold ), initialOffsetY: (fullHeight: Int) -> Int = { -it / 2 }): EnterTransition
Link copied to clipboard
fun slideOut(animationSpec: FiniteAnimationSpec<IntOffset> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntOffset.VisibilityThreshold ), targetOffset: (fullSize: IntSize) -> IntOffset): ExitTransition
Link copied to clipboard
fun slideOutHorizontally(animationSpec: FiniteAnimationSpec<IntOffset> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntOffset.VisibilityThreshold ), targetOffsetX: (fullWidth: Int) -> Int = { -it / 2 }): ExitTransition
Link copied to clipboard
fun slideOutVertically(animationSpec: FiniteAnimationSpec<IntOffset> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntOffset.VisibilityThreshold ), targetOffsetY: (fullHeight: Int) -> Int = { -it / 2 }): ExitTransition
Link copied to clipboard

更新手势进度