1import { BottomTabNavigationOptions, BottomTabNavigationProp } from '@react-navigation/bottom-tabs';
2import { DrawerNavigationOptions } from '@react-navigation/drawer';
3import { PathConfig } from '@react-navigation/native';
4import { StackNavigationOptions } from '@react-navigation/stack';
5
6import ExpoApisStackNavigator, { Screens as APIScreens } from './ExpoApisStackNavigator';
7import ExpoComponentsStackNavigator, {
8  Screens as ComponentScreens,
9} from './ExpoComponentsStackNavigator';
10
11// @tsapeta: These navigators are being used by `bare-expo` app,
12// so make sure they still work there once you change something here.
13
14type ScreenConfig = {
15  linking: PathConfig<{ ExpoApis?: string; ExpoComponents?: string }>;
16  navigator: ((props: { navigation: BottomTabNavigationProp<any> }) => JSX.Element) & {
17    navigationOptions: StackNavigationOptions &
18      DrawerNavigationOptions &
19      BottomTabNavigationOptions;
20  };
21};
22
23const apis: ScreenConfig = {
24  linking: {
25    path: '/apis',
26    initialRouteName: 'ExpoApis',
27    screens: {
28      ExpoApis: '',
29      ...APIScreens.reduce(
30        (prev, curr) => ({
31          ...prev,
32          [curr.name]: curr.name.toLowerCase(),
33        }),
34        {}
35      ),
36    },
37  },
38  navigator: ExpoApisStackNavigator,
39};
40
41const components = {
42  linking: {
43    path: '/components',
44    initialRouteName: 'ExpoComponents',
45    screens: {
46      ExpoComponents: '',
47      ...ComponentScreens.reduce(
48        (prev, curr) => ({
49          ...prev,
50          [curr.name]: curr.route || curr.name.toLowerCase(),
51        }),
52        {}
53      ),
54    },
55  },
56  navigator: ExpoComponentsStackNavigator,
57};
58
59export default {
60  apis,
61  components,
62};
63