Получить нижнюю часть панели вкладок Навигационные реквизиты
_getScreenProps = () => {
return (
{
navigation: this.props.navigation,
}
)
}
Визуализация панели вкладок
render() {
return (
<View style={{ flex: 1.0 }}>
<Stack screenProps={this._getScreenProps()} />
</View>
)
}
На экране вкладки используйте навигацию следующим образом
onPress={() => this.props.screenProps.navigation.navigate('screenName')}.
Панель вкладок
const TabView = createBottomTabNavigator({
Home: {
screen: Home,
},
Contacts: {
screen: Contacts,
},
Group: {
screen: Group,
},
Task: {
screen: Task,
},
Event: {
screen: EventView
}
},
{
defaultNavigationOptions: ({ navigation }) => ({
defaultProps: navigation,
tabBarIcon: ({ focused, horizontal, tintColor }) => {
const { routeName } = navigation.state;
let iconName;
let title = ''
if (routeName === 'Home') {
iconName = 'ic_home'
title = "HOME"
} else if (routeName === 'Contacts') {
iconName = 'ic_user_home'
title = "CONTACTS"
} else if (routeName === 'Group') {
iconName = 'ic_group'
title = "PROSPECTS"
} else if (routeName === 'Task') {
iconName = 'ic_document'
title = "TASKS"
} else if (routeName === 'Event') {
iconName = 'ic_calculator'
title = "EVENTS"
}
if (focused) {
return (
<LinearGradient style={{ flex: 1.0, width: '100%' }}
colors={[Constant.COLOR.grediantTop, Constant.COLOR.grediantBottom]}>
<View style={{ flex: 1.0, justifyContent: 'center' }}>
<Image
style={{
height: 25,
width: 25,
tintColor: 'white',
alignSelf: 'center'
}}
tintColor='white'
source={{ uri: iconName }}
resizeMode='contain' />
<SPText
style={{ alignSelf: 'center', marginTop: 2, textAlign: 'center' }}
fontSize={8}
textColor='white'
text={title} />
</View>
</LinearGradient>
)
}
else {
return (
<View style={{ flex: 1.0, justifyContent: 'center' }}>
<Image
style={{
height: 25,
width: 25,
alignSelf: 'center'
}}
source={{ uri: iconName }}
resizeMode='contain' />
<SPText
style={{ alignSelf: 'center', marginTop: 2 }}
fontSize={8}
textColor='gray'
text={title} />
</View>
)
}
},
tabBarOnPress: () => {
const { routeName } = navigation.state;
navigation.navigate(routeName)
},
}),
tabBarOptions: {
showLabel: false,
inactiveTintColor: 'gray',
inactiveBackgroundColor: 'white',
},
})
const RootStack = createStackNavigator(
{
TabView: {
screen: TabView,
},
},
{
mode: 'modal',
headerMode: 'none',
}
);
const Stack = createAppContainer(RootStack);