Package-level declarations

Types

Link copied to clipboard
data object BeforeEnd : ShareState
Link copied to clipboard
data object BeforeStart : ShareState

共享之前,在共享之前,需要显示共享控件,但是原本的控件也不能隐藏

Link copied to clipboard
sealed interface CacheState
Link copied to clipboard
data object ExitShare : ShareState

共享结束

Link copied to clipboard
data object Init : ShareState

无状态,显示原本的控件

Link copied to clipboard
data object NormalCache : CacheState
Link copied to clipboard
class PageCache

页面缓存类,用于记住页面中那些变量。 使用该类构造的remember方法:rememberPrivateInPage,rememberInPage的生命周期长度将处在rememberrememberSaveable之间。

Link copied to clipboard
data object PreShare : ShareState

开始共享

Link copied to clipboard
typealias ShareAnim<T> = (ShareState) -> T
Link copied to clipboard
typealias ShareAnimBody<T> = @Composable ShareAnim<T>.() -> State<T>
Link copied to clipboard
sealed interface ShareState

定义共享控件的状态

Link copied to clipboard
data class Sharing(val progress: Float) : ShareState

sharing 手势触发时,将由手势控制共享的过程,progress则是手势的进度, 目前手势只能控制后退时的共享元素变化

Link copied to clipboard
typealias UpdateElementListener = (Array<out Any>) -> Unit

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun <T : Any> PageCache.cache(key: String, state: CacheState = NormalCache, block: () -> T): T
Link copied to clipboard

通过点击清除焦点,以达到收起软键盘的效果

Link copied to clipboard
fun onUpdateElement(block: (Array<out Any>) -> Unit)

正在更新元素,当调用updateElement方法时,共享元素控制器就会在已有的共享元素中查找新的用来实现动画的元素,如果找不到则会触发该回调,用户需要在原有界面准备新元素,以便更新共享元素

Link copied to clipboard
fun Page(modifier: Modifier = Modifier.background(Color.White), block: @Composable PageScope.() -> Unit)

用于定义一个composable为页面

Link copied to clipboard
inline fun <T : Any> rememberInPage(key: String, noinline calculation: @DisallowComposableCalls () -> T): T

该系列方法的用法和remember一样,不同的是该方法所保存的变量的生命周期会比remember保存的要长,和当前界面的一样长 需要注意的是,

inline fun <T : Any> rememberInPage(key: String, key1: Any?, noinline calculation: @DisallowComposableCalls () -> T): T
fun <T : Any> rememberInPage(key: String, vararg inputs: Any?, calculation: @DisallowComposableCalls () -> T): T
inline fun <T : Any> rememberInPage(key: String, key1: Any?, key2: Any?, noinline calculation: @DisallowComposableCalls () -> T): T
inline fun <T : Any> rememberInPage(key: String, key1: Any?, key2: Any?, key3: Any?, noinline calculation: @DisallowComposableCalls () -> T): T
Link copied to clipboard
suspend fun LifecycleOwner.repeatOnLifecycle(state: Lifecycle.State, block: suspend CoroutineScope.() -> Unit)
Link copied to clipboard
fun sharing(sharing: Sharing, pre: Offset, current: Offset): Offset
fun sharing(sharing: Sharing, pre: Rect, current: Rect): Rect
fun sharing(sharing: Sharing, pre: Size, current: Size): Size
fun sharing(sharing: Sharing, pre: Color, current: Color): Color
fun sharing(sharing: Sharing, pre: Dp, current: Dp): Dp
fun sharing(sharing: Sharing, pre: DpOffset, current: DpOffset): DpOffset
fun sharing(sharing: Sharing, pre: DpSize, current: DpSize): DpSize
fun sharing(sharing: Sharing, pre: IntOffset, current: IntOffset): IntOffset
fun sharing(sharing: Sharing, pre: IntSize, current: IntSize): IntSize
fun sharing(sharing: Sharing, pre: Float, current: Float): Float
fun sharing(sharing: Sharing, pre: Int, current: Int): Int
Link copied to clipboard
fun updateElement(vararg keys: Any)

更新元素,在使用共享元素动画跳转到目标页面之后,可以通过该方法更新共享的元素,(必须是原页面和当前界面都有的元素),那么在退出的时候,就可以使用新的共享元素实现动画。 重申一遍,必须要在当前界面存在该元素时,才可更新,如果原页面不存在该元素,则会通过onUpdateElement进行通知,如果更新失败,那么将按照原共享元素执行。

Link copied to clipboard
fun <T> updateValue(preValue: T, currentValue: T, nextValue: T, sharing: Sharing.(preValue: T, currentValue: T) -> T = { _, current -> current }, anim: @Composable (function: (ShareState) -> T) -> State<T>): State<T>