import { Fab, Theme } from "@mui/material";
import Icon from "assets/products/Aviation/AddPlaneIconBlack.png";
import { ImgIcon } from "common/ImgIcon";
import { useMobile } from "hooks";
import { makeStyles } from "@mui/styles";


interface Props {
  onClick: () => void;
  pulse: boolean;
}

const useStyles = makeStyles((theme: Theme) => ({
    "@keyframes pulsate": {
      to: {
        boxShadow: "0 0 0 16px" + theme.palette.primary.main + "00"
      }
    },
    fab: {
      background: theme.palette.primary.main,
      "&:hover": {
        background: theme.palette.primary.main
      },
      "&:focus": {
        background: theme.palette.primary.main
      },
      position: "fixed",
      bottom: theme.spacing(8), //for mobile navigator
      right: theme.spacing(2),
      [theme.breakpoints.up("sm")]: {
        bottom: theme.spacing(2)
      }
    },
    pulse: {
      boxShadow: "0 0 0 0 " + theme.palette.primary.main + "75",
      animation: "$pulsate 1.75s infinite cubic-bezier(0.66, 0.33, 0, 1)"
    }
}));

export default function AddFab(props: Props) {
  const { onClick, pulse } = props;
  const classes = useStyles();
  const isMobile = useMobile();

  const pulseString = pulse ? classes.pulse : "";
  const classString = classes.fab + " " + pulseString;

  return (
    <Fab
      onClick={onClick}
      aria-label="Add New Gate"
      className={classString}
      size={isMobile ? "medium" : "large"}>
      <ImgIcon alt="Add New Gate" src={Icon} />
    </Fab>
  );
}
