import { styles } from "@/styles/components/button"; import { MaterialIcons } from "@expo/vector-icons"; import { getRippleColor } from "@/functions/util"; import type { RefObject } from "react"; import { type AnimatableNumericValue, type ColorValue, type DimensionValue, type View, Pressable, Text, } from "react-native"; interface Props { onPress: () => unknown | Promise; disabled?: boolean; color: ColorValue; textColor?: ColorValue; text?: string; width?: DimensionValue; height?: DimensionValue; icon?: keyof typeof MaterialIcons.glyphMap; iconColor?: ColorValue; borderWidth?: number; borderColor?: ColorValue; borderRadius?: string | AnimatableNumericValue; iconSize?: number; padding?: number; rippleColor?: ColorValue; margin?: { top?: DimensionValue; bottom?: DimensionValue; left?: DimensionValue; right?: DimensionValue; }; flex?: number; position?: "left" | "center" | "right"; bold?: boolean; open?: boolean; ref?: RefObject; } export default function Button({ onPress = () => {}, disabled = false, color, textColor = "white", text, width, height, icon, iconColor = "white", borderWidth = 0, borderColor, iconSize = 20, padding = 10, margin = {}, rippleColor, flex, borderRadius, position, bold = true, open, ref, }: Props) { const flexPositions: { [key in "left" | "center" | "right"]: "center" | "flex-start" | "flex-end"; } = { center: "center", left: "flex-start", right: "flex-end", }; return ( {icon && } {text && ( {text} )} {typeof open === "boolean" && ( )} ); }