diff --git a/app/tabBar/reducer.js b/app/tabBar/reducer.js
index d5f8552..349fcdd 100644
--- a/app/tabBar/reducer.js
+++ b/app/tabBar/reducer.js
@@ -18,8 +18,8 @@ const reducer = (state=defaultState,action) => {
}
break;
- case 'Navigation/BACK':
- if ( action.key.routeIndexZero ) {
+ case 'ANDROID_BACK_ACTION':
+ if ( action.payload.routeIndexZero ) {
let currentIndex = state.index
return { ...state, index: currentIndex - 1 }
} else {
diff --git a/app/tabBar/views/TabBarNavigation.js b/app/tabBar/views/TabBarNavigation.js
index 053d278..0b77fac 100644
--- a/app/tabBar/views/TabBarNavigation.js
+++ b/app/tabBar/views/TabBarNavigation.js
@@ -39,8 +39,6 @@ class TabBarNavigation extends React.Component {
handleBackAction = () => {
const { navigationState: {index: tabIndex}, tabOneIndex, tabTwoIndex, tabThreeIndex } = this.props
- console.log('back action..', this.props)
-
const tabIndexArray = [ tabOneIndex, tabTwoIndex, tabThreeIndex ]
const routeIndexZero = (tabIndexArray[tabIndex] === 0) ? true:false
@@ -48,7 +46,9 @@ class TabBarNavigation extends React.Component {
if ( tabIndex === 0 && routeIndexZero ) {
return false
} else {
- this.navigator.props.navigation.goBack({tabIndex:tabIndex,routeIndexZero:routeIndexZero})
+ this.navigator.props.navigation.dispatch(
+ {type:'ANDROID_BACK_ACTION',payload:{routeIndexZero:routeIndexZero,tabIndex:tabIndex}}
+ )
return true
}
}
diff --git a/app/tabOne/reducer.js b/app/tabOne/reducer.js
index a77d331..ebd275a 100644
--- a/app/tabOne/reducer.js
+++ b/app/tabOne/reducer.js
@@ -10,7 +10,7 @@ const defaultState = {
const reducer = (state=defaultState,action) => {
switch (action.type) {
case 'Navigation/NAVIGATE':
- let index = findRouteIndexByName(routeStack,action.routeName)
+ var index = findRouteIndexByName(routeStack,action.routeName)
if ( index !== -1 ) {
let newStack = state.routes.concat([routeStack[index]])
return { ...state, index: newStack.length - 1, routes:newStack }
@@ -20,7 +20,18 @@ const reducer = (state=defaultState,action) => {
break;
case 'Navigation/BACK':
- let { tabIndex, routeIndexZero } = action.key
+ var index = findRouteIndexByName(routeStack,action.key)
+ if ( index !== -1 ) {
+ let newStack = state.routes.slice(0,state.index)
+ let newIndex = state.index - 1
+ return { ...state, index:newIndex, routes:newStack }
+ } else {
+ return state
+ }
+ break;
+
+ case 'ANDROID_BACK_ACTION':
+ let { tabIndex, routeIndexZero } = action.payload
// check if the back action is for this tab and if the currentIndex is at zero
if (tabIndex === 0 && !routeIndexZero) {
let newStack = state.routes.slice(0,state.index)
diff --git a/app/tabThree/reducer.js b/app/tabThree/reducer.js
index aaef944..5ed45b9 100644
--- a/app/tabThree/reducer.js
+++ b/app/tabThree/reducer.js
@@ -20,9 +20,21 @@ const reducer = (state=defaultState,action) => {
break;
case 'Navigation/BACK':
- let { tabIndex, routeIndexZero } = action.key
+ var index = findRouteIndexByName(routeStack,action.key)
+ if ( index !== -1 ) {
+ let newStack = state.routes.slice(0,state.index)
+ let newIndex = state.index - 1
+ return { ...state, index:newIndex, routes:newStack }
+ } else {
+ return state
+ }
+ break;
+
+
+ case 'ANDROID_BACK_ACTION':
+ let { tabIndex, routeIndexZero } = action.payload
// check if the back action is for this tab and if the currentIndex is at zero
- if (tabIndex === 2 && !routeIndexZero) {
+ if (tabIndex === 2 && !routeIndexZero ) {
let newStack = state.routes.slice(0,state.index)
let newIndex = state.index - 1
return { ...state, index:newIndex, routes:newStack }
diff --git a/app/tabThree/views/TabThreeScreenThree.js b/app/tabThree/views/TabThreeScreenThree.js
index 425eb75..db4b784 100644
--- a/app/tabThree/views/TabThreeScreenThree.js
+++ b/app/tabThree/views/TabThreeScreenThree.js
@@ -12,7 +12,7 @@ export default class TabThreeScreenThree extends React.Component {
}}>
{ 'Tab Three Screen Three' }
this.props.navigation.goBack({tabIndex:2,routeIndexZero:false}) }
+ onPress={ () => this.props.navigation.goBack('TabThreeScreenThree') }
style={{
padding:20,
borderRadius:20,
diff --git a/app/tabThree/views/TabThreeScreenTwo.js b/app/tabThree/views/TabThreeScreenTwo.js
index f55652a..0da948a 100644
--- a/app/tabThree/views/TabThreeScreenTwo.js
+++ b/app/tabThree/views/TabThreeScreenTwo.js
@@ -21,9 +21,9 @@ export default class TabThreeScreenTwo extends React.Component {
}}>
{'Go to screen three'}
-
+
this.props.navigation.goBack({tabIndex:2,routeIndexZero:false}) }
+ onPress={ () => this.props.navigation.goBack('TabThreeScreenTwo') }
style={{
padding:20,
borderRadius:20,
diff --git a/app/tabTwo/reducer.js b/app/tabTwo/reducer.js
index 71fc94e..c8fba78 100644
--- a/app/tabTwo/reducer.js
+++ b/app/tabTwo/reducer.js
@@ -20,7 +20,19 @@ const reducer = (state=defaultState,action) => {
break;
case 'Navigation/BACK':
- let { tabIndex, routeIndexZero } = action.key
+ var index = findRouteIndexByName(routeStack,action.key)
+ if ( index !== -1 ) {
+ let newStack = state.routes.slice(0,state.index)
+ let newIndex = state.index - 1
+ return { ...state, index:newIndex, routes:newStack }
+ } else {
+ return state
+ }
+ break;
+
+
+ case 'ANDROID_BACK_ACTION':
+ let { tabIndex, routeIndexZero } = action.payload
// check if the back action is for this tab and if the currentIndex is at zero
if (tabIndex === 1 && !routeIndexZero) {
let newStack = state.routes.slice(0,state.index)