Let's say that I have the following custom modifier:
fun Modifier.moveable(): Modifier = composed {
var initialDragOffset: Offset by remember { mutableStateOf(Offset.Zero) }
var dragOffset: Offset? by remember { mutableStateOf(null) }
this
.pointerInput(Unit) {
this.detectDragGestures(
onDragStart = { initialDragOffset = it },
onDragEnd = { dragOffset = null },
onDragCancel = { dragOffset = null }
) { changes, _ -> dragOffset = changes.position }
}
.graphicsLayer {
if (dragOffset != null) {
translationX = dragOffset!!.x - initialDragOffset.x
translationY = dragOffset!!.y - initialDragOffset.y
alpha = 0.7f
}
}
}
(This is a simplified version of my modifier).
This is a simple case of a modifier (here pointerInput
) that outputs data which is then consumed by another modifier (here graphicsLayer
).
How do I port this from composed
to Modifier.Node
?
How do I delegate to two other modifiers with a shared state using this new Node optimized API?