Skip to content

Commit 753d43b

Browse files
committed
Merge branch 'next' into @mbert/components-new-api
2 parents 11eeef1 + 12ffcc4 commit 753d43b

File tree

67 files changed

+1377
-920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1377
-920
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ignorePatterns": [
2121
"packages/react-native-gesture-handler/lib/**/*",
2222
"**/*.config.js",
23-
"scripts/*.js",
23+
"scripts/**/*.js",
2424
"**/node_modules/**/*"
2525
],
2626
"rules": {
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: publish-npm-package
2+
description: Build and publish react-native-gesture-handler package to npm
3+
inputs:
4+
is-commitly:
5+
description: Whether the release should be marked as nightly.
6+
default: "true"
7+
dry-run:
8+
description: Whether to perform a dry run of the publish.
9+
default: "true"
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Set up environment
15+
shell: bash
16+
run: |
17+
echo "YARN_ENABLE_HARDENED_MODE=0" >> $GITHUB_ENV
18+
echo "PACKAGE_NAME=PLACEHOLDER" >> $GITHUB_ENV
19+
20+
- name: Setup Node
21+
uses: actions/setup-node@v6
22+
with:
23+
node-version: 24
24+
cache: 'yarn'
25+
registry-url: https://registry.npmjs.org/
26+
27+
- name: Update package version
28+
id: set-package-version
29+
shell: bash
30+
run: |
31+
VERSION=$(node ./scripts/release/set-package-version.js ${{ inputs.is-commitly == 'true' && '--commitly' || '' }})
32+
echo "Updated package version to $VERSION"
33+
echo "version=$VERSION" >> $GITHUB_OUTPUT
34+
35+
# Ensure npm 11.5.1 or later is installed for OIDC
36+
- name: Update npm
37+
shell: bash
38+
run: npm install -g npm@latest
39+
40+
- name: Install node dependencies
41+
shell: bash
42+
run: yarn install --immutable
43+
44+
- name: Build package
45+
id: build
46+
working-directory: packages/react-native-gesture-handler
47+
shell: bash
48+
run: npm pack
49+
50+
- name: Add package name to env
51+
working-directory: packages/react-native-gesture-handler
52+
shell: bash
53+
run: echo "PACKAGE_NAME=$(ls -l | egrep -o "react-native-gesture-handler-(.*)(=?\.tgz)")" >> $GITHUB_ENV
54+
55+
- name: Assert PACKAGE_NAME
56+
if: ${{ env.PACKAGE_NAME == 'PLACEHOLDER' }}
57+
shell: bash
58+
run: exit 1 # If we end up here, it means that package was not generated.
59+
60+
- name: Upload npm package to GitHub
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: ${{ env.PACKAGE_NAME }}
64+
path: './packages/react-native-gesture-handler/${{ env.PACKAGE_NAME }}'
65+
66+
- name: Figure out the correct npm tag
67+
id: figure-out-npm-tag
68+
shell: bash
69+
run: |
70+
if [ "${{ inputs.is-commitly }}" = "true" ]; then
71+
TAG_ARGUMENT="--tag nightly"
72+
else
73+
if [ $(node ./scripts/release/should-be-latest.js ${{ steps.set-package-version.outputs.version }}) = "true" ]; then
74+
TAG_ARGUMENT="--tag latest"
75+
else
76+
TAG_ARGUMENT=""
77+
fi
78+
fi
79+
80+
echo "Determined tag argument: $TAG_ARGUMENT"
81+
echo "tag-argument=$TAG_ARGUMENT" >> $GITHUB_OUTPUT
82+
83+
- name: Print outputs
84+
shell: bash
85+
run: |
86+
echo "Version to be published: ${{ steps.set-package-version.outputs.version }}"
87+
echo "NPM tag argument: ${{ steps.figure-out-npm-tag.outputs.tag-argument }}"
88+
89+
- name: Publish npm package
90+
shell: bash
91+
if: inputs.dry-run == 'false'
92+
working-directory: packages/react-native-gesture-handler
93+
run: |
94+
npm publish $PACKAGE_NAME --provenance ${{ steps.figure-out-npm-tag.outputs.tag-argument }}
95+
96+
- name: Don't publish if dry-run is true
97+
shell: bash
98+
if: inputs.dry-run == 'true'
99+
run: |
100+
echo "At this point, the following command would have been run: npm publish $PACKAGE_NAME --provenance ${{ steps.figure-out-npm-tag.outputs.tag-argument }}"
101+
102+
- name: Configure git
103+
if: inputs.is-commitly == 'false'
104+
shell: bash
105+
run: |
106+
git config --local user.email "[email protected]"
107+
git config --local user.name "GitHub Action"
108+
109+
- name: Create release commit
110+
if: inputs.is-commitly == 'false'
111+
shell: bash
112+
run: |
113+
git add packages/react-native-gesture-handler/package.json
114+
git commit -m "Release v${{ steps.set-package-version.outputs.version }}"
115+
116+
if [ "${{ inputs.dry-run }}" = 'false' ]; then
117+
echo "Pushing release commit to origin..."
118+
git push
119+
else
120+
echo "Dry run mode: skipping git push"
121+
fi
122+
123+
- name: Create release tag
124+
if: inputs.is-commitly == 'false'
125+
shell: bash
126+
run: |
127+
git tag -a "v${{ steps.set-package-version.outputs.version }}" -m "Release v${{ steps.set-package-version.outputs.version }}"
128+
129+
if [ "${{ inputs.dry-run }}" = 'false' ]; then
130+
echo "Pushing tag to origin..."
131+
git push origin "v${{ steps.set-package-version.outputs.version }}"
132+
else
133+
echo "Dry run mode: skipping git push"
134+
fi

.github/workflows/npm-gesture-handler-publish.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Publish release to npm
2+
on:
3+
# For commitlies
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- packages/react-native-gesture-handler/**
9+
# For stable releases
10+
workflow_dispatch:
11+
inputs:
12+
dry-run:
13+
description: Whether to perform a dry run of the publish.
14+
type: boolean
15+
default: true
16+
17+
jobs:
18+
npm-build:
19+
if: github.repository == 'software-mansion/react-native-gesture-handler'
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
contents: write
24+
id-token: write # for OIDC
25+
26+
concurrency:
27+
group: publish-${{ github.ref }}
28+
cancel-in-progress: false
29+
30+
steps:
31+
- name: Check out
32+
uses: actions/checkout@v4
33+
34+
- name: Publish stable release
35+
if: ${{ github.event_name == 'workflow_dispatch' }}
36+
uses: ./.github/actions/publish-npm-package
37+
with:
38+
is-commitly: false
39+
dry-run: ${{ inputs.dry-run }}
40+
41+
- name: Publish commitly release
42+
if: ${{ github.event_name == 'push' }}
43+
uses: ./.github/actions/publish-npm-package
44+
with:
45+
is-commitly: true
46+
dry-run: false

apps/basic-example/src/NativeDetector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Animated, Button, useAnimatedValue } from 'react-native';
33
import {
44
GestureHandlerRootView,
55
GestureDetector,
6-
usePan,
6+
usePanGesture,
77
} from 'react-native-gesture-handler';
88

99
export default function App() {
@@ -17,7 +17,7 @@ export default function App() {
1717
}
1818
);
1919

20-
const gesture = usePan({
20+
const gesture = usePanGesture({
2121
onUpdate: event,
2222
});
2323

apps/basic-example/src/Text.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@ import {
44
Gesture,
55
GestureDetector,
66
InterceptingGestureDetector,
7-
useTap,
7+
VirtualGestureDetector,
8+
useTapGesture,
89
} from 'react-native-gesture-handler';
910

1011
import { COLORS } from './colors';
1112

1213
function NativeDetectorExample() {
13-
const tapAll = useTap({
14+
const tapAll = useTapGesture({
1415
onStart: () => {
1516
'worklet';
1617
console.log('Tapped on text!');
1718
},
1819
});
1920

20-
const tapFirstPart = useTap({
21+
const tapFirstPart = useTapGesture({
2122
onStart: () => {
2223
'worklet';
2324
console.log('Tapped on first part!');
2425
},
2526
});
2627

27-
const tapSecondPart = useTap({
28+
const tapSecondPart = useTapGesture({
2829
onStart: () => {
2930
'worklet';
3031
console.log('Tapped on second part!');
@@ -39,18 +40,18 @@ function NativeDetectorExample() {
3940
<InterceptingGestureDetector gesture={tapAll}>
4041
<Text style={{ fontSize: 18, textAlign: 'center' }}>
4142
Some text example running with RNGH
42-
<GestureDetector gesture={tapFirstPart}>
43+
<VirtualGestureDetector gesture={tapFirstPart}>
4344
<Text style={{ fontSize: 24, color: COLORS.NAVY }}>
4445
{' '}
4546
try tapping on this part
4647
</Text>
47-
</GestureDetector>
48-
<GestureDetector gesture={tapSecondPart}>
48+
</VirtualGestureDetector>
49+
<VirtualGestureDetector gesture={tapSecondPart}>
4950
<Text style={{ fontSize: 28, color: COLORS.KINDA_BLUE }}>
5051
{' '}
5152
or on this part
5253
</Text>
53-
</GestureDetector>
54+
</VirtualGestureDetector>
5455
this part is not special :(
5556
</Text>
5657
</InterceptingGestureDetector>

packages/docs-gesture-handler/docs/gestures/force-touch-gesture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar_position: 10
66
---
77

88
:::warning
9-
ForceTouch gesture is depracted and will be removed in the future version of Gesture Handler.
9+
ForceTouch gesture is deprecated and will be removed in the future version of Gesture Handler.
1010
:::
1111

1212
import BaseEventData from './\_shared/base-gesture-event-data.md';
@@ -16,7 +16,7 @@ import BaseEventCallbacks from './\_shared/base-gesture-callbacks.md';
1616
import BaseContinuousEventCallbacks from './\_shared/base-continuous-gesture-callbacks.md';
1717

1818
A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
19-
The gesture [activates](/docs/fundamentals/states-events#active) when pressure of touch if greater or equal than `minForce`. It fails if pressure is greater than `maxForce`
19+
The gesture [activates](/docs/fundamentals/states-events#active) when pressure of touch is greater than or equal to `minForce`. It fails if pressure is greater than `maxForce`.
2020
Gesture callback can be used for continuous tracking of the touch pressure. It provides information for one finger (the first one).
2121

2222
At the beginning of the gesture, the pressure factor is 0.0. As the pressure increases, the pressure factor increases proportionally. The maximum pressure is 1.0.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.view.View
77
import android.view.ViewGroup
88
import android.widget.EditText
99
import com.facebook.react.uimanager.ReactCompoundView
10+
import com.facebook.react.uimanager.RootView
1011
import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
1112
import com.swmansion.gesturehandler.react.RNGestureHandlerRootView
1213
import java.util.*
@@ -15,6 +16,7 @@ class GestureHandlerOrchestrator(
1516
private val wrapperView: ViewGroup,
1617
private val handlerRegistry: GestureHandlerRegistry,
1718
private val viewConfigHelper: ViewConfigurationHelper,
19+
private val rootView: ViewGroup,
1820
) {
1921
/**
2022
* Minimum alpha (value from 0 to 1) that should be set to a view so that it can be treated as a
@@ -57,6 +59,14 @@ class GestureHandlerOrchestrator(
5759
if (finishedHandlersCleanupScheduled && handlingChangeSemaphore == 0) {
5860
cleanupFinishedHandlers()
5961
}
62+
if (action == MotionEvent.ACTION_UP ||
63+
action == MotionEvent.ACTION_CANCEL ||
64+
action == MotionEvent.ACTION_HOVER_EXIT
65+
) {
66+
if (gestureHandlers.isEmpty() && rootView is RootView) {
67+
rootView.onChildEndedNativeGesture(rootView, event)
68+
}
69+
}
6070
return true
6171
}
6272

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,6 @@ class RNGestureHandlerButtonViewManager :
440440
val isResponder = tryGrabbingResponder()
441441
if (isResponder) {
442442
isTouched = true
443-
// when setPressed(true) is called before canBegin it will not call super.setPressed
444-
// in this case we call it here
445-
setPressed(true)
446443
}
447444

448445
return isResponder

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.swmansion.gesturehandler.react
22

33
import com.facebook.react.bridge.ReadableArray
44
import com.facebook.react.module.annotations.ReactModule
5+
import com.facebook.react.uimanager.PointerEvents.Companion.parsePointerEvents
56
import com.facebook.react.uimanager.ThemedReactContext
67
import com.facebook.react.uimanager.ViewGroupManager
78
import com.facebook.react.uimanager.ViewManagerDelegate
@@ -45,4 +46,8 @@ class RNGestureHandlerDetectorViewManager :
4546
view.onViewDrop()
4647
super.onDropViewInstance(view)
4748
}
49+
50+
override fun setPointerEvents(view: RNGestureHandlerDetectorView, pointerEventsStr: String?) {
51+
view.pointerEvents = parsePointerEvents(pointerEventsStr)
52+
}
4853
}

0 commit comments

Comments
 (0)