import React from 'react';
import {
  View,
  Image,
  StyleSheet,
  TouchableOpacity,
  TouchableOpacityProps,
} from 'react-native';

interface NavigationIconProps extends TouchableOpacityProps {
  tab:
    | 'Home'
    | 'Search'
    | 'Upload'
    | 'Notifications'
    | 'Profile'
    | 'SuggestedPeople'
    | 'Chat';
  disabled?: boolean;
  newIcon?: boolean;
  isBigger?: boolean;
}

const NavigationIcon = (props: NavigationIconProps) => {
  let imgSrc;
  switch (props.tab) {
    case 'Home':
      imgSrc = props.disabled
        ? require('../../assets/navigationIcons/home.png')
        : require('../../assets/navigationIcons/home-clicked.png');
      break;
    case 'Search':
      imgSrc = props.disabled
        ? require('../../assets/navigationIcons/search.png')
        : require('../../assets/navigationIcons/search-clicked.png');
      break;
    case 'Upload':
      imgSrc = props.disabled
        ? require('../../assets/navigationIcons/new-upload.png')
        : require('../../assets/navigationIcons/upload-clicked.png');
      break;
    case 'Notifications':
      imgSrc = props.disabled
        ? props.newIcon
          ? require('../../assets/navigationIcons/new-notifications.png')
          : require('../../assets/navigationIcons/notifications.png')
        : require('../../assets/navigationIcons/notifications-clicked.png');
      break;
    case 'Chat':
      imgSrc = props.disabled
        ? props.newIcon
          ? require('../../assets/navigationIcons/chat-notifications.png')
          : require('../../assets/navigationIcons/chat.png')
        : require('../../assets/navigationIcons/chat-clicked.png');
      break;
    case 'Profile':
      imgSrc = props.disabled
        ? require('../../assets/navigationIcons/profile.png')
        : require('../../assets/navigationIcons/profile-clicked.png');
      break;
    case 'SuggestedPeople':
      imgSrc = props.disabled
        ? require('../../assets/navigationIcons/suggested-people.png')
        : require('../../assets/navigationIcons/suggested-people-clicked.png');
      break;
    default:
      imgSrc = null;
  }
  return (
    <View style={styles.container}>
      <TouchableOpacity {...props}>
        <Image
          source={imgSrc}
          style={props.isBigger ? styles.biggerIcon : styles.icon}
        />
      </TouchableOpacity>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    shadowColor: '#000000',
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowRadius: 2,
    shadowOpacity: 0.4,
  },
  icon: {
    height: 28,
    width: 28,
  },
  biggerIcon: {
    height: 44,
    width: 44,
  },
});

export default NavigationIcon;
