forked from JungHsuan/react-native-collapsible-tabview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
90 lines (85 loc) · 2.2 KB
/
App.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
82
83
84
85
86
87
88
89
90
import React, {useState} from 'react';
import {
View,
SafeAreaView,
TouchableOpacity,
Text,
StyleSheet,
} from 'react-native';
import CollapsibleTabView from './src/CollapsibleTabView';
import HeaderScrollableTabView from './src/HeaderScrollableTabView';
import PullRefreshTabView from './src/PullRefreshTabView';
const App = () => {
const [mode, setMode] = useState('collapsible');
const renderDemo = () => {
switch (mode) {
case 'collapsible':
return <CollapsibleTabView />;
case 'scrollable':
return <HeaderScrollableTabView />;
case 'refresh':
return <PullRefreshTabView />;
}
};
return (
<SafeAreaView style={{flex: 1}}>
{renderDemo()}
<View style={styles.container}>
{/* collapsible */}
<TouchableOpacity
onPress={() => setMode('collapsible')}
style={{...styles.button}}>
<Text
style={{
textAlign: 'center',
color: mode === 'collapsible' ? 'red' : 'black',
}}>
Collapsible
</Text>
</TouchableOpacity>
{/* header scrollable */}
<TouchableOpacity
onPress={() => setMode('scrollable')}
style={{...styles.button}}>
<Text
style={{
textAlign: 'center',
color: mode === 'scrollable' ? 'red' : 'black',
}}>
Header Scrollable
</Text>
</TouchableOpacity>
{/* pull refresh */}
<TouchableOpacity
onPress={() => setMode('refresh')}
style={{...styles.button}}>
<Text
style={{
textAlign: 'center',
color: mode === 'refresh' ? 'red' : 'black',
}}>
pull refresh
</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'row',
padding: 16,
},
button: {
flex: 1,
height: 48,
backgroundColor: '#eee',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 24,
paddingHorizontal: 16,
},
});
export default App;