Skip to content

Instantly share code, notes, and snippets.

@shawn-kb
Created February 23, 2018 22:14
Show Gist options
  • Save shawn-kb/0fa96c4198f4dab05e32f9cbd8b596a0 to your computer and use it in GitHub Desktop.
Save shawn-kb/0fa96c4198f4dab05e32f9cbd8b596a0 to your computer and use it in GitHub Desktop.
how its called
class HomeIconComponent extends React.Component {
handleNavigation = () => {
const { navigation, focused } = this.props
if (!focused){
navigation.navigate("Home")
}else if (navigation.state.index == 0){
if (navigation.state.routes[navigation.state.index].index != 0){
navigation.goBack(null)
}
} else if (navigation.state.index == 1 || navigate.state.index == 2){
navigation.navigate("Home")
}
}
render(){
const { navigation, focused } = this.props
return(
<TouchableOpacity onPress={() => navigation.goBack() } style={{ justifyContent: 'center'}}>
<Ionicons name="md-home" size={30} color={focused ? Colors.buttonBlue : '#404040'}/>
</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: MainTabNavigator,
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