From afd94604adf254a521daa25a500fed9e282790e1 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 23 Jul 2026 15:03:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(photo-editor):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=A4=96=E5=B1=82=20Card=20=E6=9C=AA=E6=8C=89=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=AF=94=E4=BE=8B=E8=87=AA=E9=80=82=E5=BA=94=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E4=B8=8A=E4=B8=8B=E9=BB=91=E8=BE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plus/rua/project/ui/PhotoEditorScreen.kt | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/core/src/main/kotlin/plus/rua/project/ui/PhotoEditorScreen.kt b/core/src/main/kotlin/plus/rua/project/ui/PhotoEditorScreen.kt index 6ffb187..15a0958 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/PhotoEditorScreen.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/PhotoEditorScreen.kt @@ -276,25 +276,29 @@ private fun EditorBody( .padding(16.dp), contentAlignment = Alignment.Center ) { + val srcAspect = state.sourceBitmap.width.toFloat() / state.sourceBitmap.height.toFloat() + val containerAspect by animateFloatAsState( + targetValue = RotationGeometry.stableAspect(srcAspect, state.rotationDegrees), + animationSpec = tween(durationMillis = 300, easing = FastOutSlowInEasing), + label = "rotateAspect" + ) + Card( shape = RoundedCornerShape(20.dp), colors = CardDefaults.cardColors(containerColor = Color.Black), border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant.copy(alpha = 0.5f)), - elevation = CardDefaults.cardElevation(defaultElevation = 4.dp) + elevation = CardDefaults.cardElevation(defaultElevation = 4.dp), + modifier = Modifier.aspectRatio(containerAspect) ) { - Box( - modifier = Modifier.fillMaxSize(), - contentAlignment = Alignment.Center - ) { - EditableImage( - state = state, - mode = activeTab, - onCropChange = onCropChange, - onAddPoint = onAddPoint, - onEndStroke = onEndStroke, - onDisplaySizeChange = onDisplaySizeChange - ) - } + EditableImage( + state = state, + mode = activeTab, + containerAspect = containerAspect, + onCropChange = onCropChange, + onAddPoint = onAddPoint, + onEndStroke = onEndStroke, + onDisplaySizeChange = onDisplaySizeChange + ) } if (saving) { @@ -345,11 +349,11 @@ private fun EditorBody( } } } - @Composable private fun EditableImage( state: PhotoEditorState, mode: EditTab, + containerAspect: Float, onCropChange: (Float, Float, Float, Float) -> Unit, onAddPoint: (Offset) -> Unit, onEndStroke: () -> Unit, @@ -365,17 +369,9 @@ private fun EditableImage( ) } - val srcAspect = state.sourceBitmap.width.toFloat() / state.sourceBitmap.height.toFloat() - val containerAspect by animateFloatAsState( - targetValue = RotationGeometry.stableAspect(srcAspect, state.rotationDegrees), - animationSpec = tween(durationMillis = 300, easing = FastOutSlowInEasing), - label = "rotateAspect" - ) - Box( modifier = Modifier - .fillMaxWidth() - .aspectRatio(containerAspect) + .fillMaxSize() .background(Color.Black) .onSizeChanged { size -> if (size.width > 0 && size.height > 0) {