Commit ec656ba
[iOS] Fix gestures on iOS 26 (#3756)
## Description
Some changes in #3740 required follow up.
#### Tap
Turns out that we can leave `triggerAction` in `reset` (thank you apple
for transparent docs that clearly describe what changed between 18.5 and
26 ❤️).
It also seems that double `onFinalize` issue is fixed on 26.
#### Fling
Removing `[self triggerAction]` from `reset` broke things on old iOS.
Unfortunately now swiping in different direction does not result in
calling `onFinalize` - this should be handled by `triggerAction` in
`reset`, but now by default recognizers in `reset` have `Possible` state
(once again, thank you apple 😄). To fix that we will probably have to
rewrite fling to custom logic.
#### LongPress
`LongPress` was missing on `triggerAction` call that sends `fail`.
#### Pan
In `Pan`, I've moved `triggerAction` calls from `touches*` methods to
`interactions*` methods.
## Test plan
<details>
<summary>Tested on basic-example and the following code:</summary>
```tsx
import { StyleSheet, View, Text } from 'react-native';
import {
GestureHandlerRootView,
Gesture,
GestureDetector,
GestureType,
} from 'react-native-gesture-handler';
function TestBox({
gestureType,
bgColor,
}: {
gestureType: GestureType;
bgColor: string;
}) {
const handlerName = gestureType.handlerName;
const gesture = gestureType
.onBegin(() => {
console.log(`[${handlerName}] onBegin`);
})
.onEnd(() => {
console.log(`[${handlerName}] onEnd`);
})
.onFinalize(() => {
console.log(`[${handlerName}] onFinalize`);
})
.runOnJS(true);
return (
<View style={styles.center}>
<Text>{handlerName}</Text>
<GestureDetector gesture={gesture}>
<View style={[styles.box, { backgroundColor: bgColor }]} />
</GestureDetector>
</View>
);
}
export default function App() {
return (
<GestureHandlerRootView style={[{ flex: 1, padding: 50 }, styles.center]}>
<TestBox gestureType={Gesture.Pan()} bgColor="#b58df1" />
<TestBox gestureType={Gesture.LongPress()} bgColor="#f1a85d" />
<TestBox gestureType={Gesture.Fling()} bgColor="#5df1a8" />
<TestBox gestureType={Gesture.Tap()} bgColor="#5d8ef1" />
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
center: {
display: 'flex',
justifyContent: 'space-around',
alignItems: 'center',
},
box: {
height: 100,
width: 100,
backgroundColor: '#b58df1',
borderRadius: 20,
marginBottom: 30,
},
});
```
</details>
---------
Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>1 parent cd84f44 commit ec656ba
File tree
4 files changed
+11
-12
lines changed- packages/react-native-gesture-handler/apple/Handlers
4 files changed
+11
-12
lines changedLines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| 205 | + | |
204 | 206 | | |
205 | 207 | | |
206 | 208 | | |
| |||
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | | - | |
249 | | - | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
257 | | - | |
258 | 256 | | |
259 | 257 | | |
260 | 258 | | |
| |||
Lines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | 119 | | |
121 | 120 | | |
122 | 121 | | |
| |||
131 | 130 | | |
132 | 131 | | |
133 | 132 | | |
134 | | - | |
135 | | - | |
136 | 133 | | |
137 | 134 | | |
138 | 135 | | |
| |||
144 | 141 | | |
145 | 142 | | |
146 | 143 | | |
147 | | - | |
148 | 144 | | |
149 | 145 | | |
150 | 146 | | |
| |||
204 | 200 | | |
205 | 201 | | |
206 | 202 | | |
207 | | - | |
208 | | - | |
209 | 203 | | |
210 | 204 | | |
211 | 205 | | |
212 | 206 | | |
213 | 207 | | |
214 | 208 | | |
215 | | - | |
216 | | - | |
217 | 209 | | |
218 | 210 | | |
219 | 211 | | |
| |||
251 | 243 | | |
252 | 244 | | |
253 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
254 | 250 | | |
255 | 251 | | |
256 | 252 | | |
| |||
0 commit comments