Skip to content

Commit e3164c4

Browse files
committed
Restore event builders
1 parent a2048fe commit e3164c4

9 files changed

Lines changed: 107 additions & 40 deletions

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/FlingGestureHandlerEventDataBuilder.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ import com.swmansion.gesturehandler.core.FlingGestureHandler
66

77
class FlingGestureHandlerEventDataBuilder(handler: FlingGestureHandler) :
88
GestureHandlerEventDataBuilder<FlingGestureHandler>(handler) {
9-
private val x: Float = handler.lastRelativePositionX
10-
private val y: Float = handler.lastRelativePositionY
11-
private val absoluteX: Float = handler.lastPositionInWindowX
12-
private val absoluteY: Float = handler.lastPositionInWindowY
9+
private val x: Float
10+
private val y: Float
11+
private val absoluteX: Float
12+
private val absoluteY: Float
13+
14+
init {
15+
x = handler.lastRelativePositionX
16+
y = handler.lastRelativePositionY
17+
absoluteX = handler.lastPositionInWindowX
18+
absoluteY = handler.lastPositionInWindowY
19+
}
1320

1421
override fun buildEventData(eventData: WritableMap) {
1522
super.buildEventData(eventData)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/GestureHandlerEventDataBuilder.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ import com.facebook.react.bridge.WritableMap
44
import com.swmansion.gesturehandler.core.GestureHandler
55

66
abstract class GestureHandlerEventDataBuilder<T : GestureHandler>(handler: T) {
7-
public val handlerTag: Int = handler.tag
8-
public val state: Int = handler.state
9-
private val pointerType: Int = handler.pointerType
10-
private val numberOfPointers: Int = handler.numberOfPointers
7+
val handlerTag: Int
8+
val state: Int
9+
private val numberOfPointers: Int
10+
private val pointerType: Int
11+
12+
init {
13+
numberOfPointers = handler.numberOfPointers
14+
handlerTag = handler.tag
15+
state = handler.state
16+
pointerType = handler.pointerType
17+
}
1118

1219
open fun buildEventData(eventData: WritableMap) {
1320
eventData.putInt("numberOfPointers", numberOfPointers)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/HoverGestureHandlerEventDataBuilder.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ import com.swmansion.gesturehandler.core.StylusData
77

88
class HoverGestureHandlerEventDataBuilder(handler: HoverGestureHandler) :
99
GestureHandlerEventDataBuilder<HoverGestureHandler>(handler) {
10-
private val x: Float = handler.lastRelativePositionX
11-
private val y: Float = handler.lastRelativePositionY
12-
private val absoluteX: Float = handler.lastPositionInWindowX
13-
private val absoluteY: Float = handler.lastPositionInWindowY
14-
private val stylusData: StylusData = handler.stylusData
10+
private val x: Float
11+
private val y: Float
12+
private val absoluteX: Float
13+
private val absoluteY: Float
14+
private val stylusData: StylusData
15+
16+
init {
17+
x = handler.lastRelativePositionX
18+
y = handler.lastRelativePositionY
19+
absoluteX = handler.lastPositionInWindowX
20+
absoluteY = handler.lastPositionInWindowY
21+
stylusData = handler.stylusData
22+
}
1523

1624
override fun buildEventData(eventData: WritableMap) {
1725
super.buildEventData(eventData)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/LongPressGestureHandlerEventDataBuilder.kt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@ import com.swmansion.gesturehandler.core.LongPressGestureHandler
66

77
class LongPressGestureHandlerEventDataBuilder(handler: LongPressGestureHandler) :
88
GestureHandlerEventDataBuilder<LongPressGestureHandler>(handler) {
9-
private val x: Float = handler.lastRelativePositionX
10-
private val y: Float = handler.lastRelativePositionY
11-
private val absoluteX: Float = handler.lastPositionInWindowX
12-
private val absoluteY: Float = handler.lastPositionInWindowY
13-
private val duration: Int = handler.duration
9+
private val x: Float
10+
private val y: Float
11+
private val absoluteX: Float
12+
private val absoluteY: Float
13+
private val duration: Int
14+
15+
init {
16+
x = handler.lastRelativePositionX
17+
y = handler.lastRelativePositionY
18+
absoluteX = handler.lastPositionInWindowX
19+
absoluteY = handler.lastPositionInWindowY
20+
duration = handler.duration
21+
}
1422

1523
override fun buildEventData(eventData: WritableMap) {
1624
super.buildEventData(eventData)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/NativeGestureHandlerEventDataBuilder.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import com.swmansion.gesturehandler.core.NativeViewGestureHandler
55

66
class NativeGestureHandlerEventDataBuilder(handler: NativeViewGestureHandler) :
77
GestureHandlerEventDataBuilder<NativeViewGestureHandler>(handler) {
8-
private val pointerInside: Boolean = handler.isWithinBounds
8+
private val pointerInside: Boolean
9+
10+
init {
11+
pointerInside = handler.isWithinBounds
12+
}
913

1014
override fun buildEventData(eventData: WritableMap) {
1115
super.buildEventData(eventData)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PanGestureHandlerEventDataBuilder.kt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,27 @@ import com.swmansion.gesturehandler.core.StylusData
77

88
class PanGestureHandlerEventDataBuilder(handler: PanGestureHandler) :
99
GestureHandlerEventDataBuilder<PanGestureHandler>(handler) {
10-
private val x: Float = handler.lastRelativePositionX
11-
private val y: Float = handler.lastRelativePositionY
12-
private val absoluteX: Float = handler.lastPositionInWindowX
13-
private val absoluteY: Float = handler.lastPositionInWindowY
14-
private val translationX: Float = handler.translationX
15-
private val translationY: Float = handler.translationY
16-
private val velocityX: Float = handler.velocityX
17-
private val velocityY: Float = handler.velocityY
18-
private val stylusData: StylusData = handler.stylusData
10+
private val x: Float
11+
private val y: Float
12+
private val absoluteX: Float
13+
private val absoluteY: Float
14+
private val translationX: Float
15+
private val translationY: Float
16+
private val velocityX: Float
17+
private val velocityY: Float
18+
private val stylusData: StylusData
19+
20+
init {
21+
x = handler.lastRelativePositionX
22+
y = handler.lastRelativePositionY
23+
absoluteX = handler.lastPositionInWindowX
24+
absoluteY = handler.lastPositionInWindowY
25+
translationX = handler.translationX
26+
translationY = handler.translationY
27+
velocityX = handler.velocityX
28+
velocityY = handler.velocityY
29+
stylusData = handler.stylusData
30+
}
1931

2032
override fun buildEventData(eventData: WritableMap) {
2133
super.buildEventData(eventData)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PinchGestureHandlerEventDataBuilder.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ import com.swmansion.gesturehandler.core.PinchGestureHandler
66

77
class PinchGestureHandlerEventDataBuilder(handler: PinchGestureHandler) :
88
GestureHandlerEventDataBuilder<PinchGestureHandler>(handler) {
9-
private val scale: Double = handler.scale
10-
private val focalX: Float = handler.focalPointX
11-
private val focalY: Float = handler.focalPointY
12-
private val velocity: Double = handler.velocity
9+
private val scale: Double
10+
private val focalX: Float
11+
private val focalY: Float
12+
private val velocity: Double
13+
14+
init {
15+
scale = handler.scale
16+
focalX = handler.focalPointX
17+
focalY = handler.focalPointY
18+
velocity = handler.velocity
19+
}
1320

1421
override fun buildEventData(eventData: WritableMap) {
1522
super.buildEventData(eventData)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/RotationGestureHandlerEventDataBuilder.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ import com.swmansion.gesturehandler.core.RotationGestureHandler
66

77
class RotationGestureHandlerEventDataBuilder(handler: RotationGestureHandler) :
88
GestureHandlerEventDataBuilder<RotationGestureHandler>(handler) {
9-
private val rotation: Double = handler.rotation
10-
private val anchorX: Float = handler.anchorX
11-
private val anchorY: Float = handler.anchorY
12-
private val velocity: Double = handler.velocity
9+
private val rotation: Double
10+
private val anchorX: Float
11+
private val anchorY: Float
12+
private val velocity: Double
13+
14+
init {
15+
rotation = handler.rotation
16+
anchorX = handler.anchorX
17+
anchorY = handler.anchorY
18+
velocity = handler.velocity
19+
}
1320

1421
override fun buildEventData(eventData: WritableMap) {
1522
super.buildEventData(eventData)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/TapGestureHandlerEventDataBuilder.kt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ import com.swmansion.gesturehandler.core.TapGestureHandler
66

77
class TapGestureHandlerEventDataBuilder(handler: TapGestureHandler) :
88
GestureHandlerEventDataBuilder<TapGestureHandler>(handler) {
9-
private val x: Float = handler.lastRelativePositionX
10-
private val y: Float = handler.lastRelativePositionY
11-
private val absoluteX: Float = handler.lastPositionInWindowX
12-
private val absoluteY: Float = handler.lastPositionInWindowY
9+
private val x: Float
10+
private val y: Float
11+
private val absoluteX: Float
12+
private val absoluteY: Float
13+
14+
init {
15+
x = handler.lastRelativePositionX
16+
y = handler.lastRelativePositionY
17+
absoluteX = handler.lastPositionInWindowX
18+
absoluteY = handler.lastPositionInWindowY
19+
}
1320

1421
override fun buildEventData(eventData: WritableMap) {
1522
super.buildEventData(eventData)

0 commit comments

Comments
 (0)