pepperoni-app-kit icon indicating copy to clipboard operation
pepperoni-app-kit copied to clipboard

Pop all routes on tap on active tab

Open Shamilik opened this issue 9 years ago • 1 comments

Is there any way to do this?

Shamilik avatar Aug 12 '16 09:08 Shamilik

@Shamilik There is no way with the current code, but it could be changed to something like this:

      case SWITCH_TAB: {
            // Switches the tab.
            const immutableTabs = state.get('tabs')
            const tabKey = immutableTabs.getIn(['routes', immutableTabs.get('index')]).get('key')

            const tabs = state.get('tabs').toJS()
            const nextTabs = NavigationStateUtils.jumpToIndex(tabs, action. payload)
            state = state.setIn([tabKey, 'index'], 0)
                .setIn([tabKey, 'routes'], initialState.getIn([tabKey, 'routes']))
            if (tabs !== nextTabs) {
                return state.set('tabs', fromJS(nextTabs))
            }
            return state
        }

You need to have at least 1 route so you can't pop out all of them. But you can reset the index to 0 and reset the route of the tapped key to the initial state what do you think?

Actually I am going to do the same on my application, because I think to the end user it make sense reinitialise the tab when tapped on.

fabriziomoscon avatar Sep 27 '16 12:09 fabriziomoscon