-
-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathindex.tsx
More file actions
114 lines (105 loc) · 3.17 KB
/
index.tsx
File metadata and controls
114 lines (105 loc) · 3.17 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
import React from 'react';
import type { ScenarioDescription } from '@apps/tests/shared/helpers';
import { createScenario } from '@apps/tests/shared/helpers';
import { Button, Text, View, type NativeSyntheticEvent } from 'react-native';
import {
TabsContainerWithHostConfigContext,
type TabRouteConfig,
DEFAULT_TAB_ROUTE_OPTIONS,
useTabsNavigationContext,
} from '@apps/shared/gamma/containers/tabs';
import { CenteredLayoutView } from '@apps/shared/CenteredLayoutView';
import { ToastProvider, useToast } from '@apps/shared/';
import { Colors } from '@apps/shared/styling';
import type { MoreTabSelectedEvent } from 'react-native-screens';
const scenarioDescription: ScenarioDescription = {
name: 'More navigation controller',
key: 'test-tabs-more-navigation-controller',
details: 'Test navigation and interactions with "More Navigation Controller"',
platforms: ['ios'],
};
function ContentView() {
const { routeKey } = useTabsNavigationContext();
return (
<CenteredLayoutView>
<Text style={{ fontWeight: 'bold', textAlign: 'center' }}>
{routeKey}
</Text>
<TabsNavigationButtons />
</CenteredLayoutView>
);
}
function TabsNavigationButtons() {
const nav = useTabsNavigationContext();
return (
<View>
<Button title="Select First" onPress={() => nav.selectTab('First')} />
<Button title="Select Second" onPress={() => nav.selectTab('Second')} />
<Button title="Select Third" onPress={() => nav.selectTab('Third')} />
<Button title="Select Fourth" onPress={() => nav.selectTab('Fourth')} />
<Button title="Select Fifth" onPress={() => nav.selectTab('Fifth')} />
<Button title="Select Sixth" onPress={() => nav.selectTab('Sixth')} />
</View>
);
}
const ROUTE_CONFIGS: TabRouteConfig[] = [
{
name: 'First',
Component: ContentView,
options: { ...DEFAULT_TAB_ROUTE_OPTIONS, title: 'First' },
},
{
name: 'Second',
Component: ContentView,
options: { ...DEFAULT_TAB_ROUTE_OPTIONS, title: 'Second' },
},
{
name: 'Third',
Component: ContentView,
options: { ...DEFAULT_TAB_ROUTE_OPTIONS, title: 'Third' },
},
{
name: 'Fourth',
Component: ContentView,
options: { ...DEFAULT_TAB_ROUTE_OPTIONS, title: 'Fourth' },
},
{
name: 'Fifth',
Component: ContentView,
options: { ...DEFAULT_TAB_ROUTE_OPTIONS, title: 'Fifth' },
},
{
name: 'Sixth',
Component: ContentView,
options: { ...DEFAULT_TAB_ROUTE_OPTIONS, title: 'Sixth' },
},
];
export function App() {
return (
<ToastProvider>
<AppContents />
</ToastProvider>
);
}
function AppContents() {
const toast = useToast();
return (
<TabsContainerWithHostConfigContext
routeConfigs={ROUTE_CONFIGS}
ios={{
onMoreTabSelected: (
event: NativeSyntheticEvent<MoreTabSelectedEvent>,
) => {
const message = `onMoreTabSelected: ${JSON.stringify(
event.nativeEvent,
undefined,
2,
)}`;
console.warn(message);
toast.push({ message: 'onMoreTabSelected', backgroundColor: Colors.GreenLight60 });
},
}}
/>
);
}
export default createScenario(App, scenarioDescription);