import { ActivityIndicator } from "react-native";

import { SizeEnum } from "@/constants/sizeEnum";

interface LoadingSpinnerProps {
  size?: SizeEnum.Large | SizeEnum.Small | number;
  color?: string;
}

export const LoadingSpinner = ({ size, color }: LoadingSpinnerProps) => {
  let resolvedSize: number | "small" | "large" = "large";

  if (typeof size === "number") {
    resolvedSize = size;
  } else if (size === SizeEnum.Small) {
    resolvedSize = "small";
  } else if (size === SizeEnum.Large) {
    resolvedSize = "large";
  }

  return <ActivityIndicator size={resolvedSize} color={color || "#6750a4"} />;
};
