Skip to content

Commit

Permalink
[ios][android] Update react-native-gesture-handler to 2.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tsapeta committed Oct 3, 2022
1 parent 98fa297 commit bb1ae89
Show file tree
Hide file tree
Showing 25 changed files with 79 additions and 57 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@ Package-specific changes not released in any SDK will be added here just before

- Updated `@stripe/stripe-react-native` from `0.13.1` to `0.18.1` on iOS. ([#19055](https://github.com/expo/expo/pull/19055) by [@tsapeta](https://github.com/tsapeta))
- Updated `@shopify/flash-list` from `1.1.0` to `1.3.0`. ([#19317](https://github.com/expo/expo/pull/19317) by [@kudo](https://github.com/kudo))
- Updated `react-native-gesture-handler` from `2.5.0` to `2.6.2`. ([#19362](https://github.com/expo/expo/pull/19362) by [@tsapeta](https://github.com/tsapeta))

### 🛠 Breaking changes

Expand Down
@@ -1,6 +1,7 @@
package versioned.host.exp.exponent.modules.api.components.gesturehandler

import android.os.Handler
import android.os.Looper
import android.view.MotionEvent

class FlingGestureHandler : GestureHandler<FlingGestureHandler>() {
Expand All @@ -27,7 +28,7 @@ class FlingGestureHandler : GestureHandler<FlingGestureHandler>() {
begin()
maxNumberOfPointersSimultaneously = 1
if (handler == null) {
handler = Handler() // lazy delegate?
handler = Handler(Looper.getMainLooper()) // lazy delegate?
} else {
handler!!.removeCallbacksAndMessages(null)
}
Expand Down
Expand Up @@ -5,6 +5,7 @@ import android.graphics.PointF
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import java.util.*

class GestureHandlerOrchestrator(
Expand Down Expand Up @@ -128,6 +129,13 @@ class GestureHandlerOrchestrator(
if (newState == GestureHandler.STATE_END) {
// gesture has ended, we need to kill the awaiting handler
otherHandler.cancel()
if (otherHandler.state == GestureHandler.STATE_END) {
// Handle edge case, where discrete gestures end immediately after activation thus
// their state is set to END and when the gesture they are waiting for activates they
// should be cancelled, however `cancel` was never sent as gestures were already in the END state.
// Send synthetic BEGAN -> CANCELLED to properly handle JS logic
otherHandler.dispatchStateChange(GestureHandler.STATE_CANCELLED, GestureHandler.STATE_BEGAN)
}
otherHandler.isAwaiting = false
} else {
// gesture has failed recognition, we may try activating
Expand All @@ -142,9 +150,12 @@ class GestureHandlerOrchestrator(
} else if (prevState == GestureHandler.STATE_ACTIVE || prevState == GestureHandler.STATE_END) {
if (handler.isActive) {
handler.dispatchStateChange(newState, prevState)
} else if (prevState == GestureHandler.STATE_ACTIVE) {
// handle edge case where handler awaiting for another one tries to activate but finishes
// before the other would not send state change event upon ending
} else if (prevState == GestureHandler.STATE_ACTIVE && (newState == GestureHandler.STATE_CANCELLED || newState == GestureHandler.STATE_FAILED)) {
// Handle edge case where handler awaiting for another one tries to activate but finishes
// before the other would not send state change event upon ending. Note that we only want
// to do this if the newState is either CANCELLED or FAILED, if it is END we still want to
// wait for the other handler to finish as in that case synthetic events will be sent by the
// makeActive method.
handler.dispatchStateChange(newState, GestureHandler.STATE_BEGAN)
}
} else if (prevState != GestureHandler.STATE_UNDETERMINED || newState != GestureHandler.STATE_CANCELLED) {
Expand Down Expand Up @@ -474,14 +485,24 @@ class GestureHandlerOrchestrator(
}
PointerEventsConfig.BOX_NONE -> {
// This view can't be the target, but its children might
if (view is ViewGroup) {
extractGestureHandlers(view, coords, pointerId).also { found ->
// A child view is handling touch, also extract handlers attached to this view
if (found) {
recordViewHandlersForPointer(view, coords, pointerId)
when (view) {
is ViewGroup -> {
extractGestureHandlers(view, coords, pointerId).also { found ->
// A child view is handling touch, also extract handlers attached to this view
if (found) {
recordViewHandlersForPointer(view, coords, pointerId)
}
}
}
} else false
// When <TextInput> has editable set to `false` getPointerEventsConfigForView returns
// `BOX_NONE` as it's `isEnabled` property is false. In this case we still want to extract
// handlers attached to the text input, as it makes sense that gestures would work on a
// non-editable TextInput.
is EditText -> {
recordViewHandlersForPointer(view, coords, pointerId)
}
else -> false
}
}
PointerEventsConfig.AUTO -> {
// Either this view or one of its children is the target
Expand Down
Expand Up @@ -2,6 +2,7 @@ package versioned.host.exp.exponent.modules.api.components.gesturehandler

import android.content.Context
import android.os.Handler
import android.os.Looper
import android.os.SystemClock
import android.view.MotionEvent

Expand All @@ -19,7 +20,9 @@ class LongPressGestureHandler(context: Context) : GestureHandler<LongPressGestur

init {
setShouldCancelWhenOutside(true)
defaultMaxDistSq = DEFAULT_MAX_DIST_DP * context.resources.displayMetrics.density

val defaultMaxDist = DEFAULT_MAX_DIST_DP * context.resources.displayMetrics.density
defaultMaxDistSq = defaultMaxDist * defaultMaxDist
maxDistSq = defaultMaxDistSq
}

Expand All @@ -41,7 +44,7 @@ class LongPressGestureHandler(context: Context) : GestureHandler<LongPressGestur
begin()
startX = event.rawX
startY = event.rawY
handler = Handler()
handler = Handler(Looper.getMainLooper())
if (minDurationMs > 0) {
handler!!.postDelayed({ activate() }, minDurationMs)
} else if (minDurationMs == 0L) {
Expand Down
Expand Up @@ -9,7 +9,8 @@ import com.facebook.react.views.textinput.ReactEditText

class NativeViewGestureHandler : GestureHandler<NativeViewGestureHandler>() {
private var shouldActivateOnStart = false
private var disallowInterruption = false
var disallowInterruption = false
private set

private var hook: NativeViewGestureHandlerHook = defaultHook

Expand Down
Expand Up @@ -2,6 +2,7 @@ package versioned.host.exp.exponent.modules.api.components.gesturehandler

import android.content.Context
import android.os.Handler
import android.os.Looper
import android.view.MotionEvent
import android.view.VelocityTracker
import android.view.ViewConfiguration
Expand Down Expand Up @@ -233,7 +234,7 @@ class PanGestureHandler(context: Context?) : GestureHandler<PanGestureHandler>()

if (activateAfterLongPress > 0) {
if (handler == null) {
handler = Handler()
handler = Handler(Looper.getMainLooper())
}
handler!!.postDelayed(activateDelayed, activateAfterLongPress)
}
Expand Down
Expand Up @@ -5,21 +5,13 @@ import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManager
import com.facebook.soloader.SoLoader

import versioned.host.exp.exponent.modules.api.components.gesturehandler.react.RNGestureHandlerModule
import versioned.host.exp.exponent.modules.api.components.gesturehandler.react.RNGestureHandlerRootViewManager
import versioned.host.exp.exponent.modules.api.components.gesturehandler.react.RNGestureHandlerButtonViewManager

class RNGestureHandlerPackage : ReactPackage {
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// For Fabric, we load c++ native library here, this triggers gesture handler's
// Fabric component registration which is necessary in order to avoid asking users
// to manually add init calls in their application code.
// This should no longer be needed if RN's autolink mechanism has Fabric support
SoLoader.loadLibrary("rngesturehandler_modules")
}
return listOf<NativeModule>(RNGestureHandlerModule(reactContext))
}

Expand Down
@@ -1,6 +1,7 @@
package versioned.host.exp.exponent.modules.api.components.gesturehandler

import android.os.Handler
import android.os.Looper
import android.view.MotionEvent
import versioned.host.exp.exponent.modules.api.components.gesturehandler.GestureUtils.getLastPointerX
import versioned.host.exp.exponent.modules.api.components.gesturehandler.GestureUtils.getLastPointerY
Expand Down Expand Up @@ -70,7 +71,7 @@ class TapGestureHandler : GestureHandler<TapGestureHandler>() {

private fun startTap() {
if (handler == null) {
handler = Handler() // TODO: lazy init (handle else branch correctly)
handler = Handler(Looper.getMainLooper()) // TODO: lazy init (handle else branch correctly)
} else {
handler!!.removeCallbacksAndMessages(null)
}
Expand All @@ -79,7 +80,7 @@ class TapGestureHandler : GestureHandler<TapGestureHandler>() {

private fun endTap() {
if (handler == null) {
handler = Handler()
handler = Handler(Looper.getMainLooper())
} else {
handler!!.removeCallbacksAndMessages(null)
}
Expand Down
Expand Up @@ -4,6 +4,7 @@ import android.util.SparseArray
import com.facebook.react.bridge.ReadableMap
import versioned.host.exp.exponent.modules.api.components.gesturehandler.GestureHandler
import versioned.host.exp.exponent.modules.api.components.gesturehandler.GestureHandlerInteractionController
import versioned.host.exp.exponent.modules.api.components.gesturehandler.NativeViewGestureHandler

class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
private val waitForRelations = SparseArray<IntArray>()
Expand Down Expand Up @@ -42,8 +43,13 @@ class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
otherHandler: GestureHandler<*>,
) = false

override fun shouldHandlerBeCancelledBy(handler: GestureHandler<*>, otherHandler: GestureHandler<*>) = false
override fun shouldHandlerBeCancelledBy(handler: GestureHandler<*>, otherHandler: GestureHandler<*>): Boolean {
if (otherHandler is NativeViewGestureHandler) {
return otherHandler.disallowInterruption
}

return false
}
override fun shouldRecognizeSimultaneously(
handler: GestureHandler<*>,
otherHandler: GestureHandler<*>,
Expand Down
Expand Up @@ -426,7 +426,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?)
@ReactMethod(isBlockingSynchronousMethod = true)
fun install(): Boolean {
return try {
SoLoader.loadLibrary("rngesturehandler_modules")
SoLoader.loadLibrary("gesturehandler")
val jsContext = reactApplicationContext.javaScriptContextHolder
decorateRuntime(jsContext.get())
true
Expand Down
4 changes: 2 additions & 2 deletions apps/bare-expo/ios/Podfile.lock
Expand Up @@ -714,7 +714,7 @@ PODS:
- React-Core
- RNDateTimePicker (6.2.0):
- React-Core
- RNGestureHandler (2.5.0):
- RNGestureHandler (2.6.2):
- React-Core
- RNReanimated (2.10.0):
- DoubleConversion
Expand Down Expand Up @@ -1373,7 +1373,7 @@ SPEC CHECKSUMS:
RNCMaskedView: c298b644a10c0c142055b3ae24d83879ecb13ccd
RNCPicker: 0250e95ad170569a96f5b0555cdd5e65b9084dca
RNDateTimePicker: 30e6733efc179d1e49d6008ea5fce42cdc9aeeca
RNGestureHandler: bad495418bcbd3ab47017a38d93d290ebd406f50
RNGestureHandler: 4defbd70b2faf3d6761b82fa7880285241762cb0
RNReanimated: 60e291d42c77752a0f6d6f358387bdf225a87c6e
RNScreens: 4a1af06327774490d97342c00aee0c2bafb497b7
RNSharedElement: eb7d506733952d58634f34c82ec17e82f557e377
Expand Down
2 changes: 1 addition & 1 deletion apps/bare-expo/package.json
Expand Up @@ -112,7 +112,7 @@
"react": "18.1.0",
"react-dom": "18.0.0",
"react-native": "0.70.1",
"react-native-gesture-handler": "~2.5.0",
"react-native-gesture-handler": "~2.6.2",
"react-native-reanimated": "~2.10.0",
"react-native-safe-area-context": "4.3.1",
"react-native-screens": "~3.15.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/bare-sandbox/package.json
Expand Up @@ -18,7 +18,7 @@
"react": "18.1.0",
"react-dom": "18.0.0",
"react-native": "0.70.1",
"react-native-gesture-handler": "~2.5.0",
"react-native-gesture-handler": "~2.6.2",
"react-native-reanimated": "~2.10.0",
"react-native-screens": "~3.15.0",
"react-native-web": "~0.18.9"
Expand Down
2 changes: 1 addition & 1 deletion apps/native-component-list/package.json
Expand Up @@ -144,7 +144,7 @@
"react": "18.1.0",
"react-dom": "18.0.0",
"react-native": "0.70.1",
"react-native-gesture-handler": "~2.5.0",
"react-native-gesture-handler": "~2.6.2",
"react-native-iphone-x-helper": "^1.3.0",
"react-native-maps": "0.31.1",
"react-native-pager-view": "5.4.24",
Expand Down
2 changes: 1 addition & 1 deletion apps/test-suite/package.json
Expand Up @@ -51,7 +51,7 @@
"lodash": "^4.17.19",
"react": "18.1.0",
"react-native": "0.70.1",
"react-native-gesture-handler": "~2.5.0",
"react-native-gesture-handler": "~2.6.2",
"react-native-safe-area-view": "^0.14.8",
"sinon": "^7.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion home/package.json
Expand Up @@ -55,7 +55,7 @@
"react": "18.1.0",
"react-native": "0.70.1",
"react-native-fade-in-image": "^1.6.1",
"react-native-gesture-handler": "~2.5.0",
"react-native-gesture-handler": "~2.6.2",
"react-native-infinite-scroll-view": "^0.4.5",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-maps": "0.31.1",
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Expand Up @@ -2014,7 +2014,7 @@ PODS:
- React-perflogger (= 0.70.1)
- RNFlashList (1.3.0):
- React-Core
- RNGestureHandler (2.5.0):
- RNGestureHandler (2.6.2):
- React-Core
- RNReanimated (2.9.1):
- DoubleConversion
Expand Down Expand Up @@ -3509,7 +3509,7 @@ SPEC CHECKSUMS:
React-runtimeexecutor: a11d0c2e14140baf1e449264ca9168ae9ae6bbd0
ReactCommon: 7f86326b92009925c6dcf93f8e825060171c379f
RNFlashList: 5116f2de2f543f01bfc30b22d5942d5af84b43df
RNGestureHandler: bad495418bcbd3ab47017a38d93d290ebd406f50
RNGestureHandler: 4defbd70b2faf3d6761b82fa7880285241762cb0
RNReanimated: 5c8c17e26787fd8984cd5accdc70fef2ca70aafd
RNScreens: 4a1af06327774490d97342c00aee0c2bafb497b7
Stripe: fb29a476e4866fec4ef22fb76207363dd32795aa
Expand Down
@@ -1,6 +1,6 @@
{
"name": "RNGestureHandler",
"version": "2.5.0",
"version": "2.6.2",
"summary": "Experimental implementation of a new declarative API for gesture handling in react-native",
"homepage": "https://github.com/software-mansion/react-native-gesture-handler",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
},
"source": {
"git": "https://github.com/software-mansion/react-native-gesture-handler",
"tag": "2.5.0"
"tag": "2.6.2"
},
"source_files": "ios/**/*.{h,m,mm}",
"requires_arc": true,
Expand Down
Expand Up @@ -3,13 +3,13 @@
#import "RNGestureHandlerButtonComponentView.h"

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>

#import <react/renderer/components/rngesturehandler/ComponentDescriptors.h>
#import <react/renderer/components/rngesturehandler/EventEmitters.h>
#import <react/renderer/components/rngesturehandler/Props.h>
#import <react/renderer/components/rngesturehandler/RCTComponentViewHelpers.h>

#import "RCTFabricComponentsPlugins.h"
#import "RNGestureHandlerButton.h"

using namespace facebook::react;
Expand Down
Expand Up @@ -6,12 +6,7 @@
#import <React/RCTRootView.h>
#import <React/RCTUIManager.h>
#import <React/RCTEventDispatcher.h>

#if __has_include(<React/RCTRootContentView.h>)
#import <React/RCTRootContentView.h>
#else
#import "RCTRootContentView.h"
#endif

#import "RNGestureHandlerActionType.h"
#import "RNGestureHandlerState.h"
Expand Down
@@ -1,6 +1,6 @@
#ifdef RN_FABRIC_ENABLED

#import "RCTFabricComponentsPlugins.h"
#import <React/RCTFabricComponentsPlugins.h>

Class<RCTComponentViewProtocol> RNGestureHandlerRootViewCls(void)
{
Expand Down
2 changes: 1 addition & 1 deletion packages/expo-stories/package.json
Expand Up @@ -30,7 +30,7 @@
"esbuild": "^0.12.15",
"fs-extra": "^9.1.0",
"glob": "^7.1.7",
"react-native-gesture-handler": "~2.5.0",
"react-native-gesture-handler": "~2.6.2",
"react-native-safe-area-context": "4.3.1",
"react-native-screens": "~3.15.0",
"react-native-svg": "12.3.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/expo-test-runner/package.json
Expand Up @@ -10,13 +10,13 @@
"expo-test-runner": "bin/expo-test-runner.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/expo/expo-test-runner.git"
},
"type": "git",
"url": "git+https://github.com/expo/expo-test-runner.git"
},
"bugs": {
"url": "https://github.com/expo/expo-test-runner/issues"
},
"homepage": "https://github.com/expo/expo-test-runner#readme",
"url": "https://github.com/expo/expo-test-runner/issues"
},
"homepage": "https://github.com/expo/expo-test-runner#readme",
"scripts": {
"build": "expo-module build",
"clean": "expo-module clean",
Expand Down

0 comments on commit bb1ae89

Please sign in to comment.