Remove NavigatorTypes (#3331)

This commit is contained in:
Brent Vatne 2018-01-26 15:54:46 -08:00 committed by GitHub
parent 9e026ec2c8
commit 4ae2a42a4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 77 deletions

View File

@ -9,8 +9,6 @@ import DrawerView from '../views/Drawer/DrawerView';
import DrawerItems from '../views/Drawer/DrawerNavigatorItems';
import SafeAreaView from '../views/SafeAreaView';
import NavigatorTypes from './NavigatorTypes';
// A stack navigators props are the intersection between
// the base navigator props (navgiation, screenProps, etc)
// and the view's props
@ -66,16 +64,12 @@ const DrawerNavigator = (routeConfigs, config = {}) => {
} = mergedConfig;
const contentRouter = TabRouter(routeConfigs, tabsConfig);
const drawerRouter = TabRouter(
{
[drawerCloseRoute]: {
screen: createNavigator(
contentRouter,
routeConfigs,
config,
NavigatorTypes.DRAWER
)(props => <DrawerScreen {...props} />),
screen: createNavigator(contentRouter, routeConfigs, config)(props => (
<DrawerScreen {...props} />
)),
},
[drawerOpenRoute]: {
screen: () => null,
@ -89,12 +83,8 @@ const DrawerNavigator = (routeConfigs, config = {}) => {
}
);
const navigator = createNavigator(
drawerRouter,
routeConfigs,
config,
NavigatorTypes.DRAWER
)(props => (
const navigator = createNavigator(drawerRouter, routeConfigs, config)(
props => (
<DrawerView
{...props}
drawerBackgroundColor={drawerBackgroundColor}
@ -108,7 +98,8 @@ const DrawerNavigator = (routeConfigs, config = {}) => {
drawerCloseRoute={drawerCloseRoute}
drawerToggleRoute={drawerToggleRoute}
/>
));
)
);
return createNavigationContainer(navigator);
};

View File

@ -1,9 +0,0 @@
const STACK = 'react-navigation/STACK';
const TABS = 'react-navigation/TABS';
const DRAWER = 'react-navigation/DRAWER';
export default {
STACK,
TABS,
DRAWER,
};

View File

@ -3,7 +3,6 @@ import createNavigationContainer from '../createNavigationContainer';
import createNavigator from './createNavigator';
import CardStackTransitioner from '../views/CardStack/CardStackTransitioner';
import StackRouter from '../routers/StackRouter';
import NavigatorTypes from './NavigatorTypes';
import NavigationActions from '../NavigationActions';
// A stack navigators props are the intersection between
@ -34,12 +33,8 @@ export default (routeConfigMap, stackConfig = {}) => {
const router = StackRouter(routeConfigMap, stackRouterConfig);
// Create a navigator with CardStackTransitioner as the view
const navigator = createNavigator(
router,
routeConfigMap,
stackConfig,
NavigatorTypes.STACK
)(props => (
const navigator = createNavigator(router, routeConfigMap, stackConfig)(
props => (
<CardStackTransitioner
{...props}
headerMode={headerMode}
@ -53,7 +48,8 @@ export default (routeConfigMap, stackConfig = {}) => {
onTransitionEnd && onTransitionEnd();
}}
/>
));
)
);
return createNavigationContainer(navigator);
};

View File

@ -8,8 +8,6 @@ import TabView from '../views/TabView/TabView';
import TabBarTop from '../views/TabView/TabBarTop';
import TabBarBottom from '../views/TabView/TabBarBottom';
import NavigatorTypes from './NavigatorTypes';
// A tab navigators props are the intersection between
// the base navigator props (navgiation, screenProps, etc)
// and the view's props
@ -30,12 +28,7 @@ const TabNavigator = (routeConfigs, config = {}) => {
const router = TabRouter(routeConfigs, tabsConfig);
const navigator = createNavigator(
router,
routeConfigs,
config,
NavigatorTypes.TABS
)(props => (
const navigator = createNavigator(router, routeConfigs, config)(props => (
<TabView
{...props}
tabBarComponent={tabBarComponent}

View File

@ -3,19 +3,10 @@ import React from 'react';
/**
* Creates a navigator based on a router and a view that renders the screens.
*/
export default function createNavigator(
router,
routeConfigs,
navigatorConfig,
navigatorType
) {
export default function createNavigator(router, routeConfigs, navigatorConfig) {
return NavigationView => {
class Navigator extends React.Component {
static router = router;
static routeConfigs = routeConfigs;
static navigatorConfig = navigatorConfig;
static navigatorType = navigatorType;
static navigationOptions = null;
render() {