Skip to content

Commit

Permalink
fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
aksonov committed Oct 7, 2019
1 parent 63197a3 commit eedcb81
Showing 1 changed file with 60 additions and 55 deletions.
115 changes: 60 additions & 55 deletions src/navigationStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -253,47 +255,46 @@ 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 }) || (
<RightNavBarButton navigation={navigation} {...params} {...navigationParams} {...componentData} />
);
}

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) && (
<LeftNavBarButton navigation={navigation} {...params} {...navigationParams} {...componentData} />
)) ||
res.headerLeft ||
(init ? null : (!leftButton && renderBackButton && renderBackButton(state)) || (!leftButton && <BackNavBarButton navigation={navigation} {...state} />)) ||
null;
))
|| res.headerLeft
|| (init ? null : (!leftButton && renderBackButton && renderBackButton(state)) || (!leftButton && <BackNavBarButton navigation={navigation} {...state} />))
|| null;
}

if (back) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -533,7 +534,7 @@ class NavigationStore {
}
};

onExitHandler = prevScene => {
onExitHandler = (prevScene) => {
if (prevScene) {
const exitHandler = this[prevScene + OnExit];
if (exitHandler) {
Expand All @@ -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);
Expand All @@ -581,15 +580,15 @@ class NavigationStore {
}
};

setTopLevelNavigator = navigatorRef => {
setTopLevelNavigator = (navigatorRef) => {
this._navigator = navigatorRef;
};

addRef = (name, ref) => {
this.refs[name] = ref;
};

deleteRef = name => {
deleteRef = (name) => {
delete this.refs[name];
};

Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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] = {};
}
Expand Down Expand Up @@ -861,7 +866,7 @@ class NavigationStore {
});
};

dispatch = action => {
dispatch = (action) => {
if (this.externalDispatch) {
this.externalAction = action;
this.externalDispatch(action);
Expand Down

0 comments on commit eedcb81

Please sign in to comment.