/** Pure component for each Exhibitor Item **/
import React from 'react';
import { Image, Text, View } from 'react-native';
import { ListItem } from 'react-native-elements';
import colors from '../../config/colors.json';

class ExhibitorListItem extends React.PureComponent {
  /**
  * Creates the contact avatar
  **/
  renderAvatar({ item }) {
    return (
      <Image
        source={{ uri: item.profileAvatarImg }}
        style={styles.avatarImageStyle}
      />
    );
  }

  /**
  * Render method
  **/
  render() {
    const { item, onPress } = this.props;

    const title = `@${item.tagferId}`;
    const subTitle = (
      <View>
        <Text>{item.fullName || ''}</Text>
        <Text>{item.titleAndCompany || ''}</Text>
      </View>
    );

    if (item.profileAvatarImg) {
      return (
        <ListItem
          roundAvatar
          key={item.uid}
          title={title}
          subtitle={subTitle}
          titleStyle={{ fontWeight: 'bold', marginBottom: 5, color: colors.darkGreen }}
          onPress={onPress}
          leftIcon={this.renderAvatar({ item })}
          rightIcon={
            <View />
          }
        />
      );
    }

    return (
      <ListItem
        roundAvatar
        key={item.uid}
        title={title}
        subtitle={subTitle}
        titleStyle={{ fontWeight: 'bold', marginBottom: 5, color: colors.darkGreen }}
        onPress={onPress}
        leftIcon={{ name: 'account-circle', size: 50, color: colors.lightGrey }}
        rightIcon={
          <View />
        }
      />
    );
  }
}

const styles = {
  avatarImageStyle: {
    width: 40,
    height: 40,
    borderWidth: 1,
    borderRadius: 20,
    marginLeft: 5,
    marginRight: 10
  }
};

export default ExhibitorListItem;
