import React from 'react';
import { Image } from 'react-native';

interface IAvatarProps {
  src: string;
  size?: number | 'small' | 'medium' | 'large' | 'xlarge';
  borderRadius?: number;
  imageStyle?: object;
}

export const ImageAvatar = ({
  src,
  size = 'medium',
  imageStyle,
  borderRadius,
}: IAvatarProps) => {
  const sz =
    size === 'small'
      ? 24
      : size === 'medium'
      ? 36
      : size === 'large'
      ? 48
      : size === 'xlarge'
      ? 60
      : size;

  const imageDefaultStyle = {
    borderRadius: borderRadius ? borderRadius : sz * 0.5,
    width: sz,
    height: sz,
  };

  return (
    <Image style={[imageDefaultStyle, imageStyle]} source={{ uri: src }} />
  );
};
