-
Notifications
You must be signed in to change notification settings - Fork 195
/
Copy pathindex.tsx
98 lines (91 loc) · 2.86 KB
/
index.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
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
91
92
93
94
95
96
97
98
import * as React from 'react';
import type { ScrollView } from 'react-native';
import { StatusBar, StyleSheet, Text, View, useWindowDimensions } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import {
StickyHeaderScrollView,
useStickyHeaderScrollProps,
} from 'react-native-sticky-parallax-header';
import { Tabs } from '../../components/primitiveComponents/Tabs';
import { colors, screenStyles } from '../../constants';
import { Foreground } from './Foreground';
import { HeaderBar } from './HeaderBar';
import { text } from './data';
import { simsScreenTestIDs } from './testIDs';
const PARALLAX_HEIGHT = 330;
const HEADER_BAR_HEIGHT = 92;
const SNAP_START_THRESHOLD = 50;
const SNAP_STOP_THRESHOLD = 330;
const SimsScreen: React.FC = () => {
const { width: windowWidth } = useWindowDimensions();
const {
onMomentumScrollEnd,
onScroll,
onScrollEndDrag,
scrollHeight,
scrollValue,
scrollViewRef,
} = useStickyHeaderScrollProps<ScrollView>({
parallaxHeight: PARALLAX_HEIGHT,
snapStartThreshold: SNAP_START_THRESHOLD,
snapStopThreshold: SNAP_STOP_THRESHOLD,
snapToEdge: true,
});
return (
<View style={screenStyles.screenContainer}>
<View style={[styles.headerBarContainer, { width: windowWidth }]}>
<HeaderBar scrollValue={scrollValue} />
</View>
<View style={screenStyles.stretchContainer}>
<StickyHeaderScrollView
ref={scrollViewRef}
containerStyle={screenStyles.stretchContainer}
onScroll={onScroll}
onMomentumScrollEnd={onMomentumScrollEnd}
onScrollEndDrag={onScrollEndDrag}
renderHeader={() => {
return (
<View pointerEvents="box-none" style={{ height: scrollHeight }}>
<Foreground scrollValue={scrollValue} />
</View>
);
}}
renderTabs={() => (
<View style={styles.tabContainer}>
<Tabs />
</View>
)}
showsVerticalScrollIndicator={false}
style={screenStyles.stretch}>
<SafeAreaView edges={['left', 'right', 'bottom']} style={styles.content}>
<Text style={screenStyles.text} testID={simsScreenTestIDs.contentTestID}>
{text}
</Text>
</SafeAreaView>
</StickyHeaderScrollView>
</View>
<StatusBar barStyle="light-content" backgroundColor={colors.black} translucent />
</View>
);
};
const styles = StyleSheet.create({
content: {
alignSelf: 'stretch',
},
headerBarContainer: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
alignItems: 'center',
backgroundColor: colors.transparent,
height: HEADER_BAR_HEIGHT,
flex: 1,
overflow: 'hidden',
zIndex: 3,
},
tabContainer: {
paddingTop: HEADER_BAR_HEIGHT,
},
});
export default SimsScreen;