Skip to content

Commit

Permalink
Merge pull request #2 from mobiledevpro/prepare-the-project
Browse files Browse the repository at this point in the history
Rotate
  • Loading branch information
dmitriy-chernysh authored Mar 21, 2024
2 parents 7657328 + b3eca8d commit 7527ef3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
Binary file removed doc/modularization.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,8 @@ fun ImageViewerScreen() {
fun BoxScope.UpperImage() {
var imageScale by remember { mutableFloatStateOf(1f) }
var imageOffset by remember { mutableStateOf(Offset.Zero) }
var rotation by remember { mutableFloatStateOf(0f) }

val transformState = rememberTransformableState { zoomChange, panChange, rotationChange ->
imageScale = (imageScale * zoomChange).coerceIn(1f, 5f)
imageOffset += panChange
}

val model = ImageRequest.Builder(LocalContext.current)
.data("https://c4.wallpaperflare.com/wallpaper/83/500/871/waterfall-high-resolution-desktop-wallpaper-preview.jpg")
Expand All @@ -121,30 +118,34 @@ fun BoxScope.UpperImage() {
.diskCachePolicy(CachePolicy.DISABLED)
.build()

val transformState = rememberTransformableState { zoomChange, panChange, rotationChange ->
imageScale = (imageScale * zoomChange).coerceIn(0.5f, 5f)
imageOffset += panChange
rotation += rotationChange
}

AsyncImage(
model = model,
contentDescription = "",
contentScale = ContentScale.FillHeight,
onState = { state ->
Log.d("UI", "AsyncImage.state: $state")
},
modifier = Modifier
.align(Alignment.Center)
.fillMaxWidth()
.scale(imageScale)
.graphicsLayer {
Log.d("UI", "ImageViewerScreen: graphicsLayer: scale $scaleX $scaleY")
scaleX = imageScale
scaleY = imageScale
translationX = imageOffset.x
translationY = imageOffset.y
rotationZ = rotation
}
.transformable(transformState)
.pointerInput(Unit) {
detectTapGestures(onDoubleTap = {
Log.d("UI", "ImageViewerScreen: on double tap")
imageScale = 1f
imageOffset = Offset.Zero
rotation = 0F
})
}
)
Expand All @@ -154,10 +155,12 @@ fun BoxScope.UpperImage() {
fun BoxScope.LowerImage() {
var imageScale by remember { mutableFloatStateOf(1f) }
var imageOffset by remember { mutableStateOf(Offset.Zero) }
var rotation by remember { mutableFloatStateOf(0f) }

val transformState = rememberTransformableState { zoomChange, panChange, rotationChange ->
imageScale = (imageScale * zoomChange).coerceIn(1f, 5f)
imageScale = (imageScale * zoomChange).coerceIn(0.5f, 5f)
imageOffset += panChange
rotation += rotationChange
}

val model = ImageRequest.Builder(LocalContext.current)
Expand All @@ -180,18 +183,19 @@ fun BoxScope.LowerImage() {
.fillMaxWidth()
.scale(imageScale)
.graphicsLayer {
Log.d("UI", "ImageViewerScreen: graphicsLayer: scale $scaleX $scaleY")
scaleX = imageScale
scaleY = imageScale
translationX = imageOffset.x
translationY = imageOffset.y
rotationZ = rotation
}
.transformable(transformState)
.pointerInput(Unit) {
detectTapGestures(onDoubleTap = {
Log.d("UI", "ImageViewerScreen: on double tap")
imageScale = 1f
imageOffset = Offset.Zero
rotation = 0F
})
}
)
Expand Down
28 changes: 0 additions & 28 deletions maestro/people-profile-flow.yaml

This file was deleted.

0 comments on commit 7527ef3

Please sign in to comment.