import * as React from 'react';
import {Image, StyleSheet, View} from 'react-native';
import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils';

interface TaggLoadingIndicatorProps {
  fullscreen?: boolean;
}

const TaggLoadingIndicator: React.FC<TaggLoadingIndicatorProps> = ({
  fullscreen = false,
}) => {
  return (
    <View
      style={[
        fullscreen ? styles.fullscreen : {},
        styles.container,
        styles.horizontal,
      ]}>
      <Image
        source={require('../../assets/gifs/loading-animation.gif')}
        style={styles.icon}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  fullscreen: {
    zIndex: 999,
    position: 'absolute',
    height: SCREEN_HEIGHT,
    width: SCREEN_WIDTH,
  },
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'rgba(0,0,0,0.3)',
  },
  horizontal: {
    flexDirection: 'row',
    justifyContent: 'space-around',
    padding: 10,
  },
  icon: {
    alignSelf: 'center',
    justifyContent: 'center',
    width: '40%',
    aspectRatio: 2,
  },
});

export default TaggLoadingIndicator;
