Capture: fix truncated display of narrow documents

This commit is contained in:
Pierre-Yves Nicolas
2025-06-26 07:30:53 +02:00
parent 3f582e12c0
commit b9cb072be8

View File

@@ -32,6 +32,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
@@ -216,15 +217,15 @@ private fun CapturedImage(cameraUiState: CameraUiState, thumbnailCoords: Mutable
label = "scale" label = "scale"
) { if (it) 0.3f else 1f } ) { if (it) 0.3f else 1f }
val justABitToTheTop = 100.dp
Box (modifier = Modifier Box (modifier = Modifier
.fillMaxHeight(0.8f)
.onGloballyPositioned { coordinates -> .onGloballyPositioned { coordinates ->
val bounds = coordinates.boundsInWindow() val bounds = coordinates.boundsInWindow()
val centerX = bounds.left + bounds.width / 2 val centerX = bounds.left + bounds.width / 2
val centerY = bounds.top + bounds.height / 2 val centerY = bounds.top + bounds.height / 2
with(density) { with(density) {
targetOffsetX = thumbnailCoords.value.x - centerX targetOffsetX = thumbnailCoords.value.x - centerX
targetOffsetY = thumbnailCoords.value.y - centerY + justABitToTheTop.toPx() targetOffsetY = thumbnailCoords.value.y - centerY
} }
} }
) { ) {
@@ -236,7 +237,7 @@ private fun CapturedImage(cameraUiState: CameraUiState, thumbnailCoords: Mutable
.padding(24.dp) .padding(24.dp)
.graphicsLayer { .graphicsLayer {
translationX = offsetX translationX = offsetX
translationY = offsetY - justABitToTheTop.toPx() translationY = offsetY
scaleX = scale scaleX = scale
scaleY = scale scaleY = scale
} }