bryankeltonadams
10/06/2023, 10:29 PMenum class DragValue { Start, Center, End }
@Composable
fun AnchoredDraggableBox() {
val anchors = DraggableAnchors {
Start at -100.dp.toPx()
Center at 0f
End at 100.dp.toPx()
}
val state = remember {
AnchoredDraggableState(anchors = anchors)
}
Box(
Modifier.offset { IntOffset(x = state.requireOffset(), y = 0) }
)
}
but toPx() isn't an extension function for me.* Drawing and Layout are done in pixels. To retrieve the pixel size of a Dp, use [Density.toPx]:
but I don't see any functions declared in this file for toPxMahmoo
10/06/2023, 10:44 PMPablichjenkov
10/06/2023, 10:48 PMascii
10/07/2023, 12:07 AMLocalDensity.current.run { 100.dp.toPx() }
ephemient
10/07/2023, 12:38 AMwith(LocalDensity.current) { 100.dp.toPx() }
than .run {}
IMODensity
, e.g. DrawScope
, MeasureScope
, PointerInputScope
, etc.