xref: /expo/apps/test-suite/AppNavigator.js (revision bb8f4f99)
1import { createStackNavigator } from '@react-navigation/stack';
2import * as React from 'react';
3import { MaterialCommunityIcons } from '@expo/vector-icons';
4
5import Colors from './constants/Colors';
6import SelectScreen from './screens/SelectScreen';
7import RunTests from './screens/TestScreen';
8
9// @tsapeta: This navigator is also being used by `bare-expo` app,
10// so make sure it still works there once you change something here.
11
12const Stack = createStackNavigator();
13
14const spec = {
15  animation: 'timing',
16  config: {
17    duration: 0,
18  },
19};
20
21const shouldDisableTransition = !!global.DETOX;
22
23// Disable transition animations in E2E tests
24const transitionSpec = shouldDisableTransition ? { open: spec, close: spec } : undefined;
25
26export default function AppNavigator(props) {
27  return (
28    <Stack.Navigator
29      {...props}
30      screenOptions={{
31        title: 'Tests',
32        tabBarLabel: 'Tests',
33        tabBarIcon: ({ focused }) => {
34          const color = focused ? Colors.activeTintColor : Colors.inactiveTintColor;
35          return <MaterialCommunityIcons name="format-list-checks" size={27} color={color} />;
36        },
37        transitionSpec,
38        headerBackTitle: 'Select',
39        headerTitleStyle: {
40          color: 'black',
41        },
42        headerTintColor: Colors.tintColor,
43        headerStyle: {
44          borderBottomWidth: 0.5,
45          borderBottomColor: 'rgba(0,0,0,0.1)',
46          boxShadow: '',
47        },
48      }}>
49      <Stack.Screen name="select" component={SelectScreen} options={{ title: 'Expo Test Suite' }} />
50      <Stack.Screen name="run" component={RunTests} options={{ title: 'Test Runner' }} />
51    </Stack.Navigator>
52  );
53}
54