-
-
Notifications
You must be signed in to change notification settings - Fork 643
Expand file tree
/
Copy pathindex.tsx
More file actions
70 lines (64 loc) · 2.03 KB
/
index.tsx
File metadata and controls
70 lines (64 loc) · 2.03 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
import React from 'react';
import { ScrollView } from 'react-native';
import {
NavigationContainer,
NavigationIndependentTree,
} from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { ScenarioButton } from '@apps/tests/shared/ScenarioButton';
import OrientationScenarioGroup from './orientation';
import ScrollViewScenarioGroup from './scroll-view';
import FormSheetScenarioGroup from './form-sheet';
import ScenarioSelectionScreen from '@apps/tests/shared/ScenarioScreen';
export const COMPONENT_SCENARIOS = {
Orientation: OrientationScenarioGroup,
ScrollView: ScrollViewScenarioGroup,
FormSheet: FormSheetScenarioGroup,
} as const;
type ParamsList = { [k: keyof typeof COMPONENT_SCENARIOS]: undefined } & {
Home: undefined;
};
function HomeScreen() {
return (
<ScrollView contentInsetAdjustmentBehavior="automatic">
{Object.entries(COMPONENT_SCENARIOS).map(([key, scenarioGroup]) => (
<ScenarioButton
key={key}
title={scenarioGroup.name}
route={key}
details={scenarioGroup.details}
/>
))}
</ScrollView>
);
}
const Stack = createNativeStackNavigator<ParamsList>();
export default function App() {
return (
<NavigationIndependentTree>
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{
headerShown: true,
headerLargeTitleEnabled: true,
headerTitle: 'Scenarios',
}}
/>
{Object.entries(COMPONENT_SCENARIOS).map(([key, scenarioGroup]) => (
<Stack.Screen name={key}>
{() => (
<ScenarioSelectionScreen
key={key}
scenarioGroup={scenarioGroup}
/>
)}
</Stack.Screen>
))}
</Stack.Navigator>
</NavigationContainer>
</NavigationIndependentTree>
);
}