/**
 * Learn more about light and dark modes:
 * https://docs.expo.dev/guides/color-schemes/
 */

import { ColorName } from "@/constants/theme";
import { useThemeContext } from "@/hooks/use-theme-context";

export function useThemeColor(
  props: { light?: string; dark?: string },
  colorName: ColorName
) {
  const { colorScheme, getColor } = useThemeContext();
  const colorFromProps = props[colorScheme];

  if (colorFromProps) {
    return colorFromProps;
  } else {
    return getColor(colorName);
  }
}
