Slide 9
Slide 9 text
usuiat
private class ZoomableNode(): PointerInputModifierNode, DelegatingNode() {
override fun onPointerEvent(
pointerEvent: PointerEvent,
pass: PointerEventPass,
bounds: IntSize
) {
pointerInputNode.onPointerEvent(pointerEvent, pass, bounds)
}
override fun onCancelPointerInput() {
pointerInputNode.onCancelPointerInput()
}
val pointerInputNode = delegate(SuspendingPointerInputModifierNode {
detectTransformGestures(
onGesture = { centroid, pan, zoom ->
coroutineScope.launch {
zoomState.applyGesture(pan, zoom, centroid)
}
},
)
})
}
1) ジェスチャーを検出し、ZoomStateを変更
PointerInputModifierNodeのonPointerEvent()と
onCancelPointerInput()をoverride
pointerInputNodeの処理を呼び出す
SuspendingPointerInputModifierNodeにはPointerInputScopeの
処理を渡せるので、Modifier.pointerInputに書いていた処理を
ほぼそのまま書ける。
pointerInputNodeはSuspendingPointerInputModifierNode
実際の処理はSuspendingPointerInputModifierNodeに
委任する
PointerInputModifierNodeを実装