jbkuczma / NBAreact

🏀 iOS and Android NBA app created with React Native
MIT License
105 stars 46 forks source link

Have tapping on a Tab button take you to the initial scene #55

Closed jbkuczma closed 6 years ago

jbkuczma commented 6 years ago

In other apps when you tap on a tab button it will perform a function (ex: Instagram: search for a user, click their profile, click search tab button takes you back to the initial search screen).

When you click the tab button while in a nested scene for that tab, you should go back to the root scene (ex: Scores screen -> game -> boxscore -> tap scores tab button -> back to Scores screen).

Something along the lines of the following would go in navigationOptions({...}) of the tab navigator:

tabBarOnPress: (scene, jumpToIndex) => { console.log('onPress:', scene) }

source: https://reactnavigation.org/docs/tab-navigator.html#tabbaronpress

jbkuczma commented 6 years ago

The following works as intended BUT there is a bug

tabBarOnPress: ({ scene, jumpToIndex }) => {
  console.log('onPress:', scene);
  if (scene.route.index !== 0) {
    navigation.popToTop()
  } else {
    jumpToIndex(scene.index)
  }
}

BUG: standings -> team -> games -> game -> scores tab -> game -> tap scores tab and then standings (can't view standings tab)

jbkuczma commented 6 years ago

side effect noted in comment:

placing this issue on hold and creating a new issue for the problem described above