Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions client/src/navigation/HomeNavigator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';
import PropTypes from 'prop-types';
import { StackNavigator } from 'react-navigation';

import { Root } from '../screens/home';
Expand Down Expand Up @@ -31,12 +29,4 @@ const HomeNavigator = StackNavigator(
},
);

// this wrapper exists soley so we can pass the modalNavigation prop down to our child screens
const HomeNavigatorWrapper = ({ screenProps }) => (
<HomeNavigator screenProps={screenProps} />
);
HomeNavigatorWrapper.propTypes = {
screenProps: PropTypes.shape({}),
};

export default HomeNavigatorWrapper;
export default HomeNavigator;
17 changes: 14 additions & 3 deletions client/src/navigation/MainNavigator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { Component } from 'react';
import { Platform, View } from 'react-native';
import PropTypes from 'prop-types';
import { TabNavigator } from 'react-navigation';
import { TabNavigator, NavigationActions } from 'react-navigation';

import Icon from 'react-native-vector-icons/FontAwesome';
import { graphql, compose } from 'react-apollo';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -43,11 +44,21 @@ const MainTabNavigator = TabNavigator(
{
Home: {
screen: HomeNavigator,
navigationOptions: {
navigationOptions: ({ navigation }) => ({
tabBarLabel: 'Home',
// eslint-disable-next-line react/prop-types
tabBarIcon: ({ tintColor }) => <Icon size={34} name="home" color={tintColor} />,
},
tabBarOnPress() {
const resetAction = NavigationActions.reset({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you not do this only if the tab is already selected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played around with detecting that and its possible.

But found that users would be on another tab and want to go home so press home, and it wouldnt take them home, and that was confusing.

index: 0,
key: 'Home',
actions: [
NavigationActions.navigate({ routeName: 'Root' }),
],
});
navigation.dispatch(resetAction);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try ditching the reset and just using navigation.navigate('Root');?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might help if you explain what you tried before you came to this being the best option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the first thing I tried, and its what 'the internet' documents as the correct way to reset a stack.

There is currently nothing in our code to reset the stack and nothing documented in stacknav that would suggest it should be resetting. When we swap tabs it should just keep the set of tabs in that stack in place.

#448

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you just try nav to root you will end up with a weirdly large stack of screens in your stack i believe as it would just add another home screen to the mix.

},
}),
},
Groups: {
screen: GroupsNavigator,
Expand Down