diff --git a/src/navigationStore.js b/src/navigationStore.js index 3e7b5e87c..a709b7dc2 100644 --- a/src/navigationStore.js +++ b/src/navigationStore.js @@ -109,7 +109,9 @@ function getProperties(component = {}) { delete res.children; return res; } -function createTabBarOptions({ tabBarStyle, activeTintColor, inactiveTintColor, activeBackgroundColor, inactiveBackgroundColor, showLabel, labelStyle, tabStyle, ...props }) { +function createTabBarOptions({ + tabBarStyle, activeTintColor, inactiveTintColor, activeBackgroundColor, inactiveBackgroundColor, showLabel, labelStyle, tabStyle, ...props +}) { return { ...props, style: tabBarStyle, @@ -253,15 +255,15 @@ function createNavigationOptions(params) { } if ( - rightButtonImage || - rightTitle || - params.renderRightButton || - onRight || - navigationParams.onRight || - navigationParams.rightTitle || - navigationParams.rightButtonImage || - rightButtonTextStyle || - ((drawerImage || drawerIcon) && !hideDrawerButton && drawerPosition === 'right') + rightButtonImage + || rightTitle + || params.renderRightButton + || onRight + || navigationParams.onRight + || navigationParams.rightTitle + || navigationParams.rightButtonImage + || rightButtonTextStyle + || ((drawerImage || drawerIcon) && !hideDrawerButton && drawerPosition === 'right') ) { res.headerRight = getValue(navigationParams.right || navigationParams.rightButton || params.renderRightButton, { ...navigationParams, ...screenProps }) || ( @@ -269,31 +271,30 @@ function createNavigationOptions(params) { } if ( - leftButtonImage || - backButtonImage || - backTitle || - leftTitle || - params.renderLeftButton || - leftButtonTextStyle || - renderBackButton || - backButtonTextStyle || - onLeft || - navigationParams.leftTitle || - navigationParams.onLeft || - navigationParams.leftButtonImage || - navigationParams.backButtonImage || - navigationParams.backTitle || - ((drawerImage || drawerIcon) && !hideDrawerButton && drawerPosition !== 'right') + leftButtonImage + || backButtonImage + || backTitle + || leftTitle + || params.renderLeftButton + || leftButtonTextStyle + || renderBackButton + || backButtonTextStyle + || onLeft + || navigationParams.leftTitle + || navigationParams.onLeft + || navigationParams.leftButtonImage + || navigationParams.backButtonImage + || navigationParams.backTitle + || ((drawerImage || drawerIcon) && !hideDrawerButton && drawerPosition !== 'right') ) { const leftButton = navigationParams.left || navigationParams.leftButton || params.renderLeftButton; - res.headerLeft = - getValue(leftButton, { ...params, ...navigationParams, ...screenProps }) || - (((onLeft && (leftTitle || navigationParams.leftTitle || leftButtonImage || navigationParams.leftButtonImage)) || drawerImage || drawerIcon) && ( + res.headerLeft = getValue(leftButton, { ...params, ...navigationParams, ...screenProps }) + || (((onLeft && (leftTitle || navigationParams.leftTitle || leftButtonImage || navigationParams.leftButtonImage)) || drawerImage || drawerIcon) && ( - )) || - res.headerLeft || - (init ? null : (!leftButton && renderBackButton && renderBackButton(state)) || (!leftButton && )) || - null; + )) + || res.headerLeft + || (init ? null : (!leftButton && renderBackButton && renderBackButton(state)) || (!leftButton && )) + || null; } if (back) { @@ -334,7 +335,7 @@ function createNavigationOptions(params) { if (backToInitial) { const userDefinedTabBarOnPress = res.tabBarOnPress; - res.tabBarOnPress = data => { + res.tabBarOnPress = (data) => { if (userDefinedTabBarOnPress) { console.warn('backToInitial and tabBarOnPress were both defined and might cause unexpected navigation behaviors. I hope you know what you are doing ;-)'); userDefinedTabBarOnPress(data); @@ -365,11 +366,11 @@ function extendProps(props, store: NavigationStore) { const res = { ...props }; for (const transition of Object.keys(props)) { if ( - reservedKeys.indexOf(transition) === -1 && - transition.startsWith('on') && - transition.charAt(2) >= 'A' && - transition.charAt(2) <= 'Z' && - typeof props[transition] === 'string' + reservedKeys.indexOf(transition) === -1 + && transition.startsWith('on') + && transition.charAt(2) >= 'A' + && transition.charAt(2) <= 'Z' + && typeof props[transition] === 'string' ) { if (store[props[transition]]) { res[transition] = params => store[props[transition]](params); @@ -507,13 +508,13 @@ class NavigationStore { } } - setCustomReducer = Navigator => { + setCustomReducer = (Navigator) => { this.getStateForAction = Navigator.router.getStateForAction; const reducer = createReducer(); Navigator.router.getStateForAction = (cmd, state) => (this.reducer ? this.reducer(state, cmd) : reducer(state, cmd)); }; - onEnterHandler = async currentScene => { + onEnterHandler = async (currentScene) => { if (this.states[currentScene]) { const handler = this[currentScene + OnEnter]; const success = this.states[currentScene].success || defaultSuccess; @@ -533,7 +534,7 @@ class NavigationStore { } }; - onExitHandler = prevScene => { + onExitHandler = (prevScene) => { if (prevScene) { const exitHandler = this[prevScene + OnExit]; if (exitHandler) { @@ -560,13 +561,11 @@ class NavigationStore { if (this.currentScene !== this.prevScene) { // run onExit for old scene this.onExitHandler(this.prevScene); - setTimeout(() => - this.dispatch({ - type: ActionConst.FOCUS, - routeName: this.currentScene, - params: this.currentParams, - }), - ); + setTimeout(() => this.dispatch({ + type: ActionConst.FOCUS, + routeName: this.currentScene, + params: this.currentParams, + })); this.onEnterHandler(currentScene); } else { const routeName = getRouteNameByKey(this.state, action.key); @@ -581,7 +580,7 @@ class NavigationStore { } }; - setTopLevelNavigator = navigatorRef => { + setTopLevelNavigator = (navigatorRef) => { this._navigator = navigatorRef; }; @@ -589,7 +588,7 @@ class NavigationStore { this.refs[name] = ref; }; - deleteRef = name => { + deleteRef = (name) => { delete this.refs[name]; }; @@ -606,7 +605,7 @@ class NavigationStore { return createAppContainer(Navigator); }; - createAction = name => args => { + createAction = name => (args) => { // console.log(`Transition to state=${name}`); if (this.isLogical[name]) { this[name](args); @@ -622,8 +621,12 @@ class NavigationStore { } const res = {}; const order = []; - const { navigator, renderer, contentComponent, drawerWidth, drawerLockMode, tabBarPosition, lazy, duration, ...parentProps } = scene.props; - let { tabs, modal, lightbox, overlay, drawer, transitionConfig, tabBarComponent } = parentProps; + const { + navigator, renderer, contentComponent, drawerWidth, drawerLockMode, tabBarPosition, lazy, duration, ...parentProps + } = scene.props; + let { + tabs, modal, lightbox, overlay, drawer, transitionConfig, tabBarComponent, + } = parentProps; if (scene.type === Modal) { modal = true; } else if (scene.type === Drawer) { @@ -683,7 +686,9 @@ class NavigationStore { const key = child.key || `key${(counter += 1)}`; const init = key === children[0].key; assert(reservedKeys.indexOf(key) === -1, `Scene name cannot be reserved word: ${child.key}`); - const { component, type = tabs || drawer ? 'jump' : 'push', path, onEnter, onExit, on, failure, success, wrap, initial = false, ...props } = child.props; + const { + component, type = tabs || drawer ? 'jump' : 'push', path, onEnter, onExit, on, failure, success, wrap, initial = false, ...props + } = child.props; if (!this.states[key]) { this.states[key] = {}; } @@ -861,7 +866,7 @@ class NavigationStore { }); }; - dispatch = action => { + dispatch = (action) => { if (this.externalDispatch) { this.externalAction = action; this.externalDispatch(action);