forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRootNavigator.tsx
46 lines (44 loc) · 1.35 KB
/
RootNavigator.tsx
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
import * as React from 'react';
import { Appbar } from 'react-native-paper';
import { DrawerNavigationProp } from '@react-navigation/drawer';
import { createStackNavigator } from '@react-navigation/stack';
import ExampleList, { examples } from './ExampleList';
const Stack = createStackNavigator();
export default function Root() {
return (
<Stack.Navigator
headerMode="screen"
screenOptions={{
header: ({ navigation, scene, previous }) => (
<Appbar.Header>
{previous ? (
<Appbar.BackAction onPress={() => navigation.goBack()} />
) : (navigation as any).openDrawer ? (
<Appbar.Action
icon="menu"
onPress={() =>
((navigation as any) as DrawerNavigationProp<{}>).openDrawer()
}
/>
) : null}
<Appbar.Content title={scene.descriptor.options.title} />
</Appbar.Header>
),
}}
>
<Stack.Screen
name="Home"
component={ExampleList}
options={{ title: 'Examples' }}
/>
{(Object.keys(examples) as Array<keyof typeof examples>).map(id => (
<Stack.Screen
key={id}
name={id}
component={examples[id]}
options={{ title: examples[id].title }}
/>
))}
</Stack.Navigator>
);
}