Add react-navigation to dependencies

parent 090e884a
......@@ -13,10 +13,10 @@ import reducers from './reducers';
import i18n from './utils/i18n';
import sagas from './sagas';
import ReduxNavigator from './ui/components/navigator/ReduxNavigator';
import * as sessionActions from './actions/session';
import * as deepLinkingActions from './actions/deepLinking';
import { register } from './actions/pushNotifications';
import NavigationService from './navigation';
const sagaMiddleware = createSagaMiddleware();
const store = createStore(reducers, applyMiddleware(sagaMiddleware));
......@@ -77,7 +77,11 @@ class Main extends Component {
return (
<I18nextProvider i18n={i18n}>
<Provider store={store}>
<ReduxNavigator />
<NavigationService.AppNavigator
ref={(navigatorRef) => {
NavigationService.setTopLevelNavigator(navigatorRef);
}}
/>
</Provider>
</I18nextProvider>
);
......
import { createStackNavigator, createSwitchNavigator, NavigationActions, } from 'react-navigation';
import Login from './ui/screens/user/Login';
import Welcome from './ui/screens/welcome/Welcome';
import Event from './ui/screens/events/Event';
import Profile from './ui/screens/user/Profile';
import Pizza from './ui/screens/pizza/Pizza';
import Registration from './ui/screens/events/Registration';
import SplashScreen from './ui/screens/splash/SplashScreen';
const SignedInNavigator = createStackNavigator({
Welcome,
Event,
Profile,
Pizza,
Registration,
}, {
initialRouteName: 'MainNavigator',
headerMode: 'none',
});
const AppNavigator = createSwitchNavigator({
Splash: SplashScreen,
Auth: Login,
SignedIn: SignedInNavigator,
});
let navigator;
function setTopLevelNavigator(navigatorRef) {
navigator = navigatorRef;
}
function navigate(routeName, params) {
navigator.dispatch(
NavigationActions.navigate({
routeName,
params,
}),
);
}
export default {
AppNavigator,
navigate,
setTopLevelNavigator,
};
......@@ -8,8 +8,7 @@ import { Sentry } from 'react-native-sentry';
import { apiRequest, tokenSelector } from '../utils/url';
import * as sessionActions from '../actions/session';
import * as pushNotificationsActions from '../actions/pushNotifications';
import { navigate } from '../actions/navigation';
import { LOGIN_SCENE, WELCOME_SCENE } from '../ui/components/navigator/scenes';
import NavigationService from '../navigation';
export const USERNAMEKEY = '@MyStore:username';
export const TOKENKEY = '@MyStore:token';
......@@ -44,7 +43,7 @@ function* init() {
yield put(sessionActions.fetchUserInfo());
yield put(pushNotificationsActions.register(pushCategories));
} else {
yield put(navigate(LOGIN_SCENE, true));
yield call(NavigationService.navigate, 'Auth');
}
} catch (e) {
Sentry.captureException(e);
......@@ -95,7 +94,7 @@ function* signOut() {
function* signedIn({ payload }) {
const { username } = payload;
yield put(navigate(WELCOME_SCENE, true));
yield call(NavigationService.navigate, 'SignedIn');
yield call(Sentry.setUserContext, { username });
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment