3

I'm displaying a Box which contains a tree structure in Compose Multiplatform.

Now I wanted to scale the Box so the user can zoom and scroll to the important section of the tree

Scroll is no Problem, but I have no Idea how to implement a zoom function

@Composable
fun GraphView(model: DisplayTabModel, state: DisplayState){
    val scale = remember { mutableStateOf(1f) }
    Box(modifier = Modifier
        .background(AppTheme.colors.material.background)
        .fillMaxHeight()
        .verticalScroll(rememberScrollState())
        .horizontalScroll(rememberScrollState())
        .scale(scale.value)
        .pointerInput(Unit) {
            detectTransformGestures { _, _, zoom, _ ->
                scale.value *= zoom
            }
        }
    ) {
        renderGraph(model, state)
    }
}

I've found a solution with detectTransformGestures() but I guess this works only on touch devices, as is won't work for me on my desktop/mac

Is there another solution to this so I can use something like control+scroll to zoom?

I mean the last resort would be a slider somewhere, but that's not really a good solution for me...

c_phil
  • 123
  • 6

0 Answers0