Skip to content

Commit

Permalink
remove overlay navigator
Browse files Browse the repository at this point in the history
  • Loading branch information
aksonov committed Aug 14, 2017
1 parent 25fc6c3 commit 8ddf62e
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 107 deletions.
171 changes: 84 additions & 87 deletions Example/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,103 +52,100 @@ const getSceneStyle = () => ({
shadowRadius: 3,
});

const Example = () => {
return (
const Example = () => (
<View style={{ flex: 1 }}>
<Router createReducer={reducerCreate} tintColor='red' getSceneStyle={getSceneStyle}>
<Scene overlay>
<Scene key="messageBar" component={MessageBar} />
<Scene key="modal" modal hideNavBar initial>
<Scene key="lightbox" lightbox leftButtonTextStyle={{color: 'green'}} backButtonTextStyle={{color: 'red'}} initial>
<Scene key="root" hideNavBar hideTabBar titleStyle={{alignSelf: 'center'}}>
<Scene key="echo" back clone component={EchoView} getTitle={({navigation}) => navigation.state.key}/>
<Scene key="register" back>
<Scene key="_register" component={Register} title="Register"/>
<Scene key="register2" component={Register} title="Register2"/>
<Scene key="home" component={Home} title="Replace" type={ActionConst.REPLACE}/>
</Scene>
<Scene key="launch" component={Launch} title="Launch" initial/>
<Scene key="drawer" drawer contentComponent={TabView}>
<Scene key="modal" modal hideNavBar initial>
<Scene key="lightbox" lightbox leftButtonTextStyle={{color: 'green'}} backButtonTextStyle={{color: 'red'}} initial>
<Scene key="root" hideNavBar hideTabBar titleStyle={{alignSelf: 'center'}}>
<Scene key="echo" back clone component={EchoView} getTitle={({navigation}) => navigation.state.key}/>
<Scene key="register" back>
<Scene key="_register" component={Register} title="Register"/>
<Scene key="register2" component={Register} title="Register2"/>
<Scene key="home" component={Home} title="Replace" type={ActionConst.REPLACE}/>
</Scene>
<Scene key="launch" component={Launch} title="Launch" initial/>
<Scene key="drawer" drawer contentComponent={TabView}>
<Scene
key="tabbar"
gestureEnabled={false}
showLabel={false}
tabs
tabBarStyle={styles.tabBarStyle}
activeBackgroundColor='#ddd'
>
<Scene
key="tabbar"
gestureEnabled={false}
showLabel={false}
tabs
tabBarStyle={styles.tabBarStyle}
activeBackgroundColor='#ddd'
key="tab1"
title="Tab #1"
tabBarLabel="TAB #1"
icon={TabIcon}
navigationBarStyle={{backgroundColor: 'green'}}
titleStyle={{color: 'white', alignSelf: 'center'}}
>
<Scene
key="tab1"
title="Tab #1"
tabBarLabel="TAB #1"
icon={TabIcon}
navigationBarStyle={{backgroundColor: 'green'}}
titleStyle={{color: 'white', alignSelf: 'center'}}
>
<Scene
key="tab1_1"
component={TabView}
title="Tab #1_1"
onRight={() => alert('Right button')}
rightTitle="Right"
/>
<Scene
key="tab1_2"
component={TabView}
title="Tab #1_2"
back
titleStyle={{color: 'black', alignSelf: 'center'}}
/>
</Scene>
<Scene key="tab2" initial title="Tab #2" icon={TabIcon}>
<Scene
key="tab2_1"
component={TabView}
title="Tab #2_1"
renderRightButton={() => <Text>Right</Text>}
/>
<Scene
key="tab2_2"
component={TabView}
title="Tab #2_2"
onBack={() => alert('onBack button!')}
backTitle="Back!"
panHandlers={null}
/>
</Scene>
<Scene key="tab3" component={TabView} title="Tab #3" icon={TabIcon} rightTitle="Right3" onRight={()=>{}}/>
<Scene key="tab4" component={TabView} title="Tab #4" hideNavBar icon={TabIcon}/>
<Scene key="tab5" component={TabView} title="Tab #5" icon={TabIcon}/>
key="tab1_1"
component={TabView}
title="Tab #1_1"
onRight={() => alert('Right button')}
rightTitle="Right"
/>
<Scene
key="tab1_2"
component={TabView}
title="Tab #1_2"
back
titleStyle={{color: 'black', alignSelf: 'center'}}
/>
</Scene>
<Scene key="tab2" initial title="Tab #2" icon={TabIcon}>
<Scene
key="tab2_1"
component={TabView}
title="Tab #2_1"
renderRightButton={() => <Text>Right</Text>}
/>
<Scene
key="tab2_2"
component={TabView}
title="Tab #2_2"
onBack={() => alert('onBack button!')}
backTitle="Back!"
panHandlers={null}
/>
</Scene>
<Scene key="tab3" component={TabView} title="Tab #3" icon={TabIcon} rightTitle="Right3" onRight={()=>{}}/>
<Scene key="tab4" component={TabView} title="Tab #4" hideNavBar icon={TabIcon}/>
<Scene key="tab5" component={TabView} title="Tab #5" icon={TabIcon}/>
</Scene>
</Scene>
<Scene key="error" component={Error}/>
</Scene>
<Scene key="login" titleStyle={{alignSelf: 'center'}}>
<Scene key="loginModal" component={Login} title="Login"
onEnter={()=>console.log('onEnter')}
onExit={()=>console.log('onExit')}
leftTitle="Cancel" onLeft={Actions.pop}/>
<Scene
key="loginModal2"
component={Login2}
title="Login2"
backTitle="Back"
panHandlers={null}
duration={1}
/>
<Scene
key="loginModal3"
hideNavBar
component={Login3}
title="Login3"
panHandlers={null}
duration={1}
/>
</Scene>
<Scene key="error" component={Error}/>
</Scene>
<Scene key="login" titleStyle={{alignSelf: 'center'}}>
<Scene key="loginModal" component={Login} title="Login"
onEnter={()=>console.log('onEnter')}
onExit={()=>console.log('onExit')}
leftTitle="Cancel" onLeft={Actions.pop}/>
<Scene
key="loginModal2"
component={Login2}
title="Login2"
backTitle="Back"
panHandlers={null}
duration={1}
/>
<Scene
key="loginModal3"
hideNavBar
component={Login3}
title="Login3"
panHandlers={null}
duration={1}
/>
</Scene>
</Scene>
</Router>
);
}
<MessageBar />
</View>);

