Skip to content

Commit f10ba40

Browse files
committed
Update example
1 parent 6e64fba commit f10ba40

9 files changed

Lines changed: 136 additions & 598 deletions

apps/basic-example/src/App.tsx

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,51 @@
11
import * as React from 'react';
2-
import { Animated, Button, useAnimatedValue } from 'react-native';
3-
import {
4-
GestureHandlerRootView,
5-
NativeDetector,
6-
useGesture,
7-
} from 'react-native-gesture-handler';
2+
import { SafeAreaView, Platform } from 'react-native';
3+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
84

9-
export default function App() {
10-
const [visible, setVisible] = React.useState(true);
11-
12-
const value = useAnimatedValue(0);
13-
const event = Animated.event(
14-
[{ nativeEvent: { handlerData: { translationX: value } } }],
15-
{
16-
useNativeDriver: true,
17-
}
18-
);
5+
import Navigator from './Navigator';
196

20-
const tap = useGesture('PanGestureHandler', {
21-
// numberOfTaps: 2,
22-
// needsPointerData: true,
23-
// onGestureHandlerStateChange: (event) => {
24-
// console.log('onHandlerStateChange', event.nativeEvent);
25-
// },
26-
onGestureHandlerAnimatedEvent: event,
27-
onGestureHandlerEvent: (e: any) =>
28-
console.log('onGestureHandlerEvent', e.nativeEvent),
29-
// onGestureHandlerTouchEvent: (event) => console.log('onGestureTouchEvent', event.nativeEvent),
30-
});
7+
import NativeDetector from './NativeDetector';
8+
import RuntimeDecoration from './RuntimeDecoration';
319

32-
return (
33-
<GestureHandlerRootView
34-
style={{ flex: 1, backgroundColor: 'white', paddingTop: 150 }}>
35-
<Button
36-
title="Toggle"
37-
onPress={() => {
38-
setVisible(!visible);
39-
}}
40-
/>
10+
const EXAMPLES = [
11+
{
12+
name: 'Runtime Decoration',
13+
component: RuntimeDecoration,
14+
},
15+
{
16+
name: 'Native Detector',
17+
component: NativeDetector,
18+
},
19+
];
4120

42-
{visible && (
43-
<NativeDetector gesture={tap}>
44-
<Animated.View
45-
style={[
46-
{
47-
width: 150,
48-
height: 150,
49-
backgroundColor: 'blue',
50-
opacity: 0.5,
51-
borderWidth: 10,
52-
borderColor: 'green',
53-
marginTop: 20,
54-
marginLeft: 40,
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+
);
5536
},
56-
{ transform: [{ translateX: value }] },
57-
]}
58-
/>
59-
</NativeDetector>
60-
)}
37+
},
38+
])
39+
)
40+
);
41+
42+
export default function App() {
43+
return (
44+
<GestureHandlerRootView style={{ flex: 1 }}>
45+
<SafeAreaView
46+
style={[{ flex: 1 }, Platform.OS === 'android' && { paddingTop: 50 }]}>
47+
<Stack.Navigator />
48+
</SafeAreaView>
6149
</GestureHandlerRootView>
6250
);
6351
}

apps/basic-example/src/ComponentsScreen.tsx

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

apps/basic-example/src/FinalScreen.tsx

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

0 commit comments

Comments
 (0)