import { AntDesign } from "@expo/vector-icons";
import { router } from "expo-router";
import React from "react";
import { AntDesignIconNames } from "./Icons";
import Button, { ButtonProps } from "./ui/Button";

interface Props extends ButtonProps {
  icon?: AntDesignIconNames;
}

export default React.forwardRef<any, Props>(
  ({ icon, onPress, className, ...props }, ref): React.ReactElement => {
    const defaultOnPress = () => {
      router.back();
    };

    return (
      <Button
        className={"h-16 w-16 mb-4" + " " + className}
        onPress={onPress ?? defaultOnPress}
        {...ref}
        {...props}
      >
        <AntDesign name={icon ?? "arrowleft"} size={24} />
      </Button>
    );
  }
);
