admin管理员组文章数量:1022712
I have simple createBottomTabNavigator
and one of it's tabs is createStackNavigator
and inside this stack
I have one screen which I want it to over lap the tab bar. I tried use tabBarVisible: false
on this screen but no luck there.
Code:
const BookingsStack = createStackNavigator({
Commutes: {
screen: Commutes,
navigationOptions: {
title: "Commutes",
header: null,
}
},
Tickets: {
screen: Tickets,
navigationOptions: {
title: "Tickets",
header: null,
tabBarVisible: false
}
}
});
export const MainNav = createBottomTabNavigator({
Current: {
screen: Current,
navigationOptions: {
title: "Current",
tabBarIcon: ({ tintColor }) => (
<IconIO name="ios-bus" size={scale(20)} color={tintColor} />
)
}
},
BookingsStack: {
screen: BookingsStack,
navigationOptions: {
title: "Commutes",
tabBarIcon: ({ tintColor }) => (
<IconSL name="layers" size={scale(20)} color={tintColor} />
)
}
}
}
I have simple createBottomTabNavigator
and one of it's tabs is createStackNavigator
and inside this stack
I have one screen which I want it to over lap the tab bar. I tried use tabBarVisible: false
on this screen but no luck there.
Code:
const BookingsStack = createStackNavigator({
Commutes: {
screen: Commutes,
navigationOptions: {
title: "Commutes",
header: null,
}
},
Tickets: {
screen: Tickets,
navigationOptions: {
title: "Tickets",
header: null,
tabBarVisible: false
}
}
});
export const MainNav = createBottomTabNavigator({
Current: {
screen: Current,
navigationOptions: {
title: "Current",
tabBarIcon: ({ tintColor }) => (
<IconIO name="ios-bus" size={scale(20)} color={tintColor} />
)
}
},
BookingsStack: {
screen: BookingsStack,
navigationOptions: {
title: "Commutes",
tabBarIcon: ({ tintColor }) => (
<IconSL name="layers" size={scale(20)} color={tintColor} />
)
}
}
}
Share
Improve this question
asked Nov 21, 2018 at 8:16
obiwankenoobiobiwankenoobi
1,5825 gold badges23 silver badges37 bronze badges
2 Answers
Reset to default 4As given in the navigation document:
If we want to hide the tab bar when we navigate from the feed home to a details screen without shuffling navigators, we cannot set the tabBarVisible: false
configuration in navigationOptions
on DetailsScreen
, because those options will only apply to the FeedStack
. Instead, we can do the following:
const FeedStack = createStackNavigator({ FeedHome: FeedScreen,
Details: DetailsScreen, });
FeedStack.navigationOptions = ({ navigation }) => { let
tabBarVisible = true; if (navigation.state.index > 0) {
tabBarVisible = false; }
return {
tabBarVisible,
}; };
I found a solution in the react-navigation
docs - the implementation look like this:
const ChildMainNav = createBottomTabNavigator({
Current: {
screen: Current,
navigationOptions: {
title: "Current",
tabBarIcon: ({ tintColor }) => (
<IconIO name="ios-bus" size={scale(20)} color={tintColor} />
)
}
},
Commutes: {
screen: Commutes,
navigationOptions: {
title: "Commutes",
tabBarIcon: ({ tintColor }) => (
<IconSL name="layers" size={scale(20)} color={tintColor} />
)
}
}
}
export const MainNav = createStackNavigator({
ChildMainNav: {
screen: ChildMainNav,
navigationOptions: {
header: null
}
},
// overlap screens
Tickets: {
screen: Tickets,
navigationOptions: {
title: "Tickets",
header: null,
tabBarVisible: false
}
}
});
The idea is to add the Tab navigator into Stack navigator and add in this stack any other screens you want to have different navigationOptions
to overlap the ones in your Tab.
Link to docs under:
A tab navigator contains a stack and you want to hide the tab bar on specific screens
I have simple createBottomTabNavigator
and one of it's tabs is createStackNavigator
and inside this stack
I have one screen which I want it to over lap the tab bar. I tried use tabBarVisible: false
on this screen but no luck there.
Code:
const BookingsStack = createStackNavigator({
Commutes: {
screen: Commutes,
navigationOptions: {
title: "Commutes",
header: null,
}
},
Tickets: {
screen: Tickets,
navigationOptions: {
title: "Tickets",
header: null,
tabBarVisible: false
}
}
});
export const MainNav = createBottomTabNavigator({
Current: {
screen: Current,
navigationOptions: {
title: "Current",
tabBarIcon: ({ tintColor }) => (
<IconIO name="ios-bus" size={scale(20)} color={tintColor} />
)
}
},
BookingsStack: {
screen: BookingsStack,
navigationOptions: {
title: "Commutes",
tabBarIcon: ({ tintColor }) => (
<IconSL name="layers" size={scale(20)} color={tintColor} />
)
}
}
}
I have simple createBottomTabNavigator
and one of it's tabs is createStackNavigator
and inside this stack
I have one screen which I want it to over lap the tab bar. I tried use tabBarVisible: false
on this screen but no luck there.
Code:
const BookingsStack = createStackNavigator({
Commutes: {
screen: Commutes,
navigationOptions: {
title: "Commutes",
header: null,
}
},
Tickets: {
screen: Tickets,
navigationOptions: {
title: "Tickets",
header: null,
tabBarVisible: false
}
}
});
export const MainNav = createBottomTabNavigator({
Current: {
screen: Current,
navigationOptions: {
title: "Current",
tabBarIcon: ({ tintColor }) => (
<IconIO name="ios-bus" size={scale(20)} color={tintColor} />
)
}
},
BookingsStack: {
screen: BookingsStack,
navigationOptions: {
title: "Commutes",
tabBarIcon: ({ tintColor }) => (
<IconSL name="layers" size={scale(20)} color={tintColor} />
)
}
}
}
Share
Improve this question
asked Nov 21, 2018 at 8:16
obiwankenoobiobiwankenoobi
1,5825 gold badges23 silver badges37 bronze badges
2 Answers
Reset to default 4As given in the navigation document:
If we want to hide the tab bar when we navigate from the feed home to a details screen without shuffling navigators, we cannot set the tabBarVisible: false
configuration in navigationOptions
on DetailsScreen
, because those options will only apply to the FeedStack
. Instead, we can do the following:
const FeedStack = createStackNavigator({ FeedHome: FeedScreen,
Details: DetailsScreen, });
FeedStack.navigationOptions = ({ navigation }) => { let
tabBarVisible = true; if (navigation.state.index > 0) {
tabBarVisible = false; }
return {
tabBarVisible,
}; };
I found a solution in the react-navigation
docs - the implementation look like this:
const ChildMainNav = createBottomTabNavigator({
Current: {
screen: Current,
navigationOptions: {
title: "Current",
tabBarIcon: ({ tintColor }) => (
<IconIO name="ios-bus" size={scale(20)} color={tintColor} />
)
}
},
Commutes: {
screen: Commutes,
navigationOptions: {
title: "Commutes",
tabBarIcon: ({ tintColor }) => (
<IconSL name="layers" size={scale(20)} color={tintColor} />
)
}
}
}
export const MainNav = createStackNavigator({
ChildMainNav: {
screen: ChildMainNav,
navigationOptions: {
header: null
}
},
// overlap screens
Tickets: {
screen: Tickets,
navigationOptions: {
title: "Tickets",
header: null,
tabBarVisible: false
}
}
});
The idea is to add the Tab navigator into Stack navigator and add in this stack any other screens you want to have different navigationOptions
to overlap the ones in your Tab.
Link to docs under:
A tab navigator contains a stack and you want to hide the tab bar on specific screens
版权声明:本文标题:javascript - how to hide bottom bar from in a screen inside stackNavigator react-navigation - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745545027a2155354.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论