-
-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathindex.tsx
More file actions
142 lines (133 loc) · 3.58 KB
/
index.tsx
File metadata and controls
142 lines (133 loc) · 3.58 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
import React from 'react';
import { ScrollView, Text, View, StyleSheet } from 'react-native';
import {
NavigationContainer,
NavigationIndependentTree,
} from '@react-navigation/native';
import { TabsContainer } from '@apps/shared/gamma/containers/tabs';
import type { ScenarioDescription } from '@apps/tests/shared/helpers';
import { createScenario } from '@apps/tests/shared/helpers';
const scenarioDescription: ScenarioDescription = {
name: 'Override ScrollView Content Inset',
key: 'test-tabs-override-scroll-view-content-inset-ios',
details:
'Tests overrideScrollViewContentInsetAdjustmentBehavior with different static values per tab. ' +
'False: content scrolls behind bars. True/Default: content is inset from bars.',
platforms: ['ios'],
};
const ITEM_COUNT = 30;
export function ScrollContent({
label,
testID,
}: {
label: string;
testID: string;
}) {
return (
<ScrollView style={styles.scrollView} testID={testID}>
<View style={styles.header}>
<Text style={styles.headerText}>
overrideScrollViewContentInsetAdjustmentBehavior: {label}
</Text>
</View>
{Array.from({ length: ITEM_COUNT }, (_, i) => (
<View key={i} style={styles.item}>
<Text style={styles.itemText}>Item {i + 1}</Text>
</View>
))}
</ScrollView>
);
}
export function FalseTab() {
return (
<ScrollContent
label="false"
testID="override-inset-false-scrollview"
/>
);
}
export function TrueTab() {
return (
<ScrollContent
label="true"
testID="override-inset-true-scrollview"
/>
);
}
function DefaultTab() {
return (
<ScrollContent
label="(not set, defaults to true)"
testID="override-inset-default-scrollview"
/>
);
}
export export function App() {
return (
<NavigationIndependentTree>
<NavigationContainer>
<TabsContainer
routeConfigs={[
{
name: 'False',
Component: FalseTab,
options: {
title: 'False',
tabBarItemAccessibilityLabel: 'override-inset-tab-false',
ios: {
overrideScrollViewContentInsetAdjustmentBehavior: false,
icon: { type: 'sfSymbol', name: 'xmark.circle' },
},
},
},
{
name: 'True',
Component: TrueTab,
options: {
title: 'True',
tabBarItemTestID: 'override-inset-tab-true',
ios: {
overrideScrollViewContentInsetAdjustmentBehavior: true,
icon: { type: 'sfSymbol', name: 'checkmark.circle' },
},
},
},
{
name: 'Default',
Component: DefaultTab,
options: {
title: 'Default',
tabBarItemTestID: 'override-inset-tab-default',
ios: { icon: { type: 'sfSymbol', name: 'circle.dashed' } },
},
},
]}
/>
</NavigationContainer>
</NavigationIndependentTree>
);
}
const styles = StyleSheet.create({
scrollView: {
flex: 1,
},
header: {
padding: 16,
backgroundColor: '#f0f0f0',
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: '#ccc',
},
headerText: {
fontSize: 14,
fontWeight: '600',
},
item: {
padding: 16,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: '#e0e0e0',
},
itemText: {
fontSize: 16,
},
});
export default createScenario(App, scenarioDescription);