1+ @file:OptIn(ExperimentalAnimationApi ::class )
2+
13package com.smarttoolfactory.cropper
24
5+ import androidx.compose.animation.AnimatedVisibility
6+ import androidx.compose.animation.ExperimentalAnimationApi
7+ import androidx.compose.animation.core.tween
8+ import androidx.compose.animation.scaleIn
9+ import androidx.compose.foundation.background
310import androidx.compose.foundation.layout.Box
11+ import androidx.compose.foundation.layout.fillMaxSize
412import androidx.compose.foundation.layout.size
5- import androidx.compose.material3.Text
6- import androidx.compose.runtime.Composable
7- import androidx.compose.runtime.LaunchedEffect
8- import androidx.compose.runtime.remember
13+ import androidx.compose.runtime.*
914import androidx.compose.ui.Alignment
1015import androidx.compose.ui.Modifier
1116import androidx.compose.ui.draw.clipToBounds
@@ -18,7 +23,6 @@ import androidx.compose.ui.platform.LocalDensity
1823import androidx.compose.ui.platform.LocalLayoutDirection
1924import androidx.compose.ui.unit.Dp
2025import androidx.compose.ui.unit.IntSize
21- import androidx.compose.ui.unit.sp
2226import com.smarttoolfactory.cropper.crop.CropAgent
2327import com.smarttoolfactory.cropper.draw.DrawingOverlay
2428import com.smarttoolfactory.cropper.draw.ImageDrawCanvas
@@ -135,11 +139,6 @@ fun ImageCropper(
135139 */
136140 val rectCrop = cropState.cropRect
137141
138- val drawAreaRect = cropState.drawAreaRect
139-
140- val pan = cropState.pan
141- val zoom = cropState.zoom
142-
143142 val density = LocalDensity .current
144143 val layoutDirection = LocalLayoutDirection .current
145144
@@ -175,33 +174,54 @@ fun ImageCropper(
175174 cropState = cropState
176175 )
177176
178- Box {
179- ImageCropperImpl (
180- modifier = imageModifier,
181- imageBitmap = scaledImageBitmap,
182- containerWidth = containerWidth,
183- containerHeight = containerHeight,
184- imageWidthPx = imageWidthPx,
185- imageHeightPx = imageHeightPx,
186- cropType = cropType,
187- cropOutline = cropOutline,
188- handleSize = cropProperties.handleSize,
189- cropStyle = cropStyle,
190- rectOverlay = cropState.overlayRect
191- )
177+ Box (modifier = Modifier
178+ .fillMaxSize()
179+ .background(Color .Black )
180+ ) {
181+
182+ // / Create a MutableTransitionState<Boolean> for the AnimatedVisibility.
183+ var visible by remember { mutableStateOf(false ) }
192184
185+ LaunchedEffect (Unit ) {
186+ delay(100 )
187+ visible = true
188+ }
189+
190+ AnimatedVisibility (
191+ visible = visible,
192+ enter = scaleIn(tween(500 ))
193+ ) {
194+
195+ ImageCropperImpl (
196+ modifier = imageModifier,
197+ imageBitmap = scaledImageBitmap,
198+ containerWidth = containerWidth,
199+ containerHeight = containerHeight,
200+ imageWidthPx = imageWidthPx,
201+ imageHeightPx = imageHeightPx,
202+ cropType = cropType,
203+ cropOutline = cropOutline,
204+ handleSize = cropProperties.handleSize,
205+ cropStyle = cropStyle,
206+ rectOverlay = cropState.overlayRect
207+ )
208+ }
209+
193210 // TODO Remove this text when cropper is complete. This is for debugging
194- Text (
195- modifier = Modifier .align(Alignment .TopStart ),
196- color = Color .White ,
197- fontSize = 10 .sp,
198- text = " imageWidthInPx: $imageWidthPx , imageHeightInPx: $imageHeightPx \n " +
199- " bitmapWidth: $bitmapWidth , bitmapHeight: $bitmapHeight \n " +
200- " zoom: $zoom , pan: $pan \n " +
201- " drawAreaRect: $drawAreaRect , size: ${drawAreaRect.size} \n " +
202- " overlayRect: ${cropState.overlayRect} , size: ${cropState.overlayRect.size} \n " +
203- " cropRect: $rectCrop , size: ${rectCrop.size} "
204- )
211+ // val drawAreaRect = cropState.drawAreaRect
212+ // val pan = cropState.pan
213+ // val zoom = cropState.zoom
214+ // Text(
215+ // modifier = Modifier.align(Alignment.TopStart),
216+ // color = Color.White,
217+ // fontSize = 10.sp,
218+ // text = "imageWidthInPx: $imageWidthPx, imageHeightInPx: $imageHeightPx\n" +
219+ // "bitmapWidth: $bitmapWidth, bitmapHeight: $bitmapHeight\n" +
220+ // "zoom: $zoom, pan: $pan\n" +
221+ // "drawAreaRect: $drawAreaRect, size: ${drawAreaRect.size}\n" +
222+ // "overlayRect: ${cropState.overlayRect}, size: ${cropState.overlayRect.size}\n" +
223+ // "cropRect: $rectCrop, size: ${rectCrop.size}"
224+ // )
205225 }
206226 }
207227}
0 commit comments