I'm very new to React and am trying to set the color for the text and other styles for the inactive tabs on my bottom bar but a few hours on it already and not able to make it work as the text doesn't appear unless it's the selected tab. I'm using createMaterialBottomTab.
This is my entire screen if I can get any help please:
import React from 'react'
import { Platform, Text, View } from 'react-native'
import { createAppContainer } from 'react-navigation'
import { createBottomTabNavigator } from 'react-navigation-tabs'
import { createStackNavigator } from 'react-navigation-stack'
import { createMaterialBottomTabNavigator } from 'react-navigation-material-bottom-tabs'
import HeadlinesScreen from '../screens/HeadlinesScreen'
import IrelandScreen from '../screens/IrelandScreen'
import TechnologyScreen from '../screens/TechnologyScreen'
const defaultStackNavOptions = {
headerStyle: {
backgroundColor: '#4a148c'
},
headerTintColor: 'white',
}
const NewsNavigator = createStackNavigator(
{
Headlines: HeadlinesScreen,
Ireland: IrelandScreen,
Technology: TechnologyScreen
})
const HeadLinesNavigator = createStackNavigator(
{
Headlines: HeadlinesScreen
}, {
defaultNavigationOptions: defaultStackNavOptions,
navigationOptions: {
tabBarColor: 'green'
}
})
const IrelandNavigator = createStackNavigator(
{
Ireland: IrelandScreen
}, {
defaultNavigationOptions: defaultStackNavOptions,
navigationOptions: {
tabBarColor: 'red'
}
})
const TechnologyNavigator = createStackNavigator(
{
Technology: TechnologyScreen
}, {
defaultNavigationOptions: defaultStackNavOptions,
navigationOptions: {
tabBarColor: 'purple'
}
})
const config = {
headerMode: 'none',
initialRouteName: 'Headlines',
shifting: true,
activeColor: 'black',
inactiveColor: 'black',
activeTintColor: 'black',
inactiveTintColor: 'black',
labeled: true,
}
const NewsAllNavigator = createMaterialBottomTabNavigator({
Headlines: HeadLinesNavigator,
Ireland: IrelandNavigator,
Technology: TechnologyNavigator,
}, config)
export default createAppContainer(NewsAllNavigator)
Thank you very much.
UPDATED
I noticed now that I can see items if I add icons to the bottom bar. Still not the labels unless the item is selected. I guess this may be the default behaviour but not sure it can be overwritten?
const HeadLinesNavigator = createStackNavigator(
{
Headlines: HeadlinesScreen
}, {
headerLayoutPreset: 'center',
defaultNavigationOptions: defaultStackNavOptions,
navigationOptions: {
// tabBarIcon: <TabItem label='Headlines' />,
tabBarIcon: ({ tintColor }) => (
<View>
<FontAwesome name='newspaper-o' size={25} color='white' />
</View>
),
tabBarColor: 'green',
}
})