index.tsx
1.7 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
// 路由配置
import React from 'react'
import { createStackNavigator, StackNavigationOptions } from '@react-navigation/stack'
import { headerStyle } from '../config'
import TabRouter from '../tab'
import About from '../../views/about'
import Privacy from '../../views/about/privacy'
import Features from '../../views/about/features'
import FeatureDetail from '../../views/about/feature-detail'
interface Route {
name: string;
options?: StackNavigationOptions;
component: React.FC;
}
const Routes: Route[] = [
{
name: 'Index',
options: { title: '首页' },
component: TabRouter
},
{
name: 'About',
options: { title: '', headerShown: true, headerStyle: { elevation: 0, backgroundColor: '#fff' }},
component: About
},
{
name: 'Privacy',
component: Privacy,
options: { title: '隐私协议', headerShown: true }
},
{
name: 'Features',
component: Features,
options: { headerShown: true, title: '功能介绍' }
},
{
name: 'FeatureDetail',
component: FeatureDetail,
options: { headerShown: true, title: '', headerStyle: { elevation: 0, backgroundColor: '#fff' } }
}
]
export type RouteList = {
Index: undefined;
About: undefined;
Privacy: undefined;
Features: undefined;
FeatureDetail: { content?: string };
}
const Stack = createStackNavigator()
const Route: React.FC = () => {
return (
<Stack.Navigator initialRouteName="Index" screenOptions={{ ...headerStyle as StackNavigationOptions }} mode={'card'} >
{Routes.map(item => <Stack.Screen {...item} key={item.name} />)}
</Stack.Navigator>
)
}
export { Route }