|
1 | 1 | import { |
2 | | - TabsContainerWithHostConfigContext, |
3 | | - type TabRouteConfig, |
4 | | - useTabsHostConfig, |
5 | | - DEFAULT_TAB_ROUTE_OPTIONS, |
| 2 | + TabsContainerWithHostConfigContext, |
| 3 | + type TabRouteConfig, |
| 4 | + useTabsHostConfig, |
| 5 | + DEFAULT_TAB_ROUTE_OPTIONS, |
6 | 6 | } from '@apps/shared/gamma/containers/tabs'; |
7 | 7 | import React from 'react'; |
8 | 8 | import { View, Text, ScrollView, StyleSheet } from 'react-native'; |
9 | 9 | import { Scenario } from '@apps/tests/shared/helpers'; |
10 | 10 | import { SettingsPicker } from '@apps/shared'; |
11 | | -import {TabBarControllerMode } from 'react-native-screens'; |
| 11 | +import { TabBarControllerMode } from 'react-native-screens'; |
12 | 12 |
|
13 | 13 | const SCENARIO: Scenario = { |
14 | | - name: 'Tab Bar Controller Mode', |
15 | | - key: 'test-tabs-tab-bar-controller-mode-ios', |
16 | | - details: 'Test different tab bar modes.', |
17 | | - platforms: ['ios'], |
18 | | - AppComponent: App, |
| 14 | + name: 'Tab Bar Controller Mode', |
| 15 | + key: 'test-tabs-tab-bar-controller-mode-ios', |
| 16 | + details: 'Test different tab bar modes.', |
| 17 | + platforms: ['ios'], |
| 18 | + AppComponent: App, |
19 | 19 | }; |
20 | 20 |
|
21 | 21 | export default SCENARIO; |
22 | 22 |
|
23 | 23 | function ConfigScreen() { |
24 | | - const { hostConfig, updateHostConfig } = useTabsHostConfig(); |
25 | | - return ( |
26 | | - <ScrollView style={{ padding: 40 }}> |
27 | | - <View> |
28 | | - <Text style={styles.description}> |
29 | | - Controls whether the tab bar is displayed as a bar or |
30 | | - sidebar.{'\n'}Test tabSidebar on iPad — on iPhone it collapses |
31 | | - back to a tab bar automatically. |
32 | | - </Text> |
33 | | - <SettingsPicker<TabBarControllerMode> |
34 | | - label="tabBarControllerMode" |
35 | | - value={hostConfig.ios?.tabBarControllerMode ?? 'automatic'} |
36 | | - onValueChange={value => |
37 | | - updateHostConfig({ ios: { tabBarControllerMode: value } }) |
38 | | - } |
39 | | - items={['automatic', 'tabBar', 'tabSidebar']} |
40 | | - /> |
41 | | - </View> |
42 | | - </ScrollView > |
43 | | - ); |
| 24 | + const { hostConfig, updateHostConfig } = useTabsHostConfig(); |
| 25 | + return ( |
| 26 | + <ScrollView style={{ padding: 40 }}> |
| 27 | + <View> |
| 28 | + <Text style={styles.description}> |
| 29 | + Controls whether the tab bar is displayed as a bar or |
| 30 | + sidebar.{'\n'}Test tabSidebar on iPad — on iPhone it collapses |
| 31 | + back to a tab bar automatically. |
| 32 | + </Text> |
| 33 | + <SettingsPicker<TabBarControllerMode> |
| 34 | + label="tabBarControllerMode" |
| 35 | + value={hostConfig.ios?.tabBarControllerMode ?? 'automatic'} |
| 36 | + onValueChange={value => |
| 37 | + updateHostConfig({ ios: { tabBarControllerMode: value } }) |
| 38 | + } |
| 39 | + items={['automatic', 'tabBar', 'tabSidebar']} |
| 40 | + /> |
| 41 | + </View> |
| 42 | + </ScrollView > |
| 43 | + ); |
44 | 44 | } |
45 | 45 |
|
46 | 46 | function TestScreen() { |
47 | | - return ( |
48 | | - <ScrollView |
49 | | - style={{ flex: 1 }} |
50 | | - contentInsetAdjustmentBehavior="automatic" |
51 | | - testID="test-screen-scroll"> |
52 | | - {Array.from({ length: 40 }, (_, i) => ( |
53 | | - <View key={i} style={styles.scrollItem}> |
54 | | - <Text>Row {i + 1} — scroll to test tabBarMinimizeBehavior</Text> |
55 | | - </View> |
56 | | - ))} |
57 | | - </ScrollView> |
58 | | - ); |
| 47 | + return ( |
| 48 | + <ScrollView |
| 49 | + style={{ flex: 1 }} |
| 50 | + contentInsetAdjustmentBehavior="automatic" |
| 51 | + testID="test-screen-scroll"> |
| 52 | + {Array.from({ length: 40 }, (_, i) => ( |
| 53 | + <View key={i} style={styles.scrollItem}> |
| 54 | + <Text>Row {i + 1} — scroll to test tabBarMinimizeBehavior</Text> |
| 55 | + </View> |
| 56 | + ))} |
| 57 | + </ScrollView> |
| 58 | + ); |
59 | 59 | }; |
60 | 60 |
|
61 | 61 | const ROUTE_CONFIGS: TabRouteConfig[] = [ |
62 | | - { |
63 | | - name: 'Tab1', |
64 | | - Component: ConfigScreen, |
65 | | - options: { |
66 | | - ...DEFAULT_TAB_ROUTE_OPTIONS, |
67 | | - title: 'Tab1', |
68 | | - }, |
| 62 | + { |
| 63 | + name: 'Tab1', |
| 64 | + Component: ConfigScreen, |
| 65 | + options: { |
| 66 | + ...DEFAULT_TAB_ROUTE_OPTIONS, |
| 67 | + title: 'Tab1', |
69 | 68 | }, |
70 | | - { |
71 | | - name: 'Tab2', |
72 | | - Component: TestScreen, |
73 | | - options: { |
74 | | - ...DEFAULT_TAB_ROUTE_OPTIONS, |
75 | | - title: 'Tab2', |
| 69 | + }, |
| 70 | + { |
| 71 | + name: 'Tab2', |
| 72 | + Component: TestScreen, |
| 73 | + options: { |
| 74 | + ...DEFAULT_TAB_ROUTE_OPTIONS, |
| 75 | + title: 'Tab2', |
76 | 76 |
|
77 | | - }, |
78 | 77 | }, |
| 78 | + }, |
79 | 79 | ]; |
80 | 80 |
|
81 | 81 | export function App() { |
82 | | - return <TabsContainerWithHostConfigContext routeConfigs={ROUTE_CONFIGS} />; |
| 82 | + return <TabsContainerWithHostConfigContext routeConfigs={ROUTE_CONFIGS} />; |
83 | 83 | }; |
84 | 84 |
|
85 | | -const styles = { |
86 | | - sectionHeader: { |
87 | | - fontSize: 13, |
88 | | - fontWeight: '600' as const, |
89 | | - textTransform: 'uppercase' as const, |
90 | | - color: '#888', |
91 | | - letterSpacing: 0.5, |
92 | | - marginTop: 24, |
93 | | - marginBottom: 4, |
94 | | - }, |
95 | | - description: { |
96 | | - fontSize: 13, |
97 | | - color: '#555', |
98 | | - marginBottom: 6, |
99 | | - marginTop: 12, |
100 | | - textAlign: 'center' as const, |
101 | | - }, |
102 | | - scrollItem: { |
103 | | - padding: 16, |
104 | | - borderBottomWidth: StyleSheet.hairlineWidth, |
105 | | - borderBottomColor: '#e0e0e0', |
106 | | - }, |
107 | | - centeredScreen: { |
108 | | - flex: 1, |
109 | | - justifyContent: 'center', |
110 | | - alignItems: 'center', |
111 | | - padding: 24, |
112 | | - gap: 12, |
113 | | - }, |
114 | | - screenLabel: { |
115 | | - fontSize: 17, |
116 | | - fontWeight: '600', |
117 | | - textAlign: 'center', |
118 | | - }, |
119 | | - screenHint: { |
120 | | - fontSize: 14, |
121 | | - color: '#555', |
122 | | - textAlign: 'center', |
123 | | - lineHeight: 20, |
124 | | - }, |
125 | | -} |
| 85 | +const styles = StyleSheet.create({ |
| 86 | + sectionHeader: { |
| 87 | + fontSize: 13, |
| 88 | + fontWeight: '600', |
| 89 | + textTransform: 'uppercase', |
| 90 | + color: '#888', |
| 91 | + letterSpacing: 0.5, |
| 92 | + marginTop: 24, |
| 93 | + marginBottom: 4, |
| 94 | + }, |
| 95 | + description: { |
| 96 | + fontSize: 13, |
| 97 | + color: '#555', |
| 98 | + marginBottom: 6, |
| 99 | + marginTop: 12, |
| 100 | + textAlign: 'center', |
| 101 | + }, |
| 102 | + scrollItem: { |
| 103 | + padding: 16, |
| 104 | + borderBottomWidth: StyleSheet.hairlineWidth, |
| 105 | + borderBottomColor: '#e0e0e0', |
| 106 | + }, |
| 107 | + centeredScreen: { |
| 108 | + flex: 1, |
| 109 | + justifyContent: 'center', |
| 110 | + alignItems: 'center', |
| 111 | + padding: 24, |
| 112 | + gap: 12, |
| 113 | + }, |
| 114 | + screenLabel: { |
| 115 | + fontSize: 17, |
| 116 | + fontWeight: '600', |
| 117 | + textAlign: 'center', |
| 118 | + }, |
| 119 | + screenHint: { |
| 120 | + fontSize: 14, |
| 121 | + color: '#555', |
| 122 | + textAlign: 'center', |
| 123 | + lineHeight: 20, |
| 124 | + }, |
| 125 | +}); |
0 commit comments