Reputation: 1560
I am using tab navigation for uploading images like below
const Photos = TabNavigator({
CAMERA: {
screen: TakeCamera,
navigationOptions: {
tabBarIcon: ({focused}) => (
<View style={{flexDirection: 'row'}}>
<Text style={{textAlign: 'center', color: focused? '#C7A985' : '#020202'}}>CAMERA</Text>
<Icon name="chevron-down" size={15} color= {focused? '#C7A985' : '#ffffff'}/>
</View>
)
},
},
ALBUMS: {
screen: Albums,
navigationOptions: {
tabBarIcon: ({focused}) => (
<View style={{flexDirection: 'row'}}>
<Text style={{textAlign: 'center', color: focused? '#C7A985' : '#020202'}}>ALBUMS</Text>
<Icon name="chevron-down" size={15} color= {focused? '#C7A985' : '#ffffff'}/>
</View>
)
},
},
{
tabBarOptions: {
upperCaseLabel: false,
showIcon: true,
showLabel: false,
style: {
backgroundColor: '#F7F1ED',
borderTopWidth: 1
}
},
//initialRouteName: 'Feed',
tabBarComponent: TabBarBottom,
tabBarPosition: 'bottom',
animationEnabled: false,
swipeEnabled: false,
});
export default class UploadPost extends Component {
static navigationOptions = ({ navigation }) => ({
header: null,
tabBarVisible: false
});
render() {
return (
<View style={{flex: 1}}>
<StatusBar hidden={true}/>
<Photos screenProps={{navigation: this.props.navigation}}/>
</View>
);
}
}
Here <Statusbar hidden={true}>
hides the status bar in "CAMERA", "ALBUMS" screens as expected. But it also hides the status bar in other screens.
My question is, How to hide status bar only on CAMERA, ALBUMS screens?
Upvotes: 4
Views: 1154
Reputation: 22189
You can use the Screen Tracking Middleware as mentioned in the docs to get the active routeName
of the currentScreen
function getActiveRouteName(navigationState) {
if (!navigationState) {
return null;
}
const route = navigationState.routes[navigationState.index];
// dive into nested navigators
if (route.routes) {
return getActiveRouteName(route);
}
return route.routeName;
}
If the routeName
matches your desired screens in which you don't want to show StatusBar , then set it to true
else false
Upvotes: 1