Skip to content

Commit 271b350

Browse files
update EnhancedZoomModifier callbacks
1 parent 7199fb4 commit 271b350

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

image/src/main/java/com/smarttoolfactory/image/zoom/EnhancedZoomModifier.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,28 @@ import com.smarttoolfactory.image.util.update
1111
import kotlinx.coroutines.launch
1212

1313
fun Modifier.enhancedZoom(
14-
vararg keys: Any?,
15-
touchRegionSize: Float,
16-
minDimension: Float,
1714
enhancedZoomState: EnhancedZoomState,
18-
onDown: (EnhancedZoomData) -> Unit,
19-
onMove: (EnhancedZoomData) -> Unit,
20-
onUp: (EnhancedZoomData) -> Unit,
15+
key: Any? = Unit,
16+
onDown: ((EnhancedZoomData) -> Unit)? = null,
17+
onMove: ((EnhancedZoomData) -> Unit)? = null,
18+
onUp: ((EnhancedZoomData) -> Unit)? = null,
2119
) = composed(
2220

2321
factory = {
2422

2523
val coroutineScope = rememberCoroutineScope()
2624

27-
val transformModifier = Modifier.pointerInput(keys) {
25+
val transformModifier = Modifier.pointerInput(key) {
2826

2927
detectTransformGestures(
3028
consume = true,
3129
onGestureStart = {
32-
onDown(enhancedZoomState.enhancedZoomData)
30+
onDown?.invoke(enhancedZoomState.enhancedZoomData)
3331
},
3432
onGestureEnd = {
3533
coroutineScope.launch {
3634
enhancedZoomState.onGestureEnd {
37-
onUp(enhancedZoomState.enhancedZoomData)
35+
onUp?.invoke(enhancedZoomState.enhancedZoomData)
3836
}
3937
}
4038
},
@@ -51,17 +49,17 @@ fun Modifier.enhancedZoom(
5149
)
5250
}
5351

54-
onMove(enhancedZoomState.enhancedZoomData)
52+
onMove?.invoke(enhancedZoomState.enhancedZoomData)
5553
}
5654
)
5755
}
5856

59-
val tapModifier = Modifier.pointerInput(keys) {
57+
val tapModifier = Modifier.pointerInput(key) {
6058
detectTapGestures(
6159
onDoubleTap = {
6260
coroutineScope.launch {
6361
enhancedZoomState.onDoubleTap {
64-
onUp(enhancedZoomState.enhancedZoomData)
62+
onUp?.invoke(enhancedZoomState.enhancedZoomData)
6563
}
6664
}
6765
}
@@ -82,8 +80,6 @@ fun Modifier.enhancedZoom(
8280
inspectorInfo = {
8381
name = "enhancedZoom"
8482
// add name and value of each argument
85-
properties["touchRegionRadius"] = touchRegionSize
86-
properties["minDimension"] = minDimension
8783
properties["onDown"] = onDown
8884
properties["onMove"] = onMove
8985
properties["onUp"] = onUp

0 commit comments

Comments
 (0)