-
-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathindex.tsx
More file actions
112 lines (105 loc) · 2.59 KB
/
index.tsx
File metadata and controls
112 lines (105 loc) · 2.59 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
import React from 'react';
import { ScrollView, StyleSheet, Text } from 'react-native';
import type { ScenarioDescription } from '@apps/tests/shared/helpers';
import { createScenario } from '@apps/tests/shared/helpers';
import {
TabsContainer,
type TabRouteConfig,
DEFAULT_TAB_ROUTE_OPTIONS,
} from '@apps/shared/gamma/containers/tabs';
const scenarioDescription: ScenarioDescription = {
name: 'Tabs special effect scroll to top',
key: 'test-tabs-special-effects-scroll-to-top',
details:
'Test settings of specialEffect scrollToTop.',
platforms: ['ios', 'android'],
};
interface ScrollScreenProps {
tabName: string;
}
export function ScrollScreen({ tabName }: ScrollScreenProps) {
return (
<ScrollView testID={`${tabName}-scrollview`}>
<Text style={styles.hint}>Scroll Screen — scroll down or re-tap the tab.</Text>
{Array.from({ length: 50 }, (_, i) => (
<Text key={i} testID={`${tabName}-item-${i + 1}`} style={styles.item}>
Item {i + 1}
</Text>
))}
</ScrollView>
);
}
const TAB_CONFIGS: TabRouteConfig[] = [
{
name: 'Tab1',
Component: () => <ScrollScreen tabName="tab1" />,
options: {
...DEFAULT_TAB_ROUTE_OPTIONS,
title: 'Tab1',
tabBarItemTestID: 'tab1-tab-item',
tabBarItemAccessibilityLabel: 'tab1-tab-item-label',
specialEffects: {
repeatedTabSelection: {
scrollToTop: true,
},
},
},
},
{
name: 'Tab2',
Component: () => <ScrollScreen tabName="tab2" />,
options: {
...DEFAULT_TAB_ROUTE_OPTIONS,
title: 'Tab2',
tabBarItemTestID: 'tab2-tab-item',
tabBarItemAccessibilityLabel: 'tab2-tab-item-label',
specialEffects: {
repeatedTabSelection: {
scrollToTop: false
},
},
},
},
{
name: 'Tab3',
Component: () => <ScrollScreen tabName="tab3" />,
options: {
...DEFAULT_TAB_ROUTE_OPTIONS,
title: 'Tab3',
tabBarItemTestID: 'tab3-tab-item',
tabBarItemAccessibilityLabel: 'tab3-tab-item-label',
},
},
];
export function App() {
return <TabsContainer routeConfigs={TAB_CONFIGS} />;
}
export default createScenario(App, scenarioDescription);
const styles = StyleSheet.create({
config: {
padding: 40,
},
centered: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
gap: 16,
},
subtitle: {
textAlign: 'center',
color: '#666',
},
switch: {
marginTop: 20,
marginBottom: 15,
},
hint: {
padding: 16,
color: '#666',
},
item: {
padding: 12,
borderBottomWidth: 1,
borderColor: '#eee',
},
});