-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.js
130 lines (123 loc) · 4.85 KB
/
App.js
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React from 'react';
import {
Image, View,
StyleSheet,
Text,
TouchableOpacity,
} from 'react-native';
import {TabNavigator, StackNavigator} from 'react-navigation';
import More from './app/more/More';
import MePage from './app/mepage/Me';
import Home2 from './app/home/Home2';
import Home from './app/home/Home';
import Drawer from './app/home/Home';
import * as ScreenUtil from './app/utils/ScreenUtil';
const styles = StyleSheet.create({
rightView: {
marginHorizontal: 20
},
headerView: {
backgroundColor: 'yellow',
},
headerTitleStyle: {
color: 'blue',
fontSize: 20,
alignSelf: 'center'
},
leftText: {
color: 'green'
}
});
const Tab = TabNavigator({
HomePage: {
screen: Drawer,
navigationOptions: {
tabBarLabel: '首页', //若不设置,则以key为标题
tabBarVisible: true, //是否隐藏标签栏。默认不隐藏(true),该选项卡激活时生效
tabBarIcon: ({tintColor}) => (<Image style={{height: 30, resizeMode: 'contain', tintColor: tintColor}}
source={require('./img/ic_launcher.png')}/>)
},
},
More: {
screen: More,
navigationOptions: {
// tabBarLabel: '首页',
tabBarVisible: true, //是否隐藏标签栏。默认不隐藏(true),该选项卡激活时生效
tabBarIcon: ({tintColor}) => (<Image style={{height: 30, resizeMode: 'contain', tintColor: tintColor}}
source={require('./img/ic_launcher.png')}/>)
},
},
MePage: {
screen: MePage,
navigationOptions: {
// tabBarLabel: '首页',
tabBarVisible: true, //是否隐藏标签栏。默认不隐藏(true),该选项卡激活时生效
tabBarIcon: ({tintColor}) => (<Image style={{height: 30, resizeMode: 'contain', tintColor: tintColor}}
source={require('./img/ic_launcher.png')}/>)
},
},
}, {
tabBarPosition: 'bottom', //设置tabbar的位置,iOS默认在底部,安卓默认在顶部。(属性值:'top','bottom')
swipeEnabled: true, //是否允许在标签之间滑动
animationEnabled: false, //是否在更改标签时显示动画。
lazy: true, //是否根据需要懒惰呈现标签,而不是提前制作,意思是在app打开的时候将底部标签栏全部加载,默认false,推荐改成true哦
initialRouteName: 'HomePage', //设置默认的页面组件
backBehavior: 'none', //按 back 键是否跳转到第一个Tab(首页), none 为不跳转
tabBarOptions: {
activeTintColor: 'green',//label和icon的前景色 活跃状态下(选中)。
activeBackgroundColor: 'red', //label和icon的背景色 活跃状态下(选中) 。
showLabel: true, //是否显示label,默认开启
labelStyle: {fontSize: 12}, //label的样式
style: [{height: 50}, ScreenUtil.ifIphoneX({bottom: 34})], //tabbar的样式
iconStyle: {height: 30} //安卓,
}
});
const AppRoute = StackNavigator({
Home: {
screen: Tab,
navigationOptions: {
header: null
}
},
Home2: {
screen: Home2,
navigationOptions: ({navigation}) => ({
headerTitle: `${navigation.state.params.name} `,
headerStyle: styles.headerView,
headerTitleStyle: styles.headerTitleStyle,
headerTintColor: 'blue',
headerBackTitleStyle: styles.leftText,
headerBackTitle: 'headerBackTitle: null,',
headerLeft: <TouchableOpacity onPress={() => {
navigation.goBack()
}}>
<View>
<Text>2⬅️</Text>
</View>
</TouchableOpacity>
}),
/*navigationOptions: {
// header: null //可以设置一些导航的属性,当然如果想隐藏顶部导航条只要将这个属性设置为null就可以了
// headerTitle: '首页2呀', //设置导航栏标题,推荐用这个方法。
// headerRight: <View style={styles.rightView}><Text>右侧</Text></View>,
//headerStyle: styles.headerView,
// headerTitleStyle: styles.headerTitleStyle,
// headerBackTitle: null,
// headerBackTitleStyle: styles.leftText,
// headerLeft: <View style={styles.rightView}><Text>返回</Text></View>,
headerTintColor : 'red', //返回按钮的颜色
}*/
}
}, {
mode: 'card',
headerMode: 'screen',
navigationOptions: {
gesturesEnabled: false,
},
});
export default AppRoute;