export default Example;
23 changes: 9 additions & 14 deletions dist/navigationStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var _reactNative=require('react-native');
var _reactNavigation=require('react-navigation');
var _NavBar=require('./NavBar');
var _LightboxNavigator=require('./LightboxNavigator');var _LightboxNavigator2=_interopRequireDefault(_LightboxNavigator);
var _OverlayNavigator=require('./OverlayNavigator');var _OverlayNavigator2=_interopRequireDefault(_OverlayNavigator);
var _menu_burger=require('../images/menu_burger.png');var _menu_burger2=_interopRequireDefault(_menu_burger);
var _Scene=require('./Scene');var _Scene2=_interopRequireDefault(_Scene);
var _propTypes=require('prop-types');var _propTypes2=_interopRequireDefault(_propTypes);
Expand Down Expand Up @@ -66,7 +65,6 @@ var dontInheritKeys=[
'component',
'wrap',
'modal',
'overlay',
'drawer',
'tabs',
'navigator',
Expand Down Expand Up @@ -124,15 +122,15 @@ headerStyle:getValue(navigationParams.headerStyle||headerStyle||navigationBarSty
headerBackImage:navigationParams.backButtonImage||backButtonImage});

if(NavBar){
res.header=function(data){return _react2.default.createElement(NavBar,_extends({navigation:navigation},state,data,{__source:{fileName:_jsxFileName,lineNumber:127}}));};
res.header=function(data){return _react2.default.createElement(NavBar,_extends({navigation:navigation},state,data,{__source:{fileName:_jsxFileName,lineNumber:125}}));};
}

if(panHandlers===null){
res.gesturesEnabled=false;
}

if(navigationBarTitleImage){
res.headerTitle=_react2.default.createElement(Image,{source:navigationBarTitleImage,style:navigationBarTitleImageStyle,__source:{fileName:_jsxFileName,lineNumber:135}});
res.headerTitle=_react2.default.createElement(Image,{source:navigationBarTitleImage,style:navigationBarTitleImageStyle,__source:{fileName:_jsxFileName,lineNumber:133}});
}

if(tabBarLabel){
Expand All @@ -141,7 +139,7 @@ res.tabBarLabel=tabBarLabel;

if(tabBarIcon||icon){
var Icon=tabBarIcon||icon;
res.tabBarIcon=function(data){return _react2.default.createElement(Icon,_extends({},state,data,{__source:{fileName:_jsxFileName,lineNumber:144}}));};
res.tabBarIcon=function(data){return _react2.default.createElement(Icon,_extends({},state,data,{__source:{fileName:_jsxFileName,lineNumber:142}}));};
}
var componentData={};

Expand All @@ -159,20 +157,20 @@ if(rightButtonImage||rightTitle||params.renderRightButton||onRight||navigationPa
navigationParams.rightTitle||navigationParams.rightButtonImage||rightButtonTextStyle||
(drawerImage||drawerIcon)&&drawerPosition==='right'){
res.headerRight=getValue(navigationParams.right||navigationParams.rightButton||params.renderRightButton,_extends({},
navigationParams,screenProps))||_react2.default.createElement(RightNavBarButton,_extends({},params,navigationParams,componentData,{__source:{fileName:_jsxFileName,lineNumber:162}}));
navigationParams,screenProps))||_react2.default.createElement(RightNavBarButton,_extends({},params,navigationParams,componentData,{__source:{fileName:_jsxFileName,lineNumber:160}}));
}

if(leftButtonImage||backButtonImage||backTitle||leftTitle||params.renderLeftButton||leftButtonTextStyle||
backButtonTextStyle||onLeft||navigationParams.leftTitle||navigationParams.onLeft||navigationParams.leftButtonImage||
navigationParams.backButtonImage||navigationParams.backTitle||(drawerImage||drawerIcon)&&drawerPosition!=='right'){
res.headerLeft=getValue(navigationParams.left||navigationParams.leftButton||params.renderLeftButton,_extends({},params,navigationParams,screenProps))||
(onLeft&&(leftTitle||navigationParams.leftTitle||leftButtonImage||navigationParams.leftButtonImage)||drawerImage||drawerIcon)&&
_react2.default.createElement(LeftNavBarButton,_extends({},params,navigationParams,componentData,{__source:{fileName:_jsxFileName,lineNumber:170}}))||(
init?null:renderBackButton&&renderBackButton(state)||_react2.default.createElement(BackNavBarButton,_extends({},state,{__source:{fileName:_jsxFileName,lineNumber:171}})));
_react2.default.createElement(LeftNavBarButton,_extends({},params,navigationParams,componentData,{__source:{fileName:_jsxFileName,lineNumber:168}}))||(
init?null:renderBackButton&&renderBackButton(state)||_react2.default.createElement(BackNavBarButton,_extends({},state,{__source:{fileName:_jsxFileName,lineNumber:169}})));
}

if(back){
res.headerLeft=renderBackButton&&renderBackButton(state)||_react2.default.createElement(BackNavBarButton,_extends({},state,{__source:{fileName:_jsxFileName,lineNumber:175}}));
res.headerLeft=renderBackButton&&renderBackButton(state)||_react2.default.createElement(BackNavBarButton,_extends({},state,{__source:{fileName:_jsxFileName,lineNumber:173}}));
}

if(hideTabBar){
Expand All @@ -195,7 +193,7 @@ return null;
}
var wrapper=wrapBy||function(props){return props;};
function wrapped(_ref4){var navigation=_ref4.navigation,props=_objectWithoutProperties(_ref4,['navigation']);
return _react2.default.createElement(Component,_extends({},props,{navigation:navigation},navigation.state.params,{name:navigation.state.routeName,__source:{fileName:_jsxFileName,lineNumber:198}}));
return _react2.default.createElement(Component,_extends({},props,{navigation:navigation},navigation.state.params,{name:navigation.state.routeName,__source:{fileName:_jsxFileName,lineNumber:196}}));
}
wrapped.propTypes={
navigation:_propTypes2.default.object};
Expand Down Expand Up @@ -262,7 +260,7 @@ return null;
}
var res={};
var order=[];var _scene$props=
scene.props,tabs=_scene$props.tabs,modal=_scene$props.modal,overlay=_scene$props.overlay,lightbox=_scene$props.lightbox,navigator=_scene$props.navigator,contentComponent=_scene$props.contentComponent,lazy=_scene$props.lazy,drawer=_scene$props.drawer,parentProps=_objectWithoutProperties(_scene$props,['tabs','modal','overlay','lightbox','navigator','contentComponent','lazy','drawer']);
scene.props,tabs=_scene$props.tabs,modal=_scene$props.modal,lightbox=_scene$props.lightbox,navigator=_scene$props.navigator,contentComponent=_scene$props.contentComponent,lazy=_scene$props.lazy,drawer=_scene$props.drawer,parentProps=_objectWithoutProperties(_scene$props,['tabs','modal','lightbox','navigator','contentComponent','lazy','drawer']);

var commonProps=_extends({},inheritProps,parentProps);
delete commonProps.children;
Expand Down Expand Up @@ -362,9 +360,6 @@ return(0,_reactNavigation.TabNavigator)(res,_extends({lazy:lazy,initialRouteName
tabBarOptions:createTabBarOptions(commonProps),navigationOptions:createNavigationOptions(commonProps)}));
}else if(drawer){
return(0,_reactNavigation.DrawerNavigator)(res,_extends({initialRouteName:initialRouteName,contentComponent:contentComponent,order:order},commonProps));
}else if(overlay){
return(0,_OverlayNavigator2.default)(res,_extends({mode:mode,initialRouteParams:initialRouteParams,order:order,contentComponent:contentComponent,initialRouteName:initialRouteName},commonProps,{
navigationOptions:createNavigationOptions(commonProps)}));
}
return(0,_reactNavigation.StackNavigator)(res,_extends({mode:mode,initialRouteParams:initialRouteParams,initialRouteName:initialRouteName},commonProps,{navigationOptions:createNavigationOptions(commonProps)}));
};this.
Expand Down
7 changes: 1 addition & 6 deletions src/navigationStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { View } from 'react-native';
import { TabNavigator, DrawerNavigator, StackNavigator, NavigationActions } from 'react-navigation';
import { LeftButton, RightButton, BackButton } from './NavBar';
import LightboxNavigator from './LightboxNavigator';
import OverlayNavigator from './OverlayNavigator';
import _drawerImage from '../images/menu_burger.png';
import Scene from './Scene';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -66,7 +65,6 @@ const dontInheritKeys = [
'component',
'wrap',
'modal',
'overlay',
'drawer',
'tabs',
'navigator',
Expand Down Expand Up @@ -262,7 +260,7 @@ class NavigationStore {
}
const res = {};
const order = [];
const { tabs, modal, overlay, lightbox, navigator, contentComponent, lazy, drawer, ...parentProps } = scene.props;
const { tabs, modal, lightbox, navigator, contentComponent, lazy, drawer, ...parentProps } = scene.props;

const commonProps = { ...inheritProps, ...parentProps };
delete commonProps.children;
Expand Down Expand Up @@ -362,9 +360,6 @@ class NavigationStore {
tabBarOptions: createTabBarOptions(commonProps), navigationOptions: createNavigationOptions(commonProps) });
} else if (drawer) {
return DrawerNavigator(res, { initialRouteName, contentComponent, order, ...commonProps });
} else if (overlay) {
return OverlayNavigator(res, { mode, initialRouteParams, order, contentComponent, initialRouteName, ...commonProps,
navigationOptions: createNavigationOptions(commonProps) });
}
return StackNavigator(res, { mode, initialRouteParams, initialRouteName, ...commonProps, navigationOptions: createNavigationOptions(commonProps) });
};
Expand Down

0 comments on commit 8ddf62e

Please sign in to comment.