Package-level declarations

Types

Link copied to clipboard
class ComposeModel(content: @Composable ComposeModel.() -> Unit = {})

viewer传入的Compose数据类型参数

Link copied to clipboard
class ImageViewerState(offsetX: Float = DEFAULT_OFFSET_X, offsetY: Float = DEFAULT_OFFSET_Y, scale: Float = DEFAULT_SCALE, rotation: Float = DEFAULT_ROTATION, animationSpec: AnimationSpec<Float>? = null, crossfadeAnimationSpec: AnimationSpec<Float>? = null) : CoroutineScope

viewer状态对象,用于记录compose组件状态

Link copied to clipboard
class RawGesture(val onTap: (Offset) -> Unit = {}, val onDoubleTap: (Offset) -> Unit = {}, val onLongPress: (Offset) -> Unit = {}, val gestureStart: () -> Unit = {}, val gestureEnd: (transformOnly: Boolean) -> Unit = {}, val onGesture: (centroid: Offset, pan: Offset, zoom: Float, rotation: Float, event: PointerEvent) -> Boolean = { _, _, _, _, _ -> true })
Link copied to clipboard
data class SizeChangeContent(val defaultSize: IntSize, val containerSize: IntSize, val maxScale: Float)
Link copied to clipboard
class ViewerGestureScope(var onTap: (Offset) -> Unit = {}, var onDoubleTap: (Offset) -> Unit = {}, var onLongPress: (Offset) -> Unit = {})

viewer手势对象

Properties

Link copied to clipboard
Link copied to clipboard
const val DEFAULT_OFFSET_X: Float = 0.0f
Link copied to clipboard
const val DEFAULT_OFFSET_Y: Float = 0.0f
Link copied to clipboard
const val DEFAULT_ROTATION: Float = 0.0f
Link copied to clipboard
const val DEFAULT_SCALE: Float = 1.0f
Link copied to clipboard
const val MAX_SCALE_RATE: Float = 3.2f
Link copied to clipboard
Link copied to clipboard
const val MIN_SCALE: Float = 0.5f

Functions

Link copied to clipboard
fun calcLeftSize(bSize: Float, rSize: Float, offset: Float): Float
Link copied to clipboard
suspend fun PointerInputScope.detectTransformGestures(panZoomLock: Boolean = false, gestureStart: () -> Unit = {}, gestureEnd: (Boolean) -> Unit = {}, onTap: (Offset) -> Unit = {}, onDoubleTap: (Offset) -> Unit = {}, onGesture: (centroid: Offset, pan: Offset, zoom: Float, rotation: Float, event: PointerEvent) -> Boolean)

重写事件监听方法

Link copied to clipboard
fun getBound(rw: Float, bw: Float): Float

获取移动边界

Link copied to clipboard
fun getRectDelta(delta: Float, rSize: Float, bSize: Float, offset: Float): Float
Link copied to clipboard
fun ImageComposeCanvas(modifier: Modifier = Modifier, samplingDecoder: SamplingDecoder, scale: Float = DEFAULT_SCALE, offsetX: Float = DEFAULT_OFFSET_X, offsetY: Float = DEFAULT_OFFSET_Y, rotation: Float = DEFAULT_ROTATION, gesture: RawGesture = RawGesture(), onMounted: () -> Unit = {}, onSizeChange: suspend (SizeChangeContent) -> Unit = {}, crossfadeAnimationSpec: AnimationSpec<Float> = DEFAULT_CROSS_FADE_ANIMATE_SPEC, boundClip: Boolean = true, debugMode: Boolean = false)
Link copied to clipboard
fun ImageComposeOrigin(modifier: Modifier = Modifier, model: Any, scale: Float = DEFAULT_SCALE, offsetX: Float = DEFAULT_OFFSET_X, offsetY: Float = DEFAULT_OFFSET_Y, rotation: Float = DEFAULT_ROTATION, gesture: RawGesture = RawGesture(), onMounted: () -> Unit = {}, onSizeChange: suspend (SizeChangeContent) -> Unit = {}, crossfadeAnimationSpec: AnimationSpec<Float> = DEFAULT_CROSS_FADE_ANIMATE_SPEC, boundClip: Boolean = true)
Link copied to clipboard
fun ImageViewer(modifier: Modifier = Modifier, model: Any?, state: ImageViewerState = rememberViewerState(), detectGesture: ViewerGestureScope.() -> Unit = {}, boundClip: Boolean = true, debugMode: Boolean = false)

model支持Painter、ImageBitmap、ImageVector、SamplingDecoder、ComposeModel

Link copied to clipboard
fun inBound(offset: Float, bound: Float): Boolean

判断位移是否在边界内

Link copied to clipboard
fun limitToBound(offset: Float, bound: Float): Float

把位移限制在边界内

Link copied to clipboard
fun rememberViewerState(offsetX: Float = DEFAULT_OFFSET_X, offsetY: Float = DEFAULT_OFFSET_Y, scale: Float = DEFAULT_SCALE, rotation: Float = DEFAULT_ROTATION, animationSpec: AnimationSpec<Float>? = null, crossfadeAnimationSpec: AnimationSpec<Float>? = null): ImageViewerState

记录viewer状态

Link copied to clipboard

让后一个数与前一个数的符号保持一致