Created
September 23, 2016 23:28
-
-
Save jdmorlan/4f9f23eaacf9a36d730ea84c21cbdc71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const goTo = (viewName, opts = {}) => { | |
return (dispatch, getState) => { | |
const tabName = opts['tabName'] | |
const params = opts['params'] | |
const goingBack = opts['goingBack'] | |
const state = getState() | |
const currentTab = getCurrentTab(state) | |
let view | |
if (tabName === undefined) { | |
view = currentTab.views[viewName] | |
} else { | |
const tab = getTab(state, tabName) | |
view = tab.views[viewName] | |
} | |
const enhancedView = { ...view, params } | |
if (view.historical && !goingBack) { | |
dispatch(addHistoryItem(currentTab.id, currentTab.currentView)) | |
} | |
store.dispatch(setCurrentView(currentTab.id, enhancedView)) | |
store.dispatch(setNavHeaderVisibility(view.navHeaderVisible)) | |
store.dispatch(setTabBarVisibility(view.tabBarVisible)) | |
const formattedRoute = formatPatter(enhancedView.path, enhancedView.params) | |
dispatch(push(formattedRoute)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment