forked from benevbright/react-navigation-collapsible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomHeaderScreen.tsx
54 lines (48 loc) · 1.38 KB
/
CustomHeaderScreen.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
50
51
52
53
54
import * as React from 'react';
import { Text, TouchableOpacity, Animated } from 'react-native';
import { StackNavigationProp } from '@react-navigation/stack';
import { useCollapsibleStack } from 'react-navigation-collapsible';
import { StackParamList } from '../App';
const data: number[] = [];
for (let i = 0; i < 100; i++) {
data.push(i);
}
type ScreenProps = {
navigation: StackNavigationProp<StackParamList>;
};
const CustomHeaderScreen = ({ navigation }: ScreenProps) => {
const {
onScroll,
containerPaddingTop,
scrollIndicatorInsetTop,
} = useCollapsibleStack();
return (
<Animated.FlatList
data={data}
onScroll={onScroll}
contentContainerStyle={{ paddingTop: containerPaddingTop }}
scrollIndicatorInsets={{ top: scrollIndicatorInsetTop }}
renderItem={({ item }: any) => (
<TouchableOpacity
onPress={() => navigation.navigate('CustomHeaderDetail')}
style={{
width: '100%',
height: 50,
alignItems: 'center',
justifyContent: 'center',
borderBottomColor: 'gray',
borderBottomWidth: 1,
}}>
<Text
style={{
fontSize: 22,
}}>
{item}
</Text>
</TouchableOpacity>
)}
keyExtractor={(item: any) => item.toString()}
/>
);
};
export { CustomHeaderScreen };