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 DrawerItems from '../views/Drawer/DrawerNavigatorItems';
import SafeAreaView from '../views/SafeAreaView'; import SafeAreaView from '../views/SafeAreaView';
import NavigatorTypes from './NavigatorTypes';
// A stack navigators props are the intersection between // A stack navigators props are the intersection between
// the base navigator props (navgiation, screenProps, etc) // the base navigator props (navgiation, screenProps, etc)
// and the view's props // and the view's props
@ -66,16 +64,12 @@ const DrawerNavigator = (routeConfigs, config = {}) => {
} = mergedConfig; } = mergedConfig;
const contentRouter = TabRouter(routeConfigs, tabsConfig); const contentRouter = TabRouter(routeConfigs, tabsConfig);
const drawerRouter = TabRouter( const drawerRouter = TabRouter(
{ {
[drawerCloseRoute]: { [drawerCloseRoute]: {
screen: createNavigator( screen: createNavigator(contentRouter, routeConfigs, config)(props => (
contentRouter, <DrawerScreen {...props} />
routeConfigs, )),
config,
NavigatorTypes.DRAWER
)(props => <DrawerScreen {...props} />),
}, },
[drawerOpenRoute]: { [drawerOpenRoute]: {
screen: () => null, screen: () => null,
@ -89,12 +83,8 @@ const DrawerNavigator = (routeConfigs, config = {}) => {
} }
); );
const navigator = createNavigator( const navigator = createNavigator(drawerRouter, routeConfigs, config)(
drawerRouter, props => (
routeConfigs,
config,
NavigatorTypes.DRAWER
)(props => (
<DrawerView <DrawerView
{...props} {...props}
drawerBackgroundColor={drawerBackgroundColor} drawerBackgroundColor={drawerBackgroundColor}
@ -108,7 +98,8 @@ const DrawerNavigator = (routeConfigs, config = {}) => {
drawerCloseRoute={drawerCloseRoute} drawerCloseRoute={drawerCloseRoute}
drawerToggleRoute={drawerToggleRoute} drawerToggleRoute={drawerToggleRoute}
/> />
)); )
);
return createNavigationContainer(navigator); 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 createNavigator from './createNavigator';
import CardStackTransitioner from '../views/CardStack/CardStackTransitioner'; import CardStackTransitioner from '../views/CardStack/CardStackTransitioner';
import StackRouter from '../routers/StackRouter'; import StackRouter from '../routers/StackRouter';
import NavigatorTypes from './NavigatorTypes';
import NavigationActions from '../NavigationActions'; import NavigationActions from '../NavigationActions';
// A stack navigators props are the intersection between // A stack navigators props are the intersection between
@ -34,12 +33,8 @@ export default (routeConfigMap, stackConfig = {}) => {
const router = StackRouter(routeConfigMap, stackRouterConfig); const router = StackRouter(routeConfigMap, stackRouterConfig);
// Create a navigator with CardStackTransitioner as the view // Create a navigator with CardStackTransitioner as the view
const navigator = createNavigator( const navigator = createNavigator(router, routeConfigMap, stackConfig)(
router, props => (
routeConfigMap,
stackConfig,
NavigatorTypes.STACK
)(props => (
<CardStackTransitioner <CardStackTransitioner
{...props} {...props}
headerMode={headerMode} headerMode={headerMode}
@ -53,7 +48,8 @@ export default (routeConfigMap, stackConfig = {}) => {
onTransitionEnd && onTransitionEnd(); onTransitionEnd && onTransitionEnd();
}} }}
/> />
)); )
);
return createNavigationContainer(navigator); return createNavigationContainer(navigator);
}; };

View File

@ -8,8 +8,6 @@ import TabView from '../views/TabView/TabView';
import TabBarTop from '../views/TabView/TabBarTop'; import TabBarTop from '../views/TabView/TabBarTop';
import TabBarBottom from '../views/TabView/TabBarBottom'; import TabBarBottom from '../views/TabView/TabBarBottom';
import NavigatorTypes from './NavigatorTypes';
// A tab navigators props are the intersection between // A tab navigators props are the intersection between
// the base navigator props (navgiation, screenProps, etc) // the base navigator props (navgiation, screenProps, etc)
// and the view's props // and the view's props
@ -30,12 +28,7 @@ const TabNavigator = (routeConfigs, config = {}) => {
const router = TabRouter(routeConfigs, tabsConfig); const router = TabRouter(routeConfigs, tabsConfig);
const navigator = createNavigator( const navigator = createNavigator(router, routeConfigs, config)(props => (
router,
routeConfigs,
config,
NavigatorTypes.TABS
)(props => (
<TabView <TabView
{...props} {...props}
tabBarComponent={tabBarComponent} 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. * Creates a navigator based on a router and a view that renders the screens.
*/ */
export default function createNavigator( export default function createNavigator(router, routeConfigs, navigatorConfig) {
router,
routeConfigs,
navigatorConfig,
navigatorType
) {
return NavigationView => { return NavigationView => {
class Navigator extends React.Component { class Navigator extends React.Component {
static router = router; static router = router;
static routeConfigs = routeConfigs;
static navigatorConfig = navigatorConfig;
static navigatorType = navigatorType;
static navigationOptions = null; static navigationOptions = null;
render() { render() {