diff --git a/Example/Example.js b/Example/Example.js
index c3becab88..49b4a05de 100644
--- a/Example/Example.js
+++ b/Example/Example.js
@@ -18,6 +18,7 @@ import {
Actions,
Reducer,
ActionConst,
+ Overlay,
Tabs,
Modal,
Drawer,
@@ -52,26 +53,28 @@ const reducerCreate = params => {
};
};
const getSceneStyle = () => ({
- backgroundColor: "white",
+ backgroundColor: "#F5FCFF",
shadowOpacity: 1,
shadowRadius: 3,
});
-
+const BackgroundView = () =>
const Example = () => (
-
-
- ({ screenInterpolator: CardStackStyleInterpolator.forFadeFromBottomAndroid })}>
-
-
- navigation.state.key} />
-
-
-
-
+
+
+ ({screenInterpolator: CardStackStyleInterpolator.forFadeFromBottomAndroid})}>
+
+
+ navigation.state.key}/>
+
+
+
+
-
+
-
(
tabBarLabel="TAB #1"
inactiveBackgroundColor='white' activeBackgroundColor='#dddddd'
icon={TabIcon}
- navigationBarStyle={{ backgroundColor: 'green' }}
- titleStyle={{ color: 'white', alignSelf: 'center' }}
+ navigationBarStyle={{backgroundColor: 'green'}}
+ titleStyle={{color: 'white', alignSelf: 'center'}}
>
- alert('Right button')}
- rightTitle="Right"
- />
+
+
+ alert('Right button')}
+ rightTitle="Right"
+ />
+
@@ -113,7 +119,8 @@ const Example = () => (
panHandlers={null}
/>
- {}}/>
+ {
+ }}/>
@@ -124,7 +131,7 @@ const Example = () => (
console.log("onExit")}
+ onExit={() => console.log("onExit")}
leftTitle="Cancel" onLeft={Actions.pop}/>
(
/>
-
-
- );
+
+
+
+);
export default Example;
diff --git a/Example/components/TabView.js b/Example/components/TabView.js
index 0e49d765a..39f65fb28 100644
--- a/Example/components/TabView.js
+++ b/Example/components/TabView.js
@@ -19,7 +19,7 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: 'center',
alignItems: 'center',
- backgroundColor: '#F5FCFF',
+ backgroundColor: 'transparent',
borderWidth: 2,
borderColor: 'red',
},
diff --git a/dist/Overlay.js b/dist/Overlay.js
new file mode 100644
index 000000000..4ae3b812e
--- /dev/null
+++ b/dist/Overlay.js
@@ -0,0 +1,9 @@
+Object.defineProperty(exports,"__esModule",{value:true});exports.default=
+
+
+
+
+
+
+
+function(){return null;};
\ No newline at end of file
diff --git a/dist/OverlayNavigator.js b/dist/OverlayNavigator.js
new file mode 100644
index 000000000..1c649d329
--- /dev/null
+++ b/dist/OverlayNavigator.js
@@ -0,0 +1,50 @@
+Object.defineProperty(exports,"__esModule",{value:true});var _jsxFileName='src/OverlayNavigator.js';
+
+var _react=require('react');var _react2=_interopRequireDefault(_react);
+var _reactNavigation=require('react-navigation');
+var _reactNative=require('react-native');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}
+
+var OverlayNavigator=function OverlayNavigator(
+routeConfigs)
+
+{var tabsConfig=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};
+var router=(0,_reactNavigation.TabRouter)(routeConfigs,tabsConfig);
+
+var navigator=(0,_reactNavigation.createNavigator)(
+router,
+routeConfigs,
+tabsConfig,
+'react-navigation/STACK')(
+function(_ref){var navigation=_ref.navigation;var
+state=navigation.state,dispatch=navigation.dispatch;var
+routes=state.routes;
+
+
+var Component=routeConfigs[tabsConfig.initialRouteName].screen;
+var initialIndex=0;
+for(var i=0;i=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}
+var _Tabs=require('./Tabs');var _Tabs2=_interopRequireDefault(_Tabs);
+var _Overlay=require('./Overlay');var _Overlay2=_interopRequireDefault(_Overlay);
+var _OverlayNavigator=require('./OverlayNavigator');var _OverlayNavigator2=_interopRequireDefault(_OverlayNavigator);function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj;}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key];}}newObj.default=obj;return newObj;}}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}
var RightNavBarButton=void 0;
var LeftNavBarButton=void 0;
@@ -75,6 +77,8 @@ var dontInheritKeys=[
'tabBarComponent',
'modal',
'drawer',
+'lightbox',
+'overlay',
'tabs',
'navigator',
'children',
@@ -131,7 +135,7 @@ 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:134}}));};
+res.header=function(data){return _react2.default.createElement(NavBar,_extends({navigation:navigation},state,data,{__source:{fileName:_jsxFileName,lineNumber:138}}));};
}
if(panHandlers===null){
@@ -139,7 +143,7 @@ res.gesturesEnabled=false;
}
if(navigationBarTitleImage){
-res.headerTitle=_react2.default.createElement(_reactNative.Image,{source:navigationBarTitleImage,style:navigationBarTitleImageStyle,__source:{fileName:_jsxFileName,lineNumber:142}});
+res.headerTitle=_react2.default.createElement(_reactNative.Image,{source:navigationBarTitleImage,style:navigationBarTitleImageStyle,__source:{fileName:_jsxFileName,lineNumber:146}});
}
if(tabBarLabel){
@@ -148,7 +152,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:151}}));};
+res.tabBarIcon=function(data){return _react2.default.createElement(Icon,_extends({},state,data,{__source:{fileName:_jsxFileName,lineNumber:155}}));};
}
var componentData={};
@@ -166,7 +170,7 @@ 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:169}}));
+navigationParams,screenProps))||_react2.default.createElement(RightNavBarButton,_extends({},params,navigationParams,componentData,{__source:{fileName:_jsxFileName,lineNumber:173}}));
}
if(leftButtonImage||backButtonImage||backTitle||leftTitle||params.renderLeftButton||leftButtonTextStyle||
@@ -174,12 +178,12 @@ backButtonTextStyle||onLeft||navigationParams.leftTitle||navigationParams.onLeft
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:177}}))||(
-init?null:renderBackButton&&renderBackButton(state)||_react2.default.createElement(BackNavBarButton,_extends({},state,{__source:{fileName:_jsxFileName,lineNumber:178}})));
+_react2.default.createElement(LeftNavBarButton,_extends({},params,navigationParams,componentData,{__source:{fileName:_jsxFileName,lineNumber:181}}))||(
+init?null:renderBackButton&&renderBackButton(state)||_react2.default.createElement(BackNavBarButton,_extends({},state,{__source:{fileName:_jsxFileName,lineNumber:182}})));
}
if(back){
-res.headerLeft=renderBackButton&&renderBackButton(state)||_react2.default.createElement(BackNavBarButton,_extends({},state,{__source:{fileName:_jsxFileName,lineNumber:182}}));
+res.headerLeft=renderBackButton&&renderBackButton(state)||_react2.default.createElement(BackNavBarButton,_extends({},state,{__source:{fileName:_jsxFileName,lineNumber:186}}));
}
if(hideTabBar){
@@ -218,7 +222,7 @@ Wrapped=(_temp=_class=function(_React$Component){_inherits(Wrapped,_React$Compon
{
var navigation=this.props.navigation;
-if(this.ref){
+if(this.ref&&navigation.state.routeName){
store.addRef(originalRouteName(navigation.state.routeName),this.ref);
}
}},{key:'componentWillUnmount',value:function componentWillUnmount()
@@ -229,7 +233,7 @@ store.deleteRef(originalRouteName(navigation.state.routeName));
}},{key:'render',value:function render()
{var _this2=this;
var navigation=this.props.navigation;
-return _react2.default.createElement(Component,_extends({ref:function ref(_ref4){return _this2.ref=_ref4;}},this.props,navigation.state.params,{name:navigation.state.routeName,__source:{fileName:_jsxFileName,lineNumber:232}}));
+return _react2.default.createElement(Component,_extends({ref:function ref(_ref4){return _this2.ref=_ref4;}},this.props,navigation.state.params,{name:navigation.state.routeName,__source:{fileName:_jsxFileName,lineNumber:236}}));
}}]);return Wrapped;}(_react2.default.Component),_class.propTypes={navigation:_propTypes2.default.object},_temp);
return wrapper(Wrapped);
@@ -237,7 +241,7 @@ return wrapper(Wrapped);
function StatelessWrapped(_ref5){var navigation=_ref5.navigation,props=_objectWithoutProperties(_ref5,['navigation']);
-return _react2.default.createElement(Component,_extends({},props,{navigation:navigation},navigation.state.params,{name:navigation.state.routeName,__source:{fileName:_jsxFileName,lineNumber:240}}));
+return _react2.default.createElement(Component,_extends({},props,{navigation:navigation},navigation.state.params,{name:navigation.state.routeName,__source:{fileName:_jsxFileName,lineNumber:244}}));
}
StatelessWrapped.propTypes={
navigation:_propTypes2.default.object};
@@ -315,7 +319,7 @@ return null;
var res={};
var order=[];var _scene$props=
scene.props,navigator=_scene$props.navigator,contentComponent=_scene$props.contentComponent,tabBarPosition=_scene$props.tabBarPosition,lazy=_scene$props.lazy,duration=_scene$props.duration,parentProps=_objectWithoutProperties(_scene$props,['navigator','contentComponent','tabBarPosition','lazy','duration']);var
-tabs=parentProps.tabs,modal=parentProps.modal,lightbox=parentProps.lightbox,drawer=parentProps.drawer,tabBarComponent=parentProps.tabBarComponent,transitionConfig=parentProps.transitionConfig;
+tabs=parentProps.tabs,modal=parentProps.modal,lightbox=parentProps.lightbox,overlay=parentProps.overlay,drawer=parentProps.drawer,tabBarComponent=parentProps.tabBarComponent,transitionConfig=parentProps.transitionConfig;
if(scene.type===_Modal2.default){
modal=true;
}else if(scene.type===_Drawer2.default){
@@ -324,6 +328,8 @@ drawer=true;
lightbox=true;
}else if(scene.type===_Tabs2.default){
tabs=true;
+}else if(scene.type===_Overlay2.default){
+overlay=true;
}
if(duration!==undefined&&!transitionConfig){
@@ -346,7 +352,7 @@ commonProps.drawerImage=commonProps.drawerImage||_menu_burger2.default;
var children=!Array.isArray(parentProps.children)?[parentProps.children]:[].concat.apply([],parentProps.children);
-if(!drawer&&!tabs){
+if(!drawer&&!tabs&&!overlay){
children.push.apply(children,_toConsumableArray(clones));
}
@@ -427,13 +433,16 @@ if(lightbox){
return(0,_LightboxNavigator2.default)(res,_extends({mode:mode,initialRouteParams:initialRouteParams,initialRouteName:initialRouteName},commonProps,{navigationOptions:createNavigationOptions(commonProps)}));
}else if(tabs){
if(!tabBarComponent){
-tabBarComponent=tabBarPosition==='top'?function(props){return _react2.default.createElement(_reactNavigation.TabBarTop,_extends({},props,commonProps,{__source:{fileName:_jsxFileName,lineNumber:430}}));}:
-function(props){return _react2.default.createElement(_reactNavigation.TabBarBottom,_extends({},props,commonProps,{__source:{fileName:_jsxFileName,lineNumber:431}}));};
+tabBarComponent=tabBarPosition==='top'?function(props){return _react2.default.createElement(_reactNavigation.TabBarTop,_extends({},props,commonProps,{__source:{fileName:_jsxFileName,lineNumber:436}}));}:
+function(props){return _react2.default.createElement(_reactNavigation.TabBarBottom,_extends({},props,commonProps,{__source:{fileName:_jsxFileName,lineNumber:437}}));};
}
return(0,_reactNavigation.TabNavigator)(res,_extends({lazy:lazy,initialRouteName:initialRouteName,initialRouteParams:initialRouteParams,order:order},commonProps,{
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({lazy:lazy,initialRouteName:initialRouteName,initialRouteParams:initialRouteParams,order:order},commonProps,{
+tabBarOptions:createTabBarOptions(commonProps),navigationOptions:createNavigationOptions(commonProps)}));
}
return(0,_reactNavigation.StackNavigator)(res,_extends({mode:mode,initialRouteParams:initialRouteParams,initialRouteName:initialRouteName},commonProps,{transitionConfig:transitionConfig,navigationOptions:createNavigationOptions(commonProps)}));
};this.
diff --git a/src/Overlay.js b/src/Overlay.js
new file mode 100644
index 000000000..cac8b838d
--- /dev/null
+++ b/src/Overlay.js
@@ -0,0 +1,9 @@
+/**
+ * Copyright (c) 2015-present, Pavel Aksonov
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ */
+export default () => null;
diff --git a/src/OverlayNavigator.js b/src/OverlayNavigator.js
new file mode 100644
index 000000000..5e60293e5
--- /dev/null
+++ b/src/OverlayNavigator.js
@@ -0,0 +1,50 @@
+/* @flow */
+
+import React from 'react';
+import { createNavigationContainer, createNavigator, TabRouter } from 'react-navigation';
+import { View } from 'react-native';
+
+const OverlayNavigator = (
+ routeConfigs,
+ tabsConfig = {}
+) => {
+ const router = TabRouter(routeConfigs, tabsConfig);
+
+ const navigator = createNavigator(
+ router,
+ routeConfigs,
+ tabsConfig,
+ 'react-navigation/STACK'
+ )(({ navigation }) => {
+ const { state, dispatch } = navigation;
+ const { routes } = state;
+
+ // Figure out what to render based on the navigation state and the router:
+ const Component = routeConfigs[tabsConfig.initialRouteName].screen;
+ let initialIndex = 0;
+ for (let i = 0; i < routes.length; i++) {
+ const route = routes[i];
+ if (route.routeName === tabsConfig.initialRouteName) {
+ initialIndex = i;
+ }
+ }
+ const initialRouteName = tabsConfig.initialRouteName || routes[initialIndex].routeName;
+ const overlays = [];
+ for (let i = 0; i < tabsConfig.order.length; i++) {
+ const routeName = tabsConfig.order[i];
+ if (initialRouteName !== routeName) {
+ const Overlay = routeConfigs[routeName].screen;
+ overlays.push();
+ }
+ }
+ const ContentComponent = tabsConfig.contentComponent || View;
+ return (
+
+ {overlays}
+ );
+ });
+
+ return createNavigationContainer(navigator, tabsConfig.containerOptions);
+};
+
+export default OverlayNavigator;
diff --git a/src/index.js b/src/index.js
index 3d8ea58bb..bc45df1a4 100644
--- a/src/index.js
+++ b/src/index.js
@@ -8,6 +8,7 @@ import Lightbox from './Lightbox';
import Stack from './Stack';
import Drawer from './Drawer';
import Tabs from './Tabs';
+import Overlay from './Overlay';
export {
ActionConst,
@@ -20,4 +21,5 @@ export {
Stack,
Drawer,
Tabs,
+ Overlay,
};
diff --git a/src/navigationStore.js b/src/navigationStore.js
index 05256f950..3bfe4b21a 100644
--- a/src/navigationStore.js
+++ b/src/navigationStore.js
@@ -16,6 +16,8 @@ import Modal from './Modal';
import Lightbox from './Lightbox';
import Drawer from './Drawer';
import Tabs from './Tabs';
+import Overlay from './Overlay';
+import OverlayNavigator from './OverlayNavigator';
let RightNavBarButton;
let LeftNavBarButton;
@@ -75,6 +77,8 @@ const dontInheritKeys = [
'tabBarComponent',
'modal',
'drawer',
+ 'lightbox',
+ 'overlay',
'tabs',
'navigator',
'children',
@@ -218,7 +222,7 @@ function createWrapper(Component, wrapBy, store: NavigationStore) {
}
componentDidMount() {
const navigation = this.props.navigation;
- if (this.ref) {
+ if (this.ref && navigation.state.routeName) {
store.addRef(originalRouteName(navigation.state.routeName), this.ref);
}
}
@@ -315,7 +319,7 @@ class NavigationStore {
const res = {};
const order = [];
const { navigator, contentComponent, tabBarPosition, lazy, duration, ...parentProps } = scene.props;
- let { tabs, modal, lightbox, drawer, tabBarComponent, transitionConfig } = parentProps;
+ let { tabs, modal, lightbox, overlay, drawer, tabBarComponent, transitionConfig } = parentProps;
if (scene.type === Modal) {
modal = true;
} else if (scene.type === Drawer) {
@@ -324,6 +328,8 @@ class NavigationStore {
lightbox = true;
} else if (scene.type === Tabs) {
tabs = true;
+ } else if (scene.type === Overlay) {
+ overlay = true;
}
if (duration !== undefined && !transitionConfig) {
@@ -346,7 +352,7 @@ class NavigationStore {
const children = !Array.isArray(parentProps.children) ? [parentProps.children] : [].concat.apply([], parentProps.children);
// add clone scenes
- if (!drawer && !tabs) {
+ if (!drawer && !tabs && !overlay) {
children.push(...clones);
}
// add all clones
@@ -434,6 +440,9 @@ class NavigationStore {
tabBarOptions: createTabBarOptions(commonProps), navigationOptions: createNavigationOptions(commonProps) });
} else if (drawer) {
return DrawerNavigator(res, { initialRouteName, contentComponent, order, ...commonProps });
+ } else if (overlay) {
+ return OverlayNavigator(res, { lazy, initialRouteName, initialRouteParams, order, ...commonProps,
+ tabBarOptions: createTabBarOptions(commonProps), navigationOptions: createNavigationOptions(commonProps) });
}
return StackNavigator(res, { mode, initialRouteParams, initialRouteName, ...commonProps, transitionConfig, navigationOptions: createNavigationOptions(commonProps) });
};