Skip to content

Instantly share code, notes, and snippets.

@shawn-kb
Created February 23, 2018 17:13
Show Gist options
  • Save shawn-kb/fbc8840597d0d930a21cbe94c21a81b9 to your computer and use it in GitHub Desktop.
Save shawn-kb/fbc8840597d0d930a21cbe94c21a81b9 to your computer and use it in GitHub Desktop.
navigating back or popping the stack
function backToSummary(){
console.log("running back to summary")
const resetAction = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({routeName: 'Main'})]
})
this.props.navigation.dispatch(resetAction);
}
/*
const HomeIconComponent = ({ navigation }) => (
<TouchableOpacity onPress={() => this.props.navigation.navigate('Main')}>
<Icon/>
</TouchableOpacity>
)
*/
const HomeIconComponent = ({ navigation }) => (
<TouchableOpacity onPress={backToSummary}>
<Icon/>
</TouchableOpacity>
)
export default TabNavigator(
{
SiteDrawer: {
screen: SiteDrawer,
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ tintColor, focused }) => (
<Ionicons focused={focused} color={tintColor} name={Platform.OS === 'ios' ? `ios-information-circle${focused ? '' : '-outline'}` : 'md-information-circle' } />
),
})
},
Control: {
screen: SiteControlScreen,
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ tintColor, focused }) => (
<Ionicons focused={focused} color={tintColor} name={Platform.OS === 'ios' ? `ios-link${focused ? '' : '-outline'}` : 'md-link' } />
),
})
},
Pressure: {
screen: SitePressureScreen,
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ tintColor, focused }) => (
<Ionicons focused={focused} color={tintColor} name={Platform.OS === 'ios' ? `ios-options${focused ? '' : '-outline'}` : 'md-options' } />
),
})
},
Home: {
screen: HomeIconComponent,
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ tintColor, focused }) => (
<HomeIconComponent color={tintColor} navigation={navigation} focused={focused}/>
),
})
},
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment