-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example.tsx
49 lines (42 loc) · 1.37 KB
/
Example.tsx
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
import * as React from 'react';
import { View, StyleSheet, Dimensions } from 'react-native';
import { SceneMap } from 'react-native-tab-view';
import { HScrollView } from 'react-native-head-tab-view'
import { CollapsibleHeaderTabView } from 'react-native-tab-view-collapsible-header'
const FirstRoute = () => (
<HScrollView index={0}>
<View style={[styles.scene, { backgroundColor: '#ff4081' }]} />
</HScrollView>
);
const SecondRoute = () => (
<HScrollView index={1}>
<View style={[styles.scene, { backgroundColor: '#673ab7' }]} />
</HScrollView>
);
const initialLayout = { width: Dimensions.get('window').width };
export default function TabViewExample() {
const [index, setIndex] = React.useState(0);
const [routes] = React.useState([
{ key: 'first', title: 'First' },
{ key: 'second', title: 'Second' },
]);
const renderScene = SceneMap({
first: FirstRoute,
second: SecondRoute,
});
return (
<CollapsibleHeaderTabView
renderScrollHeader={() => <View style={{ height: 200, backgroundColor: 'red' }} />}
navigationState={{ index, routes }}
renderScene={renderScene}
onIndexChange={setIndex}
initialLayout={initialLayout}
lazy={true}
/>
);
}
const styles = StyleSheet.create({
scene: {
flex: 1,
},
});