import React from "react"; import { Pressable, PressableProps } from "react-native"; import useThemeColor from "../useThemeColor"; import { usePrimaryColor } from "../PrimaryColorContext"; import Text from "./Text"; type ButtonTypeOptions = "default" | "primary" | "danger"; const dangerColor = "#f65555"; export default function TextButton({ text, onPress, type = "default", bgColor, textColor, disabled = false, flex = true, margin, marginHorizontal, marginVertical, marginLeft, marginRight, }: { text: string; onPress: PressableProps["onPress"]; type?: ButtonTypeOptions; bgColor?: string; textColor?: string; disabled?: boolean; flex?: boolean; margin?: number; marginHorizontal?: number; marginVertical?: number; marginLeft?: number; marginRight?: number; }) { const defaultTextColor = useThemeColor("text"); const defaultBorderColor = useThemeColor("border"); const disabledTextColor = useThemeColor("disabledText"); const disabledBgColor = useThemeColor("disabledBg"); const disabledBorderColor = useThemeColor("disabledBorder"); const primaryColor = usePrimaryColor(); const backgroundColor = bgColor ?? type === "primary" ? primaryColor : type === "danger" ? dangerColor : "transparent"; const borderColor = bgColor ?? type === "primary" ? primaryColor : type === "danger" ? dangerColor : defaultBorderColor; const color = textColor ?? type === "default" ? defaultTextColor : "#fff"; return ( ); }