-
Notifications
You must be signed in to change notification settings - Fork 424
/
BasicPagerViewExample.tsx
61 lines (55 loc) · 1.54 KB
/
BasicPagerViewExample.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
import React, { useMemo } from 'react';
import { StyleSheet, View, SafeAreaView, Animated, Text } from 'react-native';
import PagerView from 'react-native-pager-view';
import { LikeCount } from './component/LikeCount';
import { NavigationPanel } from './component/NavigationPanel';
import { useNavigationPanel } from './hook/useNavigationPanel';
const AnimatedPagerView = Animated.createAnimatedComponent(PagerView);
export function BasicPagerViewExample() {
const { ref, ...navigationPanel } = useNavigationPanel();
return (
<SafeAreaView style={styles.container}>
<AnimatedPagerView
{...navigationPanel}
testID="pager-view"
ref={ref}
style={styles.PagerView}
initialPage={0}
pageMargin={10}
>
{useMemo(
() =>
navigationPanel.pages.map((page, index) => (
<View
testID="pager-view-content"
key={page.key}
style={page.style}
collapsable={false}
>
<LikeCount />
<Text
testID={`pageNumber${index}`}
>{`page number ${index}`}</Text>
</View>
)),
[navigationPanel.pages]
)}
</AnimatedPagerView>
<NavigationPanel {...navigationPanel} />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'white',
},
image: {
width: 300,
height: 200,
padding: 20,
},
PagerView: {
flex: 1,
},
});