Skip to content

Commit d2e70d9

Browse files
authored
Merge pull request #9 from mahaaoo/feat/header-tab-view
Feat/header tab view
2 parents 292a730 + 9a9b657 commit d2e70d9

File tree

2 files changed

+394
-268
lines changed

2 files changed

+394
-268
lines changed

example/src/pages/PageViewExample.tsx

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { PageView, PageViewRef } from 'react-native-maui';
44

55
interface PageViewExampleProps {}
66

7+
const tabs = ["page1", "page2", "page3"]
8+
79
const PageViewExample: React.FC<PageViewExampleProps> = (props) => {
810
const {} = props;
911
const ref = useRef<PageViewRef>(null);
@@ -25,53 +27,37 @@ const PageViewExample: React.FC<PageViewExampleProps> = (props) => {
2527
pageScrollEnabled={true}
2628
bounces={true}
2729
>
28-
<View key="1" style={{ flex: 1, backgroundColor: 'orange' }}>
29-
<Text>first page</Text>
30-
<Text
31-
onPress={() => {
32-
ref.current && ref.current?.setPage(2);
33-
}}
34-
>
35-
go page 3
36-
</Text>
37-
<Text
38-
onPress={() => {
39-
ref.current && ref.current?.setPageWithoutAnimation(2);
40-
}}
41-
>
42-
go page 3 widthout animate
43-
</Text>
44-
<Text
45-
onPress={() => {
46-
const page = ref.current && ref.current?.getCurrentPage();
47-
console.log(page);
48-
}}
49-
>
50-
getCurrentPage
51-
</Text>
52-
</View>
53-
<View key="2" style={{ flex: 1, backgroundColor: 'pink' }}>
54-
<Text>Second page</Text>
55-
<Text
56-
onPress={() => {
57-
const page = ref.current && ref.current?.getCurrentPage();
58-
console.log(page);
59-
}}
60-
>
61-
getCurrentPage
62-
</Text>
63-
</View>
64-
<View key="3" style={{ flex: 1, backgroundColor: 'blue' }}>
65-
<Text>Second page</Text>
66-
<Text
67-
onPress={() => {
68-
const page = ref.current && ref.current?.getCurrentPage();
69-
console.log(page);
70-
}}
71-
>
72-
getCurrentPage
73-
</Text>
74-
</View>
30+
{
31+
tabs.map((tab, index) => {
32+
return (
33+
<View key={tab} style={{ flex: 1, backgroundColor: 'orange' }}>
34+
<Text>first page</Text>
35+
<Text
36+
onPress={() => {
37+
ref.current && ref.current?.setPage(2);
38+
}}
39+
>
40+
go page 3
41+
</Text>
42+
<Text
43+
onPress={() => {
44+
ref.current && ref.current?.setPageWithoutAnimation(2);
45+
}}
46+
>
47+
go page 3 widthout animate
48+
</Text>
49+
<Text
50+
onPress={() => {
51+
const page = ref.current && ref.current?.getCurrentPage();
52+
console.log(page);
53+
}}
54+
>
55+
getCurrentPage
56+
</Text>
57+
</View>
58+
)
59+
})
60+
}
7561
</PageView>
7662
);
7763
};

0 commit comments

Comments
 (0)