New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HOW TO: on tab icon press open modal #1576
Comments
@veljkomatic
Once you've done this, my method of showing the view modally on top of the tab views was to put the tabnavigator inside of a stacknavigatior and then just navigate to a new screen inside of the stacknavigator. |
@TomAtterton thanks a lot... so I will organize my router like Thank you |
+1 |
Hi! In an effort to get the hundreds of issues on this repo under control I'm closing issues tagged as questions. Please don't take this personally - it's simply something we need to do to get the issues to a manageable point. If you still have a question I encourage you to re-read the docs, ask on StackOverflow, or ask on the #react-navigation Reactiflux channel. Thank you! |
Solution doesn't work with v2 |
In v2, import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Provider } from 'react-redux';
import { YellowBox } from 'react-native';
import { createBottomTabNavigator, createStackNavigator } from 'react-navigation';
import { BottomTabBar } from 'react-navigation-tabs';
import store from './src/store';
import ExploreScreen from './screens/Explore';
import CameraScreen from './screens/Camera';
const BottomTabBarWithModal = (props) => {
const jumpTo = (index) => {
const { navigation: { navigate }, jumpTo } = props;
if (index === 'camera') {
navigate('Camera');
} else {
jumpTo(index);
}
}
return (
<BottomTabBar {...props} jumpTo={jumpTo} />
)
}
const rootConfig = {
mode: 'modal',
headerMode: 'none',
};
const tabConfig = {
tabBarComponent: BottomTabBarWithModal,
}
const RootScreen = createBottomTabNavigator({
explore: ExploreScreen,
camera: CameraScreen,
}, tabConfig);
const Root = createStackNavigator({
Root: RootScreen,
Camera: CameraScreen,
}, rootConfig);
class App extends Component {
componentDidMount() {
YellowBox.ignoreWarnings(['Warning: isMounted(...) is deprecated', 'Module RCTImageLoader']);
}
render() {
return (
<Provider store={store}>
<Root />
</Provider>
);
}
}
BottomTabBarWithModal.propTypes = {
jumpTo: PropTypes.func.isRequired,
navigation: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired,
}
export default App; |
I have come up with a simpler solution by using tabBarOnPress instead of changing the tabBarComponent. This works with v2 and the newest "react-navigation-tabs" version "0.3.0", because tabBarOnPress overrides the default jumpTo behaviour.
|
Hi, everyone. I'm trying to accomplish the exact same thing, but I'm encountering an issue. First of all, @sean-macfarlane 's solution doesn't do the trick since what I want is to prevent the tab to appear as selected (and what he does is... the tab is selected, only it also shows a modal). Previous solution by @itsmeek appears to be what I want (also mentioned here. And I got it to work with a custom tab bar item, just like here here. But if i try to do it with the
|
@ferostar - create a new issue with full example please! |
I have 5 tab icons, but how can I make one of them to just open modal, not to navigate just open modal...For example you are on home screen and home icon is selected and you have another tab icon for example notify and when you click that tab icon I want just to open modal, I dont want to navigate on Notify screen I want to stay on home screen. How can I do that ?
Thanks
The text was updated successfully, but these errors were encountered: