Skip to content

Commit fa6a818

Browse files
authored
Implement base for a native detector component (#3599)
## Description Implements a native `RNGestureHandlerDetector` component based on `display: contents`: - The view will match the layout of its child - The lifecycle of gestures is moved to hooks instead of being managed by the detector - Detector should attach and detach native gesture handlers to itself as it's mounted or unmounted - Implements sending native events to the detector component - It's able to work with RN's Animated events TODO: - Validate that gestures are correctly attached/detached in all cases (suspense, display: none, navigation) - Validate that the gesture lifecycle is correctly managed in StrictMode - Correctly handle `NativeViewGestureHandler`, which should be attached to the child (I think) - Correctly handle the Text component - Integration with Reanimated ## Test plan Updated basic example
1 parent c278c94 commit fa6a818

File tree

67 files changed

+1427
-704
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

+1427
-704
lines changed

apps/basic-example/Gemfile.lock

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,28 @@ GEM
55
base64
66
nkf
77
rexml
8-
activesupport (7.1.4.2)
8+
activesupport (7.1.5.1)
99
base64
10+
benchmark (>= 0.3)
1011
bigdecimal
1112
concurrent-ruby (~> 1.0, >= 1.0.2)
1213
connection_pool (>= 2.2.5)
1314
drb
1415
i18n (>= 1.6, < 2)
16+
logger (>= 1.4.2)
1517
minitest (>= 5.1)
1618
mutex_m
19+
securerandom (>= 0.3)
1720
tzinfo (~> 2.0)
1821
addressable (2.8.7)
1922
public_suffix (>= 2.0.2, < 7.0)
2023
algoliasearch (1.27.5)
2124
httpclient (~> 2.8, >= 2.8.3)
2225
json (>= 1.5.1)
2326
atomos (0.1.3)
24-
base64 (0.2.0)
25-
benchmark (0.4.0)
26-
bigdecimal (3.1.9)
27+
base64 (0.3.0)
28+
benchmark (0.4.1)
29+
bigdecimal (3.2.2)
2730
claide (1.1.0)
2831
cocoapods (1.15.2)
2932
addressable (~> 2.8)
@@ -64,8 +67,8 @@ GEM
6467
cocoapods-try (1.2.0)
6568
colored2 (3.1.2)
6669
concurrent-ruby (1.3.3)
67-
connection_pool (2.5.1)
68-
drb (2.2.1)
70+
connection_pool (2.5.3)
71+
drb (2.2.3)
6972
escape (0.0.4)
7073
ethon (0.16.0)
7174
ffi (>= 1.15.0)
@@ -77,7 +80,7 @@ GEM
7780
mutex_m
7881
i18n (1.14.7)
7982
concurrent-ruby (~> 1.0)
80-
json (2.10.2)
83+
json (2.12.2)
8184
logger (1.7.0)
8285
minitest (5.25.5)
8386
molinillo (0.8.0)
@@ -89,6 +92,7 @@ GEM
8992
public_suffix (4.0.7)
9093
rexml (3.4.1)
9194
ruby-macho (2.5.1)
95+
securerandom (0.3.2)
9296
typhoeus (1.4.1)
9397
ethon (>= 0.9.0)
9498
tzinfo (2.0.6)

apps/basic-example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2678,7 +2678,7 @@ SPEC CHECKSUMS:
26782678
RNReanimated: 25060745a200605462ff56cf488411db066631ce
26792679
RNWorklets: 9bb08cb0ef718ce063f61ca18f95f57aec9b9673
26802680
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2681-
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb
2681+
Yoga: 395b5d614cd7cbbfd76b05d01bd67230a6ad004e
26822682

26832683
PODFILE CHECKSUM: d05778d3a61b8d49242579ea0aa864580fbb1f64
26842684

apps/basic-example/src/App.tsx

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,47 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
44

55
import Navigator from './Navigator';
66

7-
import ComponentsScreen from './ComponentsScreen';
8-
import FinalScreen from './FinalScreen';
9-
import GestureCompositionScreen from './GestureCompositionScreen';
10-
import HomeScreen from './HomeScreen';
11-
import ViewFlatteningScreen from './ViewFlatteningScreen';
7+
import NativeDetector from './NativeDetector';
8+
import RuntimeDecoration from './RuntimeDecoration';
129

13-
const Stack = Navigator.create();
14-
15-
Stack.setRoutes({
16-
home: {
17-
component: HomeScreen,
18-
title: 'RNGH FabricExample',
19-
rightButtonAction: () => {
20-
Stack.navigateTo('gestureComposition');
21-
},
22-
},
23-
gestureComposition: {
24-
component: GestureCompositionScreen,
25-
title: 'Gesture Composition',
26-
rightButtonAction: () => {
27-
Stack.navigateTo('components');
28-
},
29-
},
30-
components: {
31-
component: ComponentsScreen,
32-
title: 'Components',
33-
rightButtonAction: () => {
34-
Stack.navigateTo('viewFlattening');
35-
},
10+
const EXAMPLES = [
11+
{
12+
name: 'Runtime Decoration',
13+
component: RuntimeDecoration,
3614
},
37-
viewFlattening: {
38-
component: ViewFlatteningScreen,
39-
title: 'View Flattening',
40-
rightButtonAction: () => {
41-
Stack.navigateTo('final');
42-
},
15+
{
16+
name: 'Native Detector',
17+
component: NativeDetector,
4318
},
44-
final: {
45-
component: FinalScreen,
46-
title: 'Final Screen',
47-
},
48-
});
19+
];
20+
21+
const Stack = Navigator.create();
22+
Stack.setRoutes(
23+
Object.fromEntries(
24+
EXAMPLES.map((example, index) => [
25+
example.name.toLowerCase().replace(/\s+/g, ''),
26+
{
27+
component: example.component,
28+
title: example.name,
29+
rightButtonAction:
30+
index === EXAMPLES.length - 1
31+
? undefined
32+
: () => {
33+
Stack.navigateTo(
34+
EXAMPLES[index + 1].name.toLowerCase().replace(/\s+/g, '')
35+
);
36+
},
37+
},
38+
])
39+
)
40+
);
4941

5042
export default function App() {
5143
return (
5244
<GestureHandlerRootView style={{ flex: 1 }}>
5345
<SafeAreaView
5446
style={[{ flex: 1 }, Platform.OS === 'android' && { paddingTop: 50 }]}>
55-
<Stack.Navigator initialRouteName="home" />
47+
<Stack.Navigator />
5648
</SafeAreaView>
5749
</GestureHandlerRootView>
5850
);

apps/basic-example/src/ComponentsScreen.tsx

Lines changed: 0 additions & 193 deletions
This file was deleted.

0 commit comments

Comments
 (0)