From 4a1c76bf77b3ca854c418686d9f4d8f41eaa0540 Mon Sep 17 00:00:00 2001 From: Oleksii Bulenok <63914185+abulenok@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:12:30 +0200 Subject: [PATCH] Migrate to RN GH v3 (#11682) Co-authored-by: Tomek Zawadzki --- package.json | 2 +- .../react-native-drawer-layout@4.2.3.patch | 9 ++ pnpm-lock.yaml | 56 +++----- src/components/ContextMenu/index.tsx | 103 +++++++-------- src/components/ContextMenu/types.ts | 11 +- src/components/DraggableList/index.tsx | 23 ++-- .../pager/ImageItem/ImageItem.android.tsx | 87 ++++++++----- .../pager/ImageItem/ImageItem.ios.tsx | 22 ++-- src/components/Lightbox/pager/ImagePager.tsx | 21 +-- src/components/dms/MessageContextMenu.tsx | 4 +- src/components/dms/SwipeToReply.tsx | 123 ++++++++---------- .../custom-animations/GestureActionView.tsx | 27 ++-- src/screens/VideoFeed/components/Scrubber.tsx | 72 +++++----- src/screens/VideoFeed/index.tsx | 4 +- src/state/global-gesture-events/index.tsx | 39 +++--- src/view/shell/index.tsx | 6 +- 16 files changed, 294 insertions(+), 315 deletions(-) diff --git a/package.json b/package.json index 1ef25f9cc..7e115ca17 100644 --- a/package.json +++ b/package.json @@ -257,7 +257,7 @@ "react-native-device-attest": "^0.1.6", "react-native-drawer-layout": "^4.2.3", "react-native-edge-to-edge": "^1.8.1", - "react-native-gesture-handler": "~2.32.0", + "react-native-gesture-handler": "~3.3.0", "react-native-keyboard-controller": "1.21.9", "react-native-mmkv": "^3.3.3", "react-native-pager-view": "6.8.0", diff --git a/patches/react-native-drawer-layout@4.2.3.patch b/patches/react-native-drawer-layout@4.2.3.patch index bb4b3381b..55ff7943a 100644 --- a/patches/react-native-drawer-layout@4.2.3.patch +++ b/patches/react-native-drawer-layout@4.2.3.patch @@ -36,3 +36,12 @@ index 38470a658878a63919186257041098747ec55473..b9d25798c9be229efeb676166f89bfbc if (open) { runOnJS(onOpen)(); } else { +diff --git a/lib/typescript/src/types.d.ts b/lib/typescript/src/types.d.ts +--- a/lib/typescript/src/types.d.ts ++++ b/lib/typescript/src/types.d.ts +@@ -1,4 +1,4 @@ + import * as React from 'react'; + import type { StyleProp, View, ViewStyle } from 'react-native'; +-import type { PanGesture } from 'react-native-gesture-handler'; ++import type { LegacyPanGesture as PanGesture } from 'react-native-gesture-handler'; + import type { SharedValue } from 'react-native-reanimated'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0cbb07221..bbc9697ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -227,7 +227,7 @@ patchedDependencies: expo-notifications@57.0.20: dd096e8b43ac91716d4ffefc7d65945b491612d5c6fa57035e8af3f875697deb expo-updates@57.0.23: a01d018dea691a469c745521a9c077a952d0cf9cc1163af1eacbd2122a9c3d19 expo@57.0.24: 0856ae2db56b30b378fdaa8dbec8e7cda50b13fc29d89b873e1b12cc0affac33 - react-native-drawer-layout@4.2.3: 74f2c043cc22ab87054f219e7c7373a509b779b18bfa79d27e7d051d73355130 + react-native-drawer-layout@4.2.3: 2a67e397c87df9fb947b1931c9b00724b802a8dca5d3013617e6155f1ae3188e react-native-keyboard-controller@1.21.9: ac52bf7502ff3ad34a8594b5e1a916b96bf87a2523b6abc87c31f03607d52271 react-native-pager-view@6.8.0: c8316acd33c9aef6531e8c272c2bfab7bd02af1255969eeaab2bad5ab48531cc react-native-screens@4.26.2: 64db79e069eed40559b3621792683842e9785a55a8617d138459817cf27b1926 @@ -666,13 +666,13 @@ importers: version: 0.1.6(expo@57.0.24)(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) react-native-drawer-layout: specifier: ^4.2.3 - version: 4.2.3(patch_hash=74f2c043cc22ab87054f219e7c7373a509b779b18bfa79d27e7d051d73355130)(react-native-gesture-handler@2.32.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3))(react-native-reanimated@4.6.0(f8dcf0153e1110dbdef62fe89550ce57))(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) + version: 4.2.3(patch_hash=2a67e397c87df9fb947b1931c9b00724b802a8dca5d3013617e6155f1ae3188e)(react-native-gesture-handler@3.3.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3))(react-native-reanimated@4.6.0(f8dcf0153e1110dbdef62fe89550ce57))(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) react-native-edge-to-edge: specifier: ^1.8.1 version: 1.8.1(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) react-native-gesture-handler: - specifier: ~2.32.0 - version: 2.32.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) + specifier: ~3.3.0 + version: 3.3.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) react-native-keyboard-controller: specifier: 1.21.9 version: 1.21.9(patch_hash=ac52bf7502ff3ad34a8594b5e1a916b96bf87a2523b6abc87c31f03607d52271)(react-native-reanimated@4.6.0(f8dcf0153e1110dbdef62fe89550ce57))(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) @@ -738,7 +738,7 @@ importers: version: 2.0.7(react-dom@19.2.3(react@19.2.3))(react@19.2.3) sonner-native: specifier: 0.26.4 - version: 0.26.4(ac35108601b693cc2ecffbdd23315c0a) + version: 0.26.4(a4fd305dda0c2e8ae37e0c92cb913d83) tippy.js: specifier: ^6.3.7 version: 6.3.7 @@ -1795,10 +1795,6 @@ packages: resolution: {integrity: sha512-JRrHvitc0w+r/h6XXSOq917HxsjRoxPEtyNYSmylKirjiPNrRx84VKtqFlOIWIFCOZI5BoXg6hNpE0Zq7CwVBA==} hasBin: true - '@egjs/hammerjs@2.0.17': - resolution: {integrity: sha512-XQsZgjm2EcVUiZQf11UBJQfmZeEmOW8DpI1gsFeln6w0ae0ii4dMQEQ0kjl6DspdWX1aGY1/loyXnP0JS06e/A==} - engines: {node: '>=0.8.0'} - '@eloqnt/cli@0.6.26': resolution: {integrity: sha512-F2+6m31TQKDRyZJimopy66g9TL4G/Pz6T/9pXs7smqn33pyWJR485nsJAC6TBa4VTK1Nzsq1lRZUxa5UM0saBg==} hasBin: true @@ -4074,9 +4070,6 @@ packages: '@types/graceful-fs@4.1.9': resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} - '@types/hammerjs@2.0.46': - resolution: {integrity: sha512-ynRvcq6wvqexJ9brDMS4BnBLzmr0e14d6ZJTEShTBWKymQiHwlAyGu0ZPEFI2Fh1U53F7tN9ufClWM5KvqkKOw==} - '@types/invariant@2.2.37': resolution: {integrity: sha512-IwpIMieE55oGWiXkQPSBY1nw1nFs6bsKXTFskNY8sdS17K24vyEBRQZEwlRS7ZmXCWnJcQtbxWzly+cODWGs2A==} @@ -6252,9 +6245,6 @@ packages: hls.js@1.6.16: resolution: {integrity: sha512-VSIRpLfRwlAAdGL4wiTucx2ScRipo0ed1FBatWkyt832jC4CReKstga6yIhYVwGu9LOBjuX9wzmRMeQdBJtzEA==} - hoist-non-react-statics@3.3.2: - resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} - hosted-git-info@7.0.2: resolution: {integrity: sha512-puUZAUKT5m8Zzvs72XWy3HtvVbTWljRE66cP60bxJzAqf2DgICo7lYTY2IHUmLnNpjYvw5bvmoHvPc0QO2a62w==} engines: {node: ^16.14.0 || >=18.0.0} @@ -8155,8 +8145,8 @@ packages: react: '*' react-native: '*' - react-native-gesture-handler@2.32.0: - resolution: {integrity: sha512-uYIMOKlKENORq2SABE+jIjbPU+h5I/sQKcq2v16zRq848nwEp1fWRVwML4QWqijc8UcXJC25o54S8GQd4Mf2OA==} + react-native-gesture-handler@3.3.0: + resolution: {integrity: sha512-ZCTlJ09nE3GPbm7J74lvwpxmx1TQ/7MDlHZNLARVYTN82k21mJUJ7BmI9eWjEi8eevHiAudI5O1Cpnt0rJfoJA==} peerDependencies: react: '*' react-native: '*' @@ -10643,10 +10633,6 @@ snapshots: transitivePeerDependencies: - encoding - '@egjs/hammerjs@2.0.17': - dependencies: - '@types/hammerjs': 2.0.46 - '@eloqnt/cli@0.6.26': dependencies: '@clack/prompts': 1.8.1 @@ -11103,7 +11089,7 @@ snapshots: metro-resolver: 0.84.5 metro-runtime: 0.84.5 metro-source-map: 0.84.5(supports-color@8.1.1) - metro-symbolicate: 0.84.5 + metro-symbolicate: 0.84.5(supports-color@8.1.1) metro-transform-plugins: 0.84.5(supports-color@8.1.1) metro-transform-worker: 0.84.5(supports-color@8.1.1) transitivePeerDependencies: @@ -13234,8 +13220,6 @@ snapshots: dependencies: '@types/node': 24.12.4 - '@types/hammerjs@2.0.46': {} - '@types/invariant@2.2.37': {} '@types/istanbul-lib-coverage@2.0.6': {} @@ -15692,10 +15676,6 @@ snapshots: hls.js@1.6.16: {} - hoist-non-react-statics@3.3.2: - dependencies: - react-is: 16.13.1 - hosted-git-info@7.0.2: dependencies: lru-cache: 10.4.3 @@ -16862,7 +16842,7 @@ snapshots: '@babel/types': 7.29.0 flow-enums-runtime: 0.0.6 invariant: 2.2.4 - metro-symbolicate: 0.84.5 + metro-symbolicate: 0.84.5(supports-color@8.1.1) nullthrows: 1.1.1 ob1: 0.84.5 source-map: 0.5.7 @@ -16870,7 +16850,7 @@ snapshots: transitivePeerDependencies: - supports-color - metro-symbolicate@0.84.5: + metro-symbolicate@0.84.5(supports-color@8.1.1): dependencies: flow-enums-runtime: 0.0.6 invariant: 2.2.4 @@ -16878,6 +16858,8 @@ snapshots: nullthrows: 1.1.1 source-map: 0.5.7 vlq: 1.0.1 + transitivePeerDependencies: + - supports-color metro-transform-plugins@0.84.5(supports-color@8.1.1): dependencies: @@ -16940,7 +16922,7 @@ snapshots: metro-resolver: 0.84.5 metro-runtime: 0.84.5 metro-source-map: 0.84.5(supports-color@8.1.1) - metro-symbolicate: 0.84.5 + metro-symbolicate: 0.84.5(supports-color@8.1.1) metro-transform-plugins: 0.84.5(supports-color@8.1.1) metro-transform-worker: 0.84.5(supports-color@8.1.1) mime-types: 3.0.2 @@ -17876,12 +17858,12 @@ snapshots: react: 19.2.3 react-native: 0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1) - ? react-native-drawer-layout@4.2.3(patch_hash=74f2c043cc22ab87054f219e7c7373a509b779b18bfa79d27e7d051d73355130)(react-native-gesture-handler@2.32.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3))(react-native-reanimated@4.6.0(f8dcf0153e1110dbdef62fe89550ce57))(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) + ? react-native-drawer-layout@4.2.3(patch_hash=2a67e397c87df9fb947b1931c9b00724b802a8dca5d3013617e6155f1ae3188e)(react-native-gesture-handler@3.3.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3))(react-native-reanimated@4.6.0(f8dcf0153e1110dbdef62fe89550ce57))(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) : dependencies: color: 4.2.3 react: 19.2.3 react-native: 0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1) - react-native-gesture-handler: 2.32.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) + react-native-gesture-handler: 3.3.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) react-native-reanimated: 4.6.0(f8dcf0153e1110dbdef62fe89550ce57) use-latest-callback: 0.2.6(react@19.2.3) @@ -17890,11 +17872,9 @@ snapshots: react: 19.2.3 react-native: 0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1) - react-native-gesture-handler@2.32.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3): + react-native-gesture-handler@3.3.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3): dependencies: - '@egjs/hammerjs': 2.0.17 '@types/react-test-renderer': 19.1.0 - hoist-non-react-statics: 3.3.2 invariant: 2.2.4 react: 19.2.3 react-native: 0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1) @@ -18477,11 +18457,11 @@ snapshots: dependencies: atomic-sleep: 1.0.0 - sonner-native@0.26.4(ac35108601b693cc2ecffbdd23315c0a): + sonner-native@0.26.4(a4fd305dda0c2e8ae37e0c92cb913d83): dependencies: react: 19.2.3 react-native: 0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1) - react-native-gesture-handler: 2.32.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) + react-native-gesture-handler: 3.3.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) react-native-reanimated: 4.6.0(f8dcf0153e1110dbdef62fe89550ce57) react-native-safe-area-context: 5.7.0(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) react-native-screens: 4.26.2(patch_hash=64db79e069eed40559b3621792683842e9785a55a8617d138459817cf27b1926)(react-native@0.86.3(patch_hash=d6c16c8305d443b2ed7969db4b7217555c7e686ac3757a0fb46fcb82ea8c40ac)(@babel/core@7.29.0(supports-color@8.1.1))(@react-native/jest-preset@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(react@19.2.3)(supports-color@8.1.1))(@react-native/metro-config@0.86.3(@babel/core@7.29.0(supports-color@8.1.1))(supports-color@8.1.1))(@types/react@19.2.18)(react@19.2.3)(supports-color@8.1.1))(react@19.2.3) diff --git a/src/components/ContextMenu/index.tsx b/src/components/ContextMenu/index.tsx index 294ddbd96..883215866 100644 --- a/src/components/ContextMenu/index.tsx +++ b/src/components/ContextMenu/index.tsx @@ -20,11 +20,12 @@ import { type ViewStyle, } from 'react-native' import { - Gesture, GestureDetector, - type GestureStateChangeEvent, - type GestureUpdateEvent, - type PanGestureHandlerEventPayload, + type PanGestureActiveEvent, + useCompetingGestures, + useExclusiveGestures, + usePanGesture, + useTapGesture, } from 'react-native-gesture-handler' import {KeyboardEvents} from 'react-native-keyboard-controller' import Animated, { @@ -299,24 +300,19 @@ export function Trigger({ } }, [context, insets]) - const tapGesture = useMemo(() => { - const gesture = Gesture.Tap() - .numberOfTaps(1) - .cancelsTouchesInView(false) - .runOnJS(true) - if (onTap) { - gesture.onEnd(() => void onTap()) - } - return gesture - }, [onTap]) + const tapGesture = useTapGesture({ + numberOfTaps: 1, + cancelsTouchesInView: false, + runOnJS: true, + onDeactivate: onTap ? () => void onTap() : undefined, + }) - const doubleTapGesture = useMemo(() => { - return Gesture.Tap() - .numberOfTaps(2) - .hitSlop(HITSLOP_10) - .onEnd(() => void open('auxiliary-only')) - .runOnJS(true) - }, [open]) + const doubleTapGesture = useTapGesture({ + numberOfTaps: 2, + hitSlop: HITSLOP_10, + runOnJS: true, + onDeactivate: () => void open('auxiliary-only'), + }) const { hoverablesSV, @@ -336,34 +332,33 @@ export function Trigger({ }, ) - const pressAndHoldGesture = useMemo(() => { - return Gesture.Pan() - .activateAfterLongPress(500) - .cancelsTouchesInView(false) - .averageTouches(true) - .onStart(() => { - 'worklet' - scheduleOnRN(open, 'full') - }) - .onUpdate(evt => { - 'worklet' - const item = getHoveredHoverable(evt, hoverablesSV, translationSV) - hoveredItemSV.set(item) - }) - .onEnd(() => { - 'worklet' - // don't recalculate hovered item - if they haven't moved their finger from - // the initial press, it's jarring to then select the item underneath - // as the menu may have slid into place beneath their finger - const item = hoveredItemSV.get() - if (item) { - scheduleOnRN(onTouchUpMenuItem, item) - } - }) - }, [open, hoverablesSV, onTouchUpMenuItem, hoveredItemSV, translationSV]) + const pressAndHoldGesture = usePanGesture({ + activateAfterLongPress: 500, + cancelsTouchesInView: false, + averageTouches: true, + onActivate: () => { + 'worklet' + scheduleOnRN(open, 'full') + }, + onUpdate: evt => { + 'worklet' + const item = getHoveredHoverable(evt, hoverablesSV, translationSV) + hoveredItemSV.set(item) + }, + onDeactivate: () => { + 'worklet' + // don't recalculate hovered item - if they haven't moved their finger from + // the initial press, it's jarring to then select the item underneath + // as the menu may have slid into place beneath their finger + const item = hoveredItemSV.get() + if (item) { + scheduleOnRN(onTouchUpMenuItem, item) + } + }, + }) // Order matters here: doubleTapGesture must come before tapGesture. - const tapAndHoldGestures = Gesture.Exclusive( + const tapAndHoldGestures = useExclusiveGestures( doubleTapGesture, tapGesture, pressAndHoldGesture, @@ -371,11 +366,13 @@ export function Trigger({ // An optional swipe gesture (e.g. swipe-to-reply) races against the tap/hold // group: whichever activates first wins and cancels the rest, so they're - // mutually exclusive. Race (not Exclusive) avoids a held-but-not-yet-moved + // mutually exclusive. Competing (not Exclusive) avoids a held-but-not-yet-moved // swipe Pan blocking the long-press from firing. - const composedGestures = swipeGesture - ? Gesture.Race(swipeGesture, tapAndHoldGestures) - : tapAndHoldGestures + const composedGestures = useCompetingGestures( + ...(swipeGesture + ? [swipeGesture, tapAndHoldGestures] + : [tapAndHoldGestures]), + ) const measurement = context.measurement || pendingMeasurement?.measurement @@ -990,9 +987,7 @@ function measureView( } function getHoveredHoverable( - evt: - | GestureStateChangeEvent - | GestureUpdateEvent, + evt: PanGestureActiveEvent, hoverables: SharedValue>, translation: SharedValue, ) { diff --git a/src/components/ContextMenu/types.ts b/src/components/ContextMenu/types.ts index 6fb97b681..79a758234 100644 --- a/src/components/ContextMenu/types.ts +++ b/src/components/ContextMenu/types.ts @@ -4,7 +4,7 @@ import { type StyleProp, type ViewStyle, } from 'react-native' -import {type GestureType} from 'react-native-gesture-handler' +import {type PanGesture} from 'react-native-gesture-handler' import {type SharedValue} from 'react-native-reanimated' import type * as Dialog from '#/components/Dialog' @@ -89,7 +89,7 @@ export type TriggerProps = { style?: StyleProp /** * Callback for single taps. Composed with the double-tap and - * press-and-hold gestures via `Gesture.Exclusive`, so a double tap + * press-and-hold gestures via `useExclusiveGestures`, so a double tap * does not also fire this handler. * * @platform ios, android @@ -97,12 +97,13 @@ export type TriggerProps = { onTap?: () => void /** * An optional gesture (e.g. swipe-to-reply) composed into the same - * arbitration group as the tap and press-and-hold gestures via `Gesture.Race`, - * making it mutually exclusive with them - only one can win a given touch. + * arbitration group as the tap and press-and-hold gestures via + * `useCompetingGestures`, making it mutually exclusive with them - only one + * can win a given touch. * * @platform ios, android */ - swipeGesture?: GestureType + swipeGesture?: PanGesture } export type TriggerChildProps = | { diff --git a/src/components/DraggableList/index.tsx b/src/components/DraggableList/index.tsx index ebdf621b9..9a6c988ab 100644 --- a/src/components/DraggableList/index.tsx +++ b/src/components/DraggableList/index.tsx @@ -1,5 +1,5 @@ import {useLayoutEffect, useRef} from 'react' -import {Gesture, GestureDetector} from 'react-native-gesture-handler' +import {GestureDetector, usePanGesture} from 'react-native-gesture-handler' import Animated, { type AnimatedRef, measure, @@ -253,8 +253,8 @@ function SortableItem({ const lastHapticSlot = useSharedValue(-1) - const gesture = Gesture.Pan() - .onStart(() => { + const gesture = usePanGesture({ + onActivate: () => { 'worklet' const s = state.get() const mySlot = s.slots[itemKey] @@ -268,8 +268,8 @@ function SortableItem({ scheduleOnRN(onDragStart) } scheduleOnRN(playHaptic) - }) - .onChange(e => { + }, + onUpdate: e => { 'worklet' const startSlot = state.get().dragStartSlot const minY = -startSlot * itemHeight @@ -287,8 +287,8 @@ function SortableItem({ lastHapticSlot.set(clampedSlot) scheduleOnRN(playHaptic, 'Light') } - }) - .onEnd(() => { + }, + onDeactivate: () => { 'worklet' // Stop auto-scroll BEFORE the snap animation. isGestureActive.set(false) @@ -338,9 +338,9 @@ function SortableItem({ } }), ) - }) - // Reset if the gesture is cancelled without onEnd firing. - .onFinalize(() => { + }, + // Reset if the gesture is cancelled without onDeactivate firing. + onFinalize: () => { 'worklet' isGestureActive.set(false) if (state.get().activeKey === itemKey && dragY.get() === 0) { @@ -350,7 +350,8 @@ function SortableItem({ scheduleOnRN(onDragEnd) } } - }) + }, + }) // All vertical positioning is via translateY (no `top`). This avoids // discrete jumps when slots change — Reanimated smoothly animates from diff --git a/src/components/Lightbox/pager/ImageItem/ImageItem.android.tsx b/src/components/Lightbox/pager/ImageItem/ImageItem.android.tsx index 6227eeb58..b2ae890e5 100644 --- a/src/components/Lightbox/pager/ImageItem/ImageItem.android.tsx +++ b/src/components/Lightbox/pager/ImageItem/ImageItem.android.tsx @@ -1,9 +1,13 @@ import {memo, useState} from 'react' import {ActivityIndicator, StyleSheet} from 'react-native' import { - Gesture, GestureDetector, type PanGesture, + useExclusiveGestures, + usePanGesture, + usePinchGesture, + useSimultaneousGestures, + useTapGesture, } from 'react-native-gesture-handler' import Animated, { type AnimatableValue, @@ -137,16 +141,26 @@ const ImageItem = ({ return [dx, dy] } - const pinch = Gesture.Pinch() - .onStart(e => { + /* + * Gestures are disabled while the parent pager is being dragged. Toggle + * `enabled` instead of swapping in a no-op gesture: in RNGH v3, switching + * the detector between a worklet and a non-worklet gesture changes its + * native component type, which remounts the image and blinks it out for a + * frame. + */ + const enabled = !isScrollViewBeingDragged + + const pinch = usePinchGesture({ + enabled, + onActivate: e => { 'worklet' const screenSize = measureSafeArea() pinchOrigin.set({ x: e.focalX - screenSize.width / 2, y: e.focalY - screenSize.height / 2, }) - }) - .onChange(e => { + }, + onUpdate: e => { 'worklet' const screenSize = measureSafeArea() if (!imageDimensions) { @@ -181,8 +195,8 @@ const ImageItem = ({ y: pt.y + dy, }) } - }) - .onEnd(() => { + }, + onDeactivate: () => { 'worklet' // Commit just the pinch. let t = createTransform() @@ -200,13 +214,15 @@ const ImageItem = ({ pinchScale.set(1) pinchOrigin.set({x: 0, y: 0}) pinchTranslation.set({x: 0, y: 0}) - }) + }, + }) - const pan = Gesture.Pan() - .averageTouches(true) - // Unlike .enabled(isScaled), this ensures that an initial pinch can turn into a pan midway: - .minPointers(isScaled ? 1 : 2) - .onChange(e => { + const pan = usePanGesture({ + enabled, + averageTouches: true, + // Unlike enabled: isScaled, this ensures that an initial pinch can turn into a pan midway: + minPointers: isScaled ? 1 : 2, + onUpdate: e => { 'worklet' const screenSize = measureSafeArea() if (!imageDimensions) { @@ -229,8 +245,8 @@ const ImageItem = ({ nextPanTranslation.x += dx nextPanTranslation.y += dy panTranslation.set(nextPanTranslation) - }) - .onEnd(() => { + }, + onDeactivate: () => { 'worklet' // Commit just the pan. let t = createTransform() @@ -241,16 +257,21 @@ const ImageItem = ({ // Reset just the pan. panTranslation.set({x: 0, y: 0}) - }) + }, + }) - const singleTap = Gesture.Tap().onEnd(() => { - 'worklet' - scheduleOnRN(onTap) + const singleTap = useTapGesture({ + enabled, + onDeactivate: () => { + 'worklet' + scheduleOnRN(onTap) + }, }) - const doubleTap = Gesture.Tap() - .numberOfTaps(2) - .onEnd(e => { + const doubleTap = useTapGesture({ + enabled, + numberOfTaps: 2, + onDeactivate: e => { 'worklet' const screenSize = measureSafeArea() if (!imageDimensions || !imageAspect) { @@ -295,17 +316,17 @@ const ImageItem = ({ const finalTransform = createTransform() prependPinch(finalTransform, scale, origin, {x: dx, y: dy}) committedTransform.set(withClampedSpring(finalTransform)) - }) - - const composedGesture = isScrollViewBeingDragged - ? // If the parent is not at rest, provide a no-op gesture. - Gesture.Manual() - : Gesture.Exclusive( - dismissSwipePan, - Gesture.Simultaneous(pinch, pan), - doubleTap, - singleTap, - ) + }, + }) + + const pinchAndPan = useSimultaneousGestures(pinch, pan) + + const composedGesture = useExclusiveGestures( + dismissSwipePan, + pinchAndPan, + doubleTap, + singleTap, + ) const containerStyle = useAnimatedStyle(() => { const {scaleAndMoveTransform, isHidden} = transforms.get() diff --git a/src/components/Lightbox/pager/ImageItem/ImageItem.ios.tsx b/src/components/Lightbox/pager/ImageItem/ImageItem.ios.tsx index c4a842a74..e5df270f6 100644 --- a/src/components/Lightbox/pager/ImageItem/ImageItem.ios.tsx +++ b/src/components/Lightbox/pager/ImageItem/ImageItem.ios.tsx @@ -9,9 +9,10 @@ import {memo, useState} from 'react' import {ActivityIndicator, StyleSheet} from 'react-native' import { - Gesture, GestureDetector, type PanGesture, + useExclusiveGestures, + useTapGesture, } from 'react-native-gesture-handler' import Animated, { type SharedValue, @@ -115,14 +116,16 @@ const ImageItem = ({ }) } - const singleTap = Gesture.Tap().onEnd(() => { - 'worklet' - scheduleOnRN(onTap) + const singleTap = useTapGesture({ + onDeactivate: () => { + 'worklet' + scheduleOnRN(onTap) + }, }) - const doubleTap = Gesture.Tap() - .numberOfTaps(2) - .onEnd(e => { + const doubleTap = useTapGesture({ + numberOfTaps: 2, + onDeactivate: e => { 'worklet' const screenSize = measureSafeArea() const {absoluteX, absoluteY} = e @@ -142,9 +145,10 @@ const ImageItem = ({ ) } scheduleOnRN(zoomTo, nextZoomRect) - }) + }, + }) - const composedGesture = Gesture.Exclusive( + const composedGesture = useExclusiveGestures( dismissSwipePan, doubleTap, singleTap, diff --git a/src/components/Lightbox/pager/ImagePager.tsx b/src/components/Lightbox/pager/ImagePager.tsx index b46f047e6..249360685 100644 --- a/src/components/Lightbox/pager/ImagePager.tsx +++ b/src/components/Lightbox/pager/ImagePager.tsx @@ -10,7 +10,7 @@ import {useCallback, useEffect, useMemo, useState} from 'react' import {PixelRatio, StyleSheet, useWindowDimensions, View} from 'react-native' import {SystemBars} from 'react-native-edge-to-edge' -import {Gesture} from 'react-native-gesture-handler' +import {usePanGesture} from 'react-native-gesture-handler' import PagerView, { type PagerViewOnPageSelectedEvent, type PageScrollStateChangedNativeEvent, @@ -566,19 +566,19 @@ function LightboxImage({ } }) - const dismissSwipePan = Gesture.Pan() - .enabled(isActive && !isScaled) - .activeOffsetY([-10, 10]) - .failOffsetX([-10, 10]) - .maxPointers(1) - .onUpdate(e => { + const dismissSwipePan = usePanGesture({ + enabled: isActive && !isScaled && !isScrollViewBeingDragged, + activeOffsetY: [-10, 10], + failOffsetX: [-10, 10], + maxPointers: 1, + onUpdate: e => { 'worklet' if (openProgress.get() !== 1 || isFlyingAway.get()) { return } dismissSwipeTranslateY.set(e.translationY) - }) - .onEnd(e => { + }, + onDeactivate: e => { 'worklet' if (openProgress.get() !== 1 || isFlyingAway.get()) { return @@ -608,7 +608,8 @@ function LightboxImage({ }), ) } - }) + }, + }) return ( { const {t: l, i18n} = useLingui() const ax = useAnalytics() diff --git a/src/components/dms/SwipeToReply.tsx b/src/components/dms/SwipeToReply.tsx index dbdbf9fd6..858e8ecc6 100644 --- a/src/components/dms/SwipeToReply.tsx +++ b/src/components/dms/SwipeToReply.tsx @@ -1,6 +1,5 @@ -import {useMemo} from 'react' import {View} from 'react-native' -import {Gesture, type GestureType} from 'react-native-gesture-handler' +import {type PanGesture, usePanGesture} from 'react-native-gesture-handler' import Animated, { clamp, interpolate, @@ -52,8 +51,9 @@ function applyResistance(value: number) { * * The pan gesture is built here but handed to `children` via a render prop so * the consumer can compose it into the message's context-menu gestures with - * `Gesture.Exclusive`. Sharing one arbitration group is what makes the swipe - * and the long-press mutually exclusive - only one can ever win the touch. + * `useCompetingGestures`. Sharing one arbitration group is what makes the + * swipe and the long-press mutually exclusive - only one can ever win the + * touch. */ export function SwipeToReply({ isFromSelf, @@ -64,7 +64,7 @@ export function SwipeToReply({ isFromSelf: boolean onReply: () => void enabled?: boolean - children: (swipeGesture: GestureType) => React.ReactNode + children: (swipeGesture: PanGesture) => React.ReactNode }) { const t = useTheme() const playHaptic = useHaptics() @@ -74,73 +74,56 @@ export function SwipeToReply({ const hit = useSharedValue(false) const iconScale = useSharedValue(1) - const swipeGesture = useMemo(() => { - const runPop = () => { - 'worklet' - if (isReducedMotion) return - iconScale.set( - withSequence( - withTiming(1.2, {duration: 175}), - withTiming(1, {duration: 100}), - ), - ) - } - - return ( - Gesture.Pan() - .enabled(enabled) - // Arm only on the inward axis; the outward direction is effectively - // disabled so the bubble can't be dragged off its own edge. - .activeOffsetX( - isFromSelf - ? [-10, EFFECTIVELY_DISABLED_OFFSET] - : [-EFFECTIVELY_DISABLED_OFFSET, 10], - ) - .activeOffsetY([ - -EFFECTIVELY_DISABLED_OFFSET, - EFFECTIVELY_DISABLED_OFFSET, - ]) - .onChange(e => { - 'worklet' - const dir = isFromSelf - ? Math.min(e.translationX, 0) - : Math.max(e.translationX, 0) - transX.set(applyResistance(dir)) - - const pastThreshold = Math.abs(transX.get()) >= ACTIVATION_THRESHOLD - if (pastThreshold && !hit.get()) { - hit.set(true) - runPop() - scheduleOnRN(playHaptic, 'Medium') - } else if (!pastThreshold && hit.get()) { - hit.set(false) - } - }) - .onEnd(() => { - 'worklet' - // Only a clean end (finger lifted past threshold) triggers the reply. - if (hit.get()) { - scheduleOnRN(onReply) - } - }) - .onFinalize(() => { - 'worklet' - // Runs on both end and cancellation, so the bubble always animates - // home even if the gesture is interrupted mid-swipe. - transX.set(withTiming(0, {duration: 200})) - hit.set(false) - }) + const runPop = () => { + 'worklet' + if (isReducedMotion) return + iconScale.set( + withSequence( + withTiming(1.2, {duration: 175}), + withTiming(1, {duration: 100}), + ), ) - }, [ - isFromSelf, + } + + const swipeGesture = usePanGesture({ enabled, - onReply, - playHaptic, - isReducedMotion, - transX, - hit, - iconScale, - ]) + // Arm only on the inward axis; the outward direction is effectively + // disabled so the bubble can't be dragged off its own edge. + activeOffsetX: isFromSelf + ? [-10, EFFECTIVELY_DISABLED_OFFSET] + : [-EFFECTIVELY_DISABLED_OFFSET, 10], + failOffsetY: [-10, 10], + onUpdate: e => { + 'worklet' + const dir = isFromSelf + ? Math.min(e.translationX, 0) + : Math.max(e.translationX, 0) + transX.set(applyResistance(dir)) + + const pastThreshold = Math.abs(transX.get()) >= ACTIVATION_THRESHOLD + if (pastThreshold && !hit.get()) { + hit.set(true) + runPop() + scheduleOnRN(playHaptic, 'Medium') + } else if (!pastThreshold && hit.get()) { + hit.set(false) + } + }, + onDeactivate: () => { + 'worklet' + // Only a clean end (finger lifted past threshold) triggers the reply. + if (hit.get()) { + scheduleOnRN(onReply) + } + }, + onFinalize: () => { + 'worklet' + // Runs on both end and cancellation, so the bubble always animates + // home even if the gesture is interrupted mid-swipe. + transX.set(withTiming(0, {duration: 200})) + hit.set(false) + }, + }) const contentStyle = useAnimatedStyle(() => ({ transform: [{translateX: transX.get()}], diff --git a/src/lib/custom-animations/GestureActionView.tsx b/src/lib/custom-animations/GestureActionView.tsx index 6f3efcf4b..ea4e744be 100644 --- a/src/lib/custom-animations/GestureActionView.tsx +++ b/src/lib/custom-animations/GestureActionView.tsx @@ -1,6 +1,6 @@ import {useMemo, useState} from 'react' import {type ColorValue, Dimensions, View} from 'react-native' -import {Gesture, GestureDetector} from 'react-native-gesture-handler' +import {GestureDetector, usePanGesture} from 'react-native-gesture-handler' import Animated, { clamp, interpolate, @@ -106,17 +106,17 @@ export function GestureActionView({ // Absurdly high value so it doesn't interfere with the pan gestures above (i.e., scroll) // reanimated doesn't offer great support for disabling y/x axes :/ const effectivelyDisabledOffset = 200 - const panGesture = Gesture.Pan() - .activeOffsetX([ + const panGesture = usePanGesture({ + activeOffsetX: [ actions.leftFirst ? -10 : -effectivelyDisabledOffset, actions.rightFirst ? 10 : effectivelyDisabledOffset, - ]) - .activeOffsetY([-effectivelyDisabledOffset, effectivelyDisabledOffset]) - .onStart(() => { + ], + failOffsetY: [-10, 10], + onActivate: () => { 'worklet' isActive.set(true) - }) - .onChange(e => { + }, + onUpdate: e => { 'worklet' transX.set(e.translationX) @@ -189,8 +189,8 @@ export function GestureActionView({ } } } - }) - .onEnd(e => { + }, + onDeactivate: e => { 'worklet' if (e.translationX < 0) { if (hitSecond.get() && actions.leftSecond) { @@ -209,9 +209,8 @@ export function GestureActionView({ hitFirst.set(false) hitSecond.set(false) isActive.set(false) - }) - - const composedGesture = Gesture.Simultaneous(panGesture) + }, + }) const animatedSliderStyle = useAnimatedStyle(() => { return { @@ -286,7 +285,7 @@ export function GestureActionView({ }) return ( - + { - return Gesture.Pan() - .blocksExternalGesture(scrollGesture) - .activeOffsetX([-10, 10]) - .failOffsetY([-10, 10]) - .onStart(() => { - 'worklet' - seekProgressSV.set(currentTimeSV.get()) - isSeekingSV.set(true) - seekingAnimationSV.set(withTiming(1, {duration: 500})) - }) - .onUpdate(evt => { - 'worklet' - const progress = evt.x / screenWidth - seekProgressSV.set( - clamp(progress * durationSV.get(), 0, durationSV.get()), - ) - }) - .onEnd(evt => { - 'worklet' - isSeekingSV.get() + const scrubPanGesture = usePanGesture({ + block: scrollGesture, + activeOffsetX: [-10, 10], + failOffsetY: [-10, 10], + onActivate: () => { + 'worklet' + seekProgressSV.set(currentTimeSV.get()) + isSeekingSV.set(true) + seekingAnimationSV.set(withTiming(1, {duration: 500})) + }, + onUpdate: evt => { + 'worklet' + const progress = evt.x / screenWidth + seekProgressSV.set( + clamp(progress * durationSV.get(), 0, durationSV.get()), + ) + }, + onDeactivate: evt => { + 'worklet' + isSeekingSV.get() - const progress = evt.x / screenWidth - const newTime = clamp(progress * durationSV.get(), 0, durationSV.get()) + const progress = evt.x / screenWidth + const newTime = clamp(progress * durationSV.get(), 0, durationSV.get()) - // optimisically set the progress bar - seekProgressSV.set(newTime) + // optimisically set the progress bar + seekProgressSV.set(newTime) - // it's seek by, so offset by the current time - // seekBy sets isSeekingSV back to false, so no need to do that here - scheduleOnRN(seekBy, newTime - currentTimeSV.get()) - }) - }, [ - scrollGesture, - seekingAnimationSV, - seekBy, - screenWidth, - currentTimeSV, - durationSV, - isSeekingSV, - seekProgressSV, - ]) + // it's seek by, so offset by the current time + // seekBy sets isSeekingSV back to false, so no need to do that here + scheduleOnRN(seekBy, newTime - currentTimeSV.get()) + }, + }) const timeStyle = useAnimatedStyle(() => { return { diff --git a/src/screens/VideoFeed/index.tsx b/src/screens/VideoFeed/index.tsx index 9c662fdf1..172a62958 100644 --- a/src/screens/VideoFeed/index.tsx +++ b/src/screens/VideoFeed/index.tsx @@ -7,9 +7,9 @@ import { View, } from 'react-native' import { - Gesture, GestureDetector, type NativeGesture, + useNativeGesture, } from 'react-native-gesture-handler' import Animated, { useAnimatedStyle, @@ -258,7 +258,7 @@ function Feed() { const [currentIndex, setCurrentIndex] = useState(0) - const scrollGesture = useMemo(() => Gesture.Native(), []) + const scrollGesture = useNativeGesture() const renderItem: ListRenderItem = useCallback( ({item, index}) => { diff --git a/src/state/global-gesture-events/index.tsx b/src/state/global-gesture-events/index.tsx index 4d3e9795d..40ed79223 100644 --- a/src/state/global-gesture-events/index.tsx +++ b/src/state/global-gesture-events/index.tsx @@ -1,19 +1,18 @@ import {createContext, useContext, useMemo, useRef, useState} from 'react' import {type StyleProp, View, type ViewStyle} from 'react-native' import { - Gesture, GestureDetector, - type GestureStateChangeEvent, - type GestureUpdateEvent, - type PanGestureHandlerEventPayload, + type PanGestureActiveEvent, + type PanGestureEvent, + usePanGesture, } from 'react-native-gesture-handler' import {EventEmitter} from 'eventemitter3' export type GlobalGestureEvents = { - begin: GestureStateChangeEvent - update: GestureUpdateEvent - end: GestureStateChangeEvent - finalize: GestureStateChangeEvent + begin: PanGestureEvent + update: PanGestureActiveEvent + end: PanGestureActiveEvent & {canceled: boolean} + finalize: PanGestureEvent & {canceled: boolean} } const Context = createContext<{ @@ -55,22 +54,22 @@ export function GlobalGestureEventsProvider({ }), [events, setEnabled], ) - const gesture = Gesture.Pan() - .runOnJS(true) - .enabled(enabled) - .simultaneousWithExternalGesture() - .onBegin(e => { + const gesture = usePanGesture({ + runOnJS: true, + enabled, + onBegin: e => { events.emit('begin', e) - }) - .onUpdate(e => { + }, + onUpdate: e => { events.emit('update', e) - }) - .onEnd(e => { + }, + onDeactivate: e => { events.emit('end', e) - }) - .onFinalize(e => { + }, + onFinalize: e => { events.emit('finalize', e) - }) + }, + }) return ( diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx index 053949490..ece3364d4 100644 --- a/src/view/shell/index.tsx +++ b/src/view/shell/index.tsx @@ -1,8 +1,7 @@ -import {useCallback, useEffect, useState} from 'react' +import {useCallback, useEffect} from 'react' import {BackHandler, useWindowDimensions, View} from 'react-native' import {Drawer} from 'react-native-drawer-layout' import {SystemBars} from 'react-native-edge-to-edge' -import {Gesture} from 'react-native-gesture-handler' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {BottomSheetOutlet} from '@bsky.app/bottom-sheet' import {updateActiveViewAsync} from '@bsky.app/expo-bluesky-swiss-army/src/VisibilityView' @@ -143,7 +142,6 @@ function DrawerLayout({children}: {children: React.ReactNode}) { const {hasSession} = useSession() const swipeEnabled = !canGoBack && hasSession && !isDrawerSwipeDisabled - const [trendingScrollGesture] = useState(() => Gesture.Native()) const renderDrawerContent = useCallback(() => , []) const onOpenDrawer = useCallback( @@ -160,8 +158,6 @@ function DrawerLayout({children}: {children: React.ReactNode}) { renderDrawerContent={renderDrawerContent} drawerStyle={{width: Math.min(400, winDim.width * 0.8)}} configureGestureHandler={handler => { - handler = handler.requireExternalGestureToFail(trendingScrollGesture) - if (swipeEnabled) { if (isDrawerOpen) { return handler.activeOffsetX([-1, 1]) -- knotmirror 0.0.1