@@ -15,6 +15,8 @@ import LaunchPage from '../pages/Launch'
1515import BadgeItem from '../components/BadgeTabbarItem'
1616
1717import styles from '../styles'
18+ import { store } from '../../App'
19+ import { changeStack } from '../store/actions/login'
1820
1921function _renderTabbarIcon ( icon ) {
2022 return < Image source = { icon } style = { styles . tabBarIcon } />
@@ -82,12 +84,29 @@ const TabBarStack = () => (
8284 tabBarIcon : ( { focused } ) => tabarIcons [ route . name ] . render ( focused ) ,
8385 } ) }
8486 >
85- < Tab . Screen name = "Home" component = { HomeStack } options = { ( { route } ) => ( {
86- tabBarLabel : '首页' ,
87- tabBarVisible : route . state && route . state . index === 0
88- } ) } />
89- < Tab . Screen name = "Message" component = { MessageStack } options = { { tabBarLabel : '信息' } } />
90- < Tab . Screen name = "Profile" component = { ProfilePage } options = { { tabBarLabel : '我的' } } />
87+ < Tab . Screen name = "Home"
88+ component = { HomeStack }
89+ options = { ( { route } ) => ( {
90+ tabBarLabel : '首页' ,
91+ tabBarVisible : route . state && route . state . index === 0
92+ } ) }
93+ />
94+ < Tab . Screen
95+ name = "Message"
96+ component = { MessageStack }
97+ options = { { tabBarLabel : '信息' } }
98+ />
99+ < Tab . Screen
100+ name = "Profile"
101+ component = { ProfilePage }
102+ options = { { tabBarLabel : '我的' } }
103+ listeners = { {
104+ tabPress : e => {
105+ store . dispatch ( changeStack ( ) )
106+ e . preventDefault ( )
107+ }
108+ } }
109+ />
91110 </ Tab . Navigator >
92111)
93112
@@ -105,10 +124,10 @@ const AppStack = ({ isLaunching }) => (
105124 </ Stack . Navigator >
106125)
107126
108- const SwitchStack = ( { isLaunching } ) => {
127+ const SwitchStack = ( { isLaunching, switchStack } ) => {
109128 return (
110129 < NavigationContainer >
111- < AppStack isLaunching = { isLaunching } />
130+ < AppStack isLaunching = { isLaunching } switchStack = { switchStack } />
112131 </ NavigationContainer >
113132 )
114133}
0 commit comments