splash screen removed from stack after initial display (#117)
This commit is contained in:
parent
6abf511ef4
commit
3d3f1e0ff0
2 changed files with 19 additions and 10 deletions
|
@ -79,8 +79,8 @@ const walletStack = StackNavigator({
|
||||||
});
|
});
|
||||||
|
|
||||||
const drawer = DrawerNavigator({
|
const drawer = DrawerNavigator({
|
||||||
Discover: { screen: discoverStack },
|
DiscoverStack: { screen: discoverStack },
|
||||||
Wallet: { screen: walletStack },
|
WalletStack: { screen: walletStack },
|
||||||
Settings: { screen: SettingsPage, navigationOptions: { drawerLockMode: 'locked-closed' } },
|
Settings: { screen: SettingsPage, navigationOptions: { drawerLockMode: 'locked-closed' } },
|
||||||
About: { screen: AboutPage, navigationOptions: { drawerLockMode: 'locked-closed' } }
|
About: { screen: AboutPage, navigationOptions: { drawerLockMode: 'locked-closed' } }
|
||||||
}, {
|
}, {
|
||||||
|
@ -110,16 +110,17 @@ class AppWithNavigationState extends React.Component {
|
||||||
BackHandler.addEventListener('hardwareBackPress', function() {
|
BackHandler.addEventListener('hardwareBackPress', function() {
|
||||||
const { dispatch, navigation, nav } = this.props;
|
const { dispatch, navigation, nav } = this.props;
|
||||||
// There should be a better way to check this
|
// There should be a better way to check this
|
||||||
if (nav.routes.length > 1) {
|
if (nav.routes.length > 0) {
|
||||||
const subRoutes = nav.routes[1].routes[0].routes;
|
const subRoutes = nav.routes[0].routes[0].routes;
|
||||||
const lastRoute = subRoutes[subRoutes.length - 1];
|
const lastRoute = subRoutes[subRoutes.length - 1];
|
||||||
if (['About', 'Settings'].indexOf(lastRoute.key) > -1) {
|
if (nav.routes[0].routes[0].index > 0 &&
|
||||||
dispatch({ type: 'Navigation/BACK' });
|
['About', 'Settings'].indexOf(lastRoute.key) > -1) {
|
||||||
|
dispatch(NavigationActions.back());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (nav.routes[1].routeName === 'Main') {
|
if (nav.routes[0].routeName === 'Main') {
|
||||||
if (nav.routes[1].routes[0].routes[0].index > 0) {
|
if (nav.routes[0].routes[0].routes[0].index > 0) {
|
||||||
dispatch({ type: 'Navigation/BACK' });
|
dispatch(NavigationActions.back());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Lbry } from 'lbry-redux';
|
import { Lbry } from 'lbry-redux';
|
||||||
import { View, Text, NativeModules } from 'react-native';
|
import { View, Text, NativeModules } from 'react-native';
|
||||||
|
import { NavigationActions } from 'react-navigation';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import splashStyle from '../../styles/splash';
|
import splashStyle from '../../styles/splash';
|
||||||
|
|
||||||
|
@ -42,7 +43,14 @@ class SplashScreen extends React.PureComponent {
|
||||||
// Leave the splash screen
|
// Leave the splash screen
|
||||||
const { balanceSubscribe, navigation } = this.props;
|
const { balanceSubscribe, navigation } = this.props;
|
||||||
balanceSubscribe();
|
balanceSubscribe();
|
||||||
navigation.navigate('Main');
|
|
||||||
|
const resetAction = NavigationActions.reset({
|
||||||
|
index: 0,
|
||||||
|
actions: [
|
||||||
|
NavigationActions.navigate({ routeName: 'Main'})
|
||||||
|
]
|
||||||
|
});
|
||||||
|
navigation.dispatch(resetAction);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue