Compose Modifier

magnifier

Shows a [Magnifier] widget that shows an enlarged version of the content at [sourceCenter] relative to the current layout node.

MagnifierSample

@Composable
fun MagnifierSample() {
    // When the magnifier center position is Unspecified, it is hidden.
    // Hide the magnifier until a drag starts.
    var magnifierCenter by remember { mutableStateOf(Offset.Unspecified) }
    if (Build.VERSION.SDK_INT < 28) {
        Text("Magnifier is not supported on this platform.")
    } else {
        Box(
            Modifier.magnifier(sourceCenter = { magnifierCenter }, zoom = 2f)
                .pointerInput(Unit) {
                    detectDragGestures(
                        // Show the magnifier at the original pointer position.
                        onDragStart = { magnifierCenter = it },
                        // Make the magnifier follow the finger while dragging.
                        onDrag = { _, delta -> magnifierCenter += delta },
                        // Hide the magnifier when the finger lifts.
                        onDragEnd = { magnifierCenter = Offset.Unspecified },
                        onDragCancel = { magnifierCenter = Offset.Unspecified },
                    )
                }
                .drawBehind {
                    // Some concentric circles to zoom in on.
                    for (diameter in 2 until size.maxDimension.toInt() step 10) {
                        drawCircle(color = Color.Black, radius = diameter / 2f, style = Stroke())
                    }
                }
        )
    }
}