@@ -17,98 +17,101 @@ import BadgeItem from '../components/BadgeTabbarItem'
1717import styles from '../styles'
1818
1919function _renderTabbarIcon ( icon ) {
20- return < Image source = { icon } style = { styles . tabBarIcon } />
20+ return < Image source = { icon } style = { styles . tabBarIcon } />
2121}
2222
2323const Stack = createStackNavigator ( )
2424const Tab = createBottomTabNavigator ( )
2525
2626const StackNavigatorOptions = {
27- headerStyle : {
28- backgroundColor : '#fff' ,
29- borderBottomWidth : 0 ,
30- } ,
31- headerTintColor : '#5B99FA' ,
32- headerBackTitle : ' '
27+ headerStyle : {
28+ backgroundColor : '#fff' ,
29+ borderBottomWidth : 0 ,
30+ } ,
31+ headerTintColor : '#5B99FA' ,
32+ headerBackTitle : ' ' ,
3333}
3434
3535
3636const tabarIcons = {
37- Home : {
38- render : focused => {
39- return focused
40- ? _renderTabbarIcon ( require ( '../images/tabbar_home_selected.png' ) )
41- : _renderTabbarIcon ( require ( '../images/tabbar_home.png' ) )
42- }
43- } ,
44- Message : {
45- render : focused => {
46- return focused
47- ? _renderTabbarIcon ( require ( '../images/tabbar_message_selected.png' ) )
48- : _renderTabbarIcon ( require ( '../images/tabbar_message.png' ) )
49- }
50- } ,
51- Profile : {
52- render : focused => {
53- return < BadgeItem focused = { focused } />
54- }
37+ Home : {
38+ render : focused => {
39+ return focused
40+ ? _renderTabbarIcon ( require ( '../images/tabbar_home_selected.png' ) )
41+ : _renderTabbarIcon ( require ( '../images/tabbar_home.png' ) )
5542 }
43+ } ,
44+ Message : {
45+ render : focused => {
46+ return focused
47+ ? _renderTabbarIcon ( require ( '../images/tabbar_message_selected.png' ) )
48+ : _renderTabbarIcon ( require ( '../images/tabbar_message.png' ) )
49+ }
50+ } ,
51+ Profile : {
52+ render : focused => {
53+ return < BadgeItem focused = { focused } />
54+ }
55+ }
5656}
5757
5858HomeStack = ( ) => (
59- < Stack . Navigator
60- screenOptions = { StackNavigatorOptions }
61- >
62- < Stack . Screen name = "Home" component = { HomePage } options = { { title : '首页' } } />
63- < Stack . Screen name = "HomeDetail" component = { HomeDetailPage } options = { { title : '详情' } } />
64- </ Stack . Navigator >
59+ < Stack . Navigator
60+ screenOptions = { StackNavigatorOptions }
61+ >
62+ < Stack . Screen name = "Home" component = { HomePage } options = { { title : '首页' } } />
63+ < Stack . Screen name = "HomeDetail" component = { HomeDetailPage } options = { { title : '详情' } } />
64+ </ Stack . Navigator >
6565)
6666
6767MessageStack = ( ) => (
68- < Stack . Navigator
69- screenOptions = { StackNavigatorOptions }
70- >
71- < Stack . Screen name = "Message" component = { MessagePage } options = { { headerShown : false } } />
72- < Stack . Screen name = "MessageDetail" component = { MessageDetailPage } options = { { headerShown : false } } />
73- </ Stack . Navigator >
68+ < Stack . Navigator
69+ screenOptions = { StackNavigatorOptions }
70+ >
71+ < Stack . Screen name = "Message" component = { MessagePage } options = { { headerShown : false , animationEnabled : false } } />
72+ < Stack . Screen name = "MessageDetail" component = { MessageDetailPage } options = { { headerShown : false , animationEnabled : false } } />
73+ </ Stack . Navigator >
7474)
7575
7676const TabBarStack = ( ) => (
77- < Tab . Navigator
78- tabBarOptions = { {
79- activeTintColor : '#6699ff' ,
80- inactiveTintColor : '#999' ,
81- } }
82- screenOptions = { ( { route } ) => ( {
83- tabBarIcon : ( { focused } ) => tabarIcons [ route . name ] . render ( focused ) ,
84- } ) }
85- >
86- < Tab . Screen name = "Home" component = { HomeStack } options = { ( { route } ) => ( {
87- tabBarLabel : '首页' ,
88- tabBarVisible : route . state && route . state . index === 0
89- } ) } />
90- < Tab . Screen name = "Message" component = { MessageStack } options = { { tabBarLabel : '信息' } } />
91- < Tab . Screen name = "Profile" component = { ProfilePage } options = { { tabBarLabel : '我的' } } />
92- </ Tab . Navigator >
77+ < Tab . Navigator
78+ tabBarOptions = { {
79+ activeTintColor : '#6699ff' ,
80+ inactiveTintColor : '#999' ,
81+ } }
82+ screenOptions = { ( { route } ) => ( {
83+ tabBarIcon : ( { focused } ) => tabarIcons [ route . name ] . render ( focused ) ,
84+ } ) }
85+ >
86+ < Tab . Screen name = "Home" component = { HomeStack } options = { ( { route } ) => ( {
87+ tabBarLabel : '首页' ,
88+ tabBarVisible : route . state && route . state . index === 0
89+ } ) } />
90+ < Tab . Screen name = "Message" component = { MessageStack } options = { { tabBarLabel : '信息' } } />
91+ < Tab . Screen name = "Profile" component = { ProfilePage } options = { { tabBarLabel : '我的' } } />
92+ </ Tab . Navigator >
9393)
9494
9595AppStack = ( { isLaunching } ) => (
96- < Stack . Navigator
97- >
98- {
99- isLaunching ?
100- < Stack . Screen name = "Launch" component = { LaunchPage } options = { { headerShown : false } } />
101- : < Stack . Screen name = "TabBar" component = { TabBarStack } options = { { headerShown : false } } />
102- }
103- </ Stack . Navigator >
96+ < Stack . Navigator
97+ screenOptions = { {
98+ animationEnabled : false
99+ } }
100+ >
101+ {
102+ isLaunching ?
103+ < Stack . Screen name = "Launch" component = { LaunchPage } options = { { headerShown : false , animationEnabled : false } } />
104+ : < Stack . Screen name = "TabBar" component = { TabBarStack } options = { { headerShown : false } } />
105+ }
106+ </ Stack . Navigator >
104107)
105108
106109const SwitchStack = ( { isLaunching } ) => (
107- < NavigationContainer >
108- < AppStack isLaunching = { isLaunching } />
109- </ NavigationContainer >
110+ < NavigationContainer >
111+ < AppStack isLaunching = { isLaunching } />
112+ </ NavigationContainer >
110113)
111114
112115export default connect ( ( state ) => ( {
113- isLaunching : state . Login . isLaunching
116+ isLaunching : state . Login . isLaunching
114117} ) ) ( SwitchStack )
0 commit comments