import React from 'react';
import { Image, View, Text, ActivityIndicator } from 'react-native';
import styles from './Styles';
import { Colors } from '../../theme';
import FastImage from 'react-native-fast-image';

export interface Props {
  style: any;
  imageStyle?: any;
  source: any;
  defaultText?: any;
  defaultTextStyle?: any;
  defaultImage?: any;
  defaultImageStyle?: any;
  defaultImageRoundShape?: any;
}

class ImageX extends React.PureComponent<Props> {
  render() {
    const {
      style,
      imageStyle,
      source,
      defaultText,
      defaultTextStyle,
      defaultImage,
      defaultImageStyle,
      defaultImageRoundShape
    } = this.props;
    return (
      <View style={[style || {}, styles.imageView]}>
        {defaultText && (
          <Text style={[styles.defaultText, defaultTextStyle || {}]}>
            {defaultText}
          </Text>
        )}
        {defaultImage && (
          <Image
            source={defaultImage}
            style={[styles.defaultImage, defaultImageStyle || {}]}
          />
        )}
        {!!source.uri && (
          <FastImage style={[styles.image, imageStyle || {}]} source={source} />
        )}
      </View>
    );
  }
}

export default ImageX;
