-
Notifications
You must be signed in to change notification settings - Fork 463
Expand file tree
/
Copy pathApp.tsx
More file actions
166 lines (159 loc) · 5.77 KB
/
App.tsx
File metadata and controls
166 lines (159 loc) · 5.77 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import { enableScreens } from 'react-native-screens';
// run this before any screen render(usually in App.js)
enableScreens();
import * as React from 'react';
import {
StyleSheet,
Text,
ScrollView,
TouchableOpacity,
Button,
Alert,
I18nManager,
DevSettings,
} from 'react-native';
import { NavigationContainer, useNavigation } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { BasicPagerViewExample } from './BasicPagerViewExample';
import { KeyboardExample } from './KeyboardExample';
import { OnPageScrollExample } from './OnPageScrollExample';
import { OnPageSelectedExample } from './OnPageSelectedExample';
import { ScrollablePagerViewExample } from './ScrollablePagerViewExample';
import { ScrollViewInsideExample } from './ScrollViewInsideExample';
import HeadphonesCarouselExample from './HeadphonesCarouselExample';
import PaginationDotsExample from './PaginationDotsExample';
import { NestPagerView } from './NestPagerView';
import ScrollableTabBarExample from './tabView/ScrollableTabBarExample';
import AutoWidthTabBarExample from './tabView/AutoWidthTabBarExample';
import TabBarIconExample from './tabView/TabBarIconExample';
import CustomIndicatorExample from './tabView/CustomIndicatorExample';
import CustomTabBarExample from './tabView/CustomTabBarExample';
import CoverflowExample from './tabView/CoverflowExample';
import ReanimatedOnPageScrollExample from './ReanimatedOnPageScrollExample';
import { MaterialTopBarExample } from './MaterialTopTabExample';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { PagerHookExample } from './PagerHookExample';
const examples = [
{ component: BasicPagerViewExample, name: 'Basic Example' },
{ component: PagerHookExample, name: 'Pager Hook Example' },
{ component: KeyboardExample, name: 'Keyboard Example' },
{ component: OnPageScrollExample, name: 'OnPageScroll Example' },
{ component: OnPageSelectedExample, name: 'OnPageSelected Example' },
{ component: HeadphonesCarouselExample, name: 'Headphones Carousel Example' },
{ component: PaginationDotsExample, name: 'Pagination Dots Example' },
{ component: MaterialTopBarExample, name: 'MaterialTopBarExample' },
{
component: ScrollablePagerViewExample,
name: 'Scrollable PagerView Example',
},
{
component: ScrollViewInsideExample,
name: 'ScrollView inside PagerView Example',
},
{
component: NestPagerView,
name: 'Nest PagerView Example',
},
{ component: ScrollableTabBarExample, name: 'ScrollableTabBarExample' },
{ component: AutoWidthTabBarExample, name: 'AutoWidthTabBarExample' },
{ component: TabBarIconExample, name: 'TabBarIconExample' },
{ component: CustomIndicatorExample, name: 'CustomIndicatorExample' },
{ component: CustomTabBarExample, name: 'CustomTabBarExample' },
{
component: ReanimatedOnPageScrollExample,
name: 'Reanimated onPageScroll example',
},
{ component: CoverflowExample, name: 'CoverflowExample' },
];
function App() {
const navigation = useNavigation();
return (
<ScrollView>
{examples.map((example) => (
<TouchableOpacity
key={example.name}
testID={example.name}
style={styles.exampleTouchable}
onPress={() => {
//@ts-ignore
navigation.navigate(example.name);
}}
>
<Text style={styles.exampleText}>{example.name}</Text>
</TouchableOpacity>
))}
</ScrollView>
);
}
const Stack = createStackNavigator();
const NativeStack = createNativeStackNavigator();
export function Navigation() {
const [mode, setMode] = React.useState<'native' | 'js'>('native');
const NavigationStack = mode === 'js' ? Stack : NativeStack;
return (
<SafeAreaProvider>
<NavigationContainer>
<NavigationStack.Navigator initialRouteName="PagerView Example">
<NavigationStack.Screen
name="PagerView Example"
component={App}
options={{
title: global?.nativeFabricUIManager
? 'PagerView Example (Fabric)'
: 'PagerView Example',
headerRight: () => (
<Button
onPress={() =>
Alert.alert(
'Alert',
`Do you want to change to the ${
mode === 'js' ? 'native stack' : 'js stack'
} ?`,
[
{ text: 'No', onPress: () => {} },
{
text: 'Yes',
onPress: () => {
setMode(mode === 'js' ? 'native' : 'js');
},
},
]
)
}
title={mode === 'js' ? 'JS' : 'NATIVE'}
color="orange"
/>
),
headerLeft: () => (
<Button
title={I18nManager.getConstants().isRTL ? 'RTL' : 'LTR'}
color="orange"
onPress={() => {
I18nManager.forceRTL(!I18nManager.getConstants().isRTL);
DevSettings.reload();
}}
/>
),
}}
/>
{examples.map((example, index) => (
<NavigationStack.Screen
key={index}
name={example.name}
component={example.component}
/>
))}
</NavigationStack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
);
}
const styles = StyleSheet.create({
exampleTouchable: {
padding: 16,
},
exampleText: {
fontSize: 16,
},
});