Skip to content

Instantly share code, notes, and snippets.

@FabricioFFC
Created July 2, 2018 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabricioFFC/f3d907cbe88625b2b6a0bb0542c1048b to your computer and use it in GitHub Desktop.
Save FabricioFFC/f3d907cbe88625b2b6a0bb0542c1048b to your computer and use it in GitHub Desktop.
import React from 'react';
import PropTypes from 'prop-types';
import {
StyleSheet,
Text,
Image,
TouchableOpacity,
} from 'react-native';
import { withNavigation } from 'react-navigation';
const styles = StyleSheet.create({
flag: {
borderWidth: 1,
borderColor: '#c7c6c6',
flex: 1,
height: 22,
width: 32,
},
item: {
flex: 3,
paddingLeft: 10,
},
itemContainer: {
alignItems: 'center',
backgroundColor: '#fff',
flex: 1,
flexDirection: 'row',
marginBottom: 10,
marginRight: 10,
paddingLeft: 10,
paddingRight: 10,
paddingVertical: 10,
},
});
const TeamItem = ({ item, navigation }) => {
const goToDetails = teamCode => navigation.navigate('TeamDetails', { teamCode });
return (
<TouchableOpacity onPress={() => goToDetails(item.code)} style={styles.itemContainer}>
<Image
style={styles.flag}
source={{ uri: item.flag }}
/>
<Text style={styles.item}>{item.name}</Text>
</TouchableOpacity>
);
};
TeamItem.propTypes = {
item: PropTypes.shape({
flag: PropTypes.string,
name: PropTypes.string,
code: PropTypes.string,
}).isRequired,
navigation: PropTypes.shape({
navigate: PropTypes.func,
}),
};
TeamItem.defaultProps = {
navigation: undefined,
};
export default withNavigation(TeamItem);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment