import React from 'react';
import { Avatar } from 'react-native-elements';

const TagferAvatar = ({ size, photoURL, style, color }) => {
  const uri = photoURL ? { uri: photoURL } : null;
  const icon = !photoURL ? { name: 'user', type: 'entypo' } : null;

  return (
    <Avatar
      {...getSize(size)}
      rounded
      icon={icon}
      source={uri}
      activeOpacity={0.7}
      containerStyle={style}
      overlayContainerStyle={{ backgroundColor: color }}
    />
  );
};

function getSize(size) {
  switch (size) {
    case 'small': return { small: true };
    case 'medium': return { medium: true };
    case 'large': return { large: true };
    case 'xlarge': return { xlarge: true };
    default: throw new Error('Unsupported Tagfer Avatar size');
  }
}
export default TagferAvatar;
