-
Notifications
You must be signed in to change notification settings - Fork 524
/
example.js
81 lines (75 loc) · 2.13 KB
/
example.js
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
import React, { useState } from 'react';
import {
Dimensions,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import Basic from './examples/basic';
import SectionList from './examples/sectionlist';
import PerRowConfig from './examples/per_row_config';
import StandaloneRow from './examples/standalone_row';
import SwipeToDelete from './examples/swipe_to_delete';
import SwipeValueBasedUi from './examples/swipe_value_based_ui';
import Actions from './examples/actions';
import CloseRowManually from './examples/close_row_manually';
const componentMap = {
Basic,
SectionList,
PerRowConfig,
StandaloneRow,
SwipeToDelete,
SwipeValueBasedUi,
Actions,
CloseRowManually,
};
export default function App() {
const [mode, setMode] = useState('Basic');
const renderExample = () => {
const Component = componentMap[mode];
return <Component />;
};
return (
<View style={styles.container}>
<View style={styles.switchContainer}>
{Object.keys(componentMap).map(type => (
<TouchableOpacity
key={type}
style={[
styles.switch,
{
backgroundColor:
mode === type ? 'grey' : 'white',
},
]}
onPress={() => setMode(type)}
>
<Text>{type}</Text>
</TouchableOpacity>
))}
</View>
{renderExample()}
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1,
},
switchContainer: {
flexDirection: 'row',
justifyContent: 'center',
marginVertical: 50,
flexWrap: 'wrap',
},
switch: {
alignItems: 'center',
borderWidth: 1,
borderColor: 'black',
marginVertical: 2,
paddingVertical: 10,
width: Dimensions.get('window').width / 3,
},
});