jaqxues
03/14/2021, 5:27 PMjaqxues
03/14/2021, 5:32 PMjaqxues
03/14/2021, 5:33 PMAdam Powell
03/14/2021, 5:39 PMjaqxues
03/14/2021, 5:43 PM@Composable
fun BoxScope.StaticImage(url: String) {
var scale by remember { mutableStateOf(1f) }
var offset by remember { mutableStateOf(Offset.Zero) }
val transformableState = rememberTransformableState { zoomChange, panChange, _ ->
scale = (scale * zoomChange).coerceIn(1f, 10f)
offset += panChange
}
val scope = rememberCoroutineScope()
GlideImage(
url,
null,
Modifier
.scale(scale)
.offset {
IntOffset(offset.x.roundToInt(), offset.y.roundToInt())
}
.pointerInput(Unit) {
detectTapGestures(onDoubleTap = {
scope.launch { transformableState.animateZoomBy(3f) }
})
}
.pointerInput(Unit) {
detectDragGestures { _, dragAmount ->
offset += dragAmount
}
}
.transformable(transformableState),
fadeIn = true,
loading = {
CircularProgressIndicator()
}
)
DownloadButton(...)
}
Adam Powell
03/14/2021, 5:50 PM.onSizeChanged {}
to determine the size of an element, and use that recorded size to constrain positioningAdam Powell
03/14/2021, 6:18 PMModifier.layout {}
to do the sizing and positioning in one place insteadTlaster
03/15/2021, 12:55 AMTornike Kikalishvili
09/17/2021, 10:54 AMTlaster
09/17/2021, 11:12 AMTornike Kikalishvili
09/17/2021, 11:14 AM