Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/header tab view #9

Merged
merged 14 commits into from
Nov 14, 2024
80 changes: 33 additions & 47 deletions example/src/pages/PageViewExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { PageView, PageViewRef } from 'react-native-maui';

interface PageViewExampleProps {}

const tabs = ["page1", "page2", "page3"]

const PageViewExample: React.FC<PageViewExampleProps> = (props) => {
const {} = props;
const ref = useRef<PageViewRef>(null);
Expand All @@ -25,53 +27,37 @@ const PageViewExample: React.FC<PageViewExampleProps> = (props) => {
pageScrollEnabled={true}
bounces={true}
>
<View key="1" style={{ flex: 1, backgroundColor: 'orange' }}>
<Text>first page</Text>
<Text
onPress={() => {
ref.current && ref.current?.setPage(2);
}}
>
go page 3
</Text>
<Text
onPress={() => {
ref.current && ref.current?.setPageWithoutAnimation(2);
}}
>
go page 3 widthout animate
</Text>
<Text
onPress={() => {
const page = ref.current && ref.current?.getCurrentPage();
console.log(page);
}}
>
getCurrentPage
</Text>
</View>
<View key="2" style={{ flex: 1, backgroundColor: 'pink' }}>
<Text>Second page</Text>
<Text
onPress={() => {
const page = ref.current && ref.current?.getCurrentPage();
console.log(page);
}}
>
getCurrentPage
</Text>
</View>
<View key="3" style={{ flex: 1, backgroundColor: 'blue' }}>
<Text>Second page</Text>
<Text
onPress={() => {
const page = ref.current && ref.current?.getCurrentPage();
console.log(page);
}}
>
getCurrentPage
</Text>
</View>
{
tabs.map((tab, index) => {
return (
<View key={tab} style={{ flex: 1, backgroundColor: 'orange' }}>
<Text>first page</Text>
<Text
onPress={() => {
ref.current && ref.current?.setPage(2);
}}
>
go page 3
</Text>
<Text
onPress={() => {
ref.current && ref.current?.setPageWithoutAnimation(2);
}}
>
go page 3 widthout animate
</Text>
<Text
onPress={() => {
const page = ref.current && ref.current?.getCurrentPage();
console.log(page);
}}
>
getCurrentPage
</Text>
</View>
)
})
}
</PageView>
);
};
Expand Down
Loading
Loading