Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard

基于稳定 key 的插入式排序,直接用于现有 Lazy 容器,不持有业务列表。

Properties

Link copied to clipboard

默认提供拖动态的状态层和抬升阴影。 通常无需设置;可通过 CompositionLocalProvider 覆盖样式,返回 Modifier 可关闭默认效果。 样式不应改变 item 的测量尺寸或位置,位移和回落动画由排序容器管理。

Functions

Link copied to clipboard
fun rememberReorderingState(state: LazyListState, onSettle: (from: Int, to: Int) -> Unit = { _, _ -> }, onMove: (from: Int, to: Int) -> Unit): ReorderingState
fun rememberReorderingState(state: LazyGridState, onSettle: (from: Int, to: Int) -> Unit = { _, _ -> }, onMove: (from: Int, to: Int) -> Unit): ReorderingState
fun rememberReorderingState(state: LazyStaggeredGridState, onSettle: (from: Int, to: Int) -> Unit = { _, _ -> }, onMove: (from: Int, to: Int) -> Unit): ReorderingState
Link copied to clipboard
fun <T> ReorderingColumn(list: List<T>, key: (T) -> Any, onSettle: (from: Int, to: Int) -> Unit, modifier: Modifier = Modifier, verticalArrangement: Arrangement.Vertical = Arrangement.Top, horizontalAlignment: Alignment.Horizontal = Alignment.Start, content: @Composable ReorderingItemScope.(item: T, isDragging: Boolean) -> Unit)

少量条目的非滚动 Column,可嵌入已有滚动页面。拖动期间只更新内部预览,回落动画结束后 onSettle 按原始列表索引提交一次;若回落中开始下一次拖动,会先提交上一手势。 调用方同步移动 list 中的元素即可。key 必须唯一且稳定。 拖动范围限制在容器内部,绘制内容也按容器边界裁剪。 默认激活样式由框架提供,可通过 LocalReorderingItemStyle 覆盖。

Link copied to clipboard
fun LazyItemScope.ReorderingItem(state: ReorderingState, key: Any, modifier: Modifier = Modifier, enabled: Boolean = true, content: @Composable ReorderingItemScope.(isDragging: Boolean) -> Unit)

包裹一个 Lazy item,key 必须与 items 的 key 相同。普通项使用容器的 animateItem 动画, 拖动项浮到最上层并跟随指针,松手后以弹簧动画回落。enabled 为 false 时不能作为移动目标, 但插入操作仍可能改变它的索引;不包裹的 header/footer 同样不能作为目标。 默认由框架绘制拖动态的状态层和阴影;可通过 LocalReorderingItemStyle 覆盖样式。

fun LazyGridItemScope.ReorderingItem(state: ReorderingState, key: Any, modifier: Modifier = Modifier, enabled: Boolean = true, content: @Composable ReorderingItemScope.(isDragging: Boolean) -> Unit)

用于 LazyVerticalGrid / LazyHorizontalGrid,约定与 ReorderingState 相同。

fun LazyStaggeredGridItemScope.ReorderingItem(state: ReorderingState, key: Any, modifier: Modifier = Modifier, enabled: Boolean = true, content: @Composable ReorderingItemScope.(isDragging: Boolean) -> Unit)

用于 LazyVerticalStaggeredGrid / LazyHorizontalStaggeredGrid。

Link copied to clipboard
fun reorderingItemStyle(isDragging: Boolean, shape: Shape = Theme.shape.v8): Modifier
Link copied to clipboard
fun <T> ReorderingRow(list: List<T>, key: (T) -> Any, onSettle: (from: Int, to: Int) -> Unit, modifier: Modifier = Modifier, horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, verticalAlignment: Alignment.Vertical = Alignment.Top, content: @Composable ReorderingItemScope.(item: T, isDragging: Boolean) -> Unit)

少量条目的非滚动 Row,拖柄沿水平方向移动,支持 RTL 和不同条目宽度。 与 ReorderingColumn 相同,拖动期间只更新内部预览,回落后以原始列表索引提交一次 onSettle。 回落中可以继续拖动,下一手势开始前会先提交上一手势,不丢失已经完成的移动。 可通过 modifier 接入 horizontalScroll,普通 Row 自身不执行边缘自动滚动。 拖动范围限制在 Row 的内容边界内部,绘制内容也按边界裁剪。 默认激活样式由框架提供,可通过 LocalReorderingItemStyle 覆盖。