Skip to content

Commit 765e326

Browse files
committed
Merge branch 'next' into @akwasniewski/logic-detector
2 parents 153385c + 738a33c commit 765e326

File tree

19 files changed

+525
-255
lines changed

19 files changed

+525
-255
lines changed

apps/basic-example/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { getDefaultConfig } = require('@react-native/metro-config');
22
const { mergeConfig } = require('metro-config');
33

44
const path = require('path');
5-
const exclusionList = require('metro-config/private/defaults/exclusionList');
5+
const exclusionList = require('metro-config/private/defaults/exclusionList').default;
66
const escape = require('escape-string-regexp');
77

88
// Gesture handler tries to require 'react-native-reanimated' inside a try...catch

apps/expo-example/metro.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { getDefaultConfig } = require('expo/metro-config');
22
const path = require('path');
33

4-
const exclusionList = require('metro-config/private/defaults/exclusionList');
4+
const exclusionList = require('metro-config/private/defaults/exclusionList').default;
55
const escape = require('escape-string-regexp');
66
const pack = require('./package.json');
77

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,13 @@ class RNGestureHandlerButtonViewManager :
262262
}
263263
}
264264

265-
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
266-
if (super.onInterceptTouchEvent(ev)) {
265+
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
266+
if (super.onInterceptTouchEvent(event)) {
267267
return true
268268
}
269269
// We call `onTouchEvent` and wait until button changes state to `pressed`, if it's pressed
270270
// we return true so that the gesture handler can activate.
271-
onTouchEvent(ev)
271+
onTouchEvent(event)
272272
return isPressed
273273
}
274274

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
9898
val factory = RNGestureHandlerFactoryUtil.findFactoryForHandler<GestureHandler>(handler) ?: return
9999

100100
factory.setConfig(handler, config)
101-
102-
if (handler.actionType != GestureHandler.ACTION_TYPE_NATIVE_DETECTOR) {
103-
interactionManager.dropRelationsForHandlerWithTag(handlerTag)
104-
interactionManager.configureInteractions(handler, config)
105-
}
106101
}
107102

108103
@ReactMethod

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
115115
}
116116
}
117117

118-
fun dispatchTouchEvent(ev: MotionEvent): Boolean {
118+
fun dispatchTouchEvent(event: MotionEvent): Boolean {
119119
// We mark `mPassingTouch` before we get into `mOrchestrator.onTouchEvent` so that we can tell
120120
// if `requestDisallow` has been called as a result of a normal gesture handling process or
121121
// as a result of one of the gesture handlers activating
122122
passingTouch = true
123-
orchestrator!!.onTouchEvent(ev)
123+
orchestrator!!.onTouchEvent(event)
124124
passingTouch = false
125125
return shouldIntercept
126126
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class RNGestureHandlerRootView(context: Context?) : ReactViewGroup(context) {
3737
rootHelper?.tearDown()
3838
}
3939

40-
override fun dispatchTouchEvent(ev: MotionEvent) = if (rootViewEnabled && rootHelper!!.dispatchTouchEvent(ev)) {
40+
override fun dispatchTouchEvent(event: MotionEvent) = if (rootViewEnabled && rootHelper!!.dispatchTouchEvent(event)) {
4141
true
4242
} else {
43-
super.dispatchTouchEvent(ev)
43+
super.dispatchTouchEvent(event)
4444
}
4545

4646
override fun dispatchGenericMotionEvent(event: MotionEvent) =

packages/react-native-gesture-handler/apple/RNGestureHandler.mm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ - (void)updateConfig:(NSDictionary *)config
182182
RCTLogError(@"Cannot have all of top, bottom and height defined");
183183
}
184184
}
185-
186-
if (_actionType != RNGestureHandlerActionTypeNativeDetector) {
187-
[self updateRelations:config];
188-
}
189185
}
190186

191187
- (void)updateRelations:(NSDictionary *)relations

packages/react-native-gesture-handler/apple/RNGestureHandlerModule.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ - (void)updateGestureHandlerConfig:(double)handlerTag newConfig:(NSDictionary *)
161161

162162
- (void)configureRelations:(double)handlerTag relations:(NSDictionary *)relations
163163
{
164-
RNGestureHandlerManager *manager = [RNGestureHandlerModule handlerManagerForModuleId:_moduleId];
165-
[manager updateGestureHandlerRelations:[NSNumber numberWithDouble:handlerTag] relations:relations];
164+
[self addOperationBlock:^(RNGestureHandlerManager *manager) {
165+
[manager updateGestureHandlerRelations:[NSNumber numberWithDouble:handlerTag] relations:relations];
166+
}];
166167
}
167168

168169
- (void)dropGestureHandler:(double)handlerTag

packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,13 @@ const Pressable = (props: PressableProps) => {
270270
stateMachine.reset();
271271
handlePressOut(pressableEvent, false);
272272
})
273-
.onFinalize(() => {
273+
.onFinalize((_event, success) => {
274274
if (Platform.OS === 'web') {
275-
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
275+
if (success) {
276+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
277+
} else {
278+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
279+
}
276280
handleFinalize();
277281
}
278282
}),
@@ -301,11 +305,15 @@ const Pressable = (props: PressableProps) => {
301305
stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
302306
}
303307
})
304-
.onFinalize(() => {
308+
.onFinalize((_event, success) => {
305309
if (Platform.OS !== 'web') {
306310
// On Web we use LongPress().onFinalize() instead of Native().onFinalize(),
307311
// as Native cancels on mouse move, and LongPress does not.
308-
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
312+
if (success) {
313+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
314+
} else {
315+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
316+
}
309317
handleFinalize();
310318
}
311319
}),

packages/react-native-gesture-handler/src/components/Pressable/stateDefinitions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export enum StateMachineEvent {
77
NATIVE_START = 'nativeStart',
88
FINALIZE = 'finalize',
99
LONG_PRESS_TOUCHES_DOWN = 'longPressTouchesDown',
10+
CANCEL = 'cancel',
1011
}
1112

1213
function getAndroidStatesConfig(

0 commit comments

Comments
 (0)