react-navigation#getActiveChildNavigationOptions JavaScript Examples
The following examples show how to use
react-navigation#getActiveChildNavigationOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainNavigator.js From real-frontend with GNU General Public License v3.0 | 5 votes |
HomeStack = (screenProps) => {
const Stack = createMaterialTopTabNavigator({
CameraStack: createStackNavigator({
Camera: CameraScreen,
}, {
initialRouteName: 'Camera',
headerMode: 'none',
navigationOptions: {
cardStyle: {
backgroundColor: screenProps.theme.colors.backgroundPrimary,
},
},
}),
FeedStack: createStackNavigator({
Feed: FeedScreen,
}, {
navigationOptions: {
cardStyle: {
backgroundColor: screenProps.theme.colors.backgroundPrimary,
},
},
}),
ChatStack: createStackNavigator({
Chat: ChatScreen,
}, {
navigationOptions: {
cardStyle: {
backgroundColor: screenProps.theme.colors.backgroundPrimary,
},
},
}),
}, {
initialRouteName: 'FeedStack',
tabBarComponent: () => null,
navigationOptions: ({ navigation, screenProps }) => ({
...getActiveChildNavigationOptions(navigation, screenProps),
}),
})
Stack.navigationOptions = ({ navigation, screenProps }) => ({
tabBarIcon: ({ focused }) => (
<TabBarItem focused={focused}>
<HomeIcon fill={screenProps.theme.colors.primaryIcon} />
</TabBarItem>
),
tabBarVisible: navigation.state.routes[navigation.state.index].routeName !== 'CameraStack',
tabBarOnPress: ({ navigation, defaultHandler }) => {
const stackIndex = path(['state', 'index'])(navigation)
const stackRoutes = path(['state', 'routes', stackIndex])(navigation)
const currentIndex = path(['index'])(stackRoutes)
const currentKey = path(['key'])(stackRoutes)
const scrollToTop = path(['routes', currentIndex, 'params', 'scrollToTop'])(stackRoutes)
if (navigation.isFocused() && currentIndex !== 0) {
navigation.navigate('Feed')
}
if (navigation.isFocused() && currentKey !== 'FeedStack') {
navigation.navigate('Feed')
}
if (navigation.isFocused() && typeof scrollToTop === 'function') {
scrollToTop()
}
defaultHandler()
},
})
return Stack
}