forked from software-mansion/react-native-gesture-handler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
89 lines (79 loc) · 2.1 KB
/
App.js
File metadata and controls
89 lines (79 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React from 'react';
import { Text, View, FlatList, StyleSheet, YellowBox } from 'react-native';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import { RectButton, ScrollView } from 'react-native-gesture-handler';
import Multitap from './multitap';
YellowBox.ignoreWarnings([
'Warning: isMounted(...) is deprecated',
'Module RCTImageLoader',
]);
// refers to bug in React Navigation which should be fixed soon
// https://github.com/react-navigation/react-navigation/issues/3956
const SCREENS = {
Multitap: { screen: Multitap },
};
class MainScreen extends React.Component {
static navigationOptions = {
title: '✌️ Gesture Handler Demo',
};
render() {
const data = Object.keys(SCREENS).map(key => ({ key }));
return (
<FlatList
style={styles.list}
data={data}
ItemSeparatorComponent={ItemSeparator}
renderItem={props => (
<MainScreenItem
{...props}
onPressItem={({ key }) => this.props.navigation.navigate(key)}
/>
)}
renderScrollComponent={props => <ScrollView {...props} />}
/>
);
}
}
const ItemSeparator = () => <View style={styles.separator} />;
class MainScreenItem extends React.Component {
_onPress = () => this.props.onPressItem(this.props.item);
render() {
const { key } = this.props.item;
return (
<RectButton style={styles.button} onPress={this._onPress}>
<Text style={styles.buttonText}>{SCREENS[key].title || key}</Text>
</RectButton>
);
}
}
const ExampleApp = createStackNavigator(
{
Main: { screen: MainScreen },
...SCREENS,
},
{
initialRouteName: 'Main',
}
);
const Container = createAppContainer(ExampleApp);
const styles = StyleSheet.create({
list: {
backgroundColor: '#EFEFF4',
},
separator: {
height: 1,
backgroundColor: '#DBDBE0',
},
buttonText: {
backgroundColor: 'transparent',
},
button: {
flex: 1,
height: 60,
padding: 10,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: '#fff',
},
});
export default Container;