import React from "react"; import { Button as PaperButton, ButtonProps } from "react-native-paper"; // import { useTheme } from "../hooks/theme-context"; import { theme, useTheme } from "common-ui"; import { TouchableOpacity } from "react-native"; import MyText from "./text"; // Updated import path // Omit 'children' from ButtonProps so it can't be passed interface Props extends Omit { variant?: "blue" | "red" | "green"; fillColor?: keyof ReturnType["theme"]["colors"]; textColor?: keyof ReturnType["theme"]["colors"]; borderColor?: keyof ReturnType["theme"]["colors"]; fullWidth?: boolean; textContent?: string; children?: React.ReactNode; } function MyButton({ variant = "blue", fullWidth, fillColor, textColor, borderColor, children, textContent, ...props }: Props) { const { colors } = useTheme().theme; let backgroundColor = colors.brand500; if (variant === "red") backgroundColor = colors.red1; if (variant === "green") backgroundColor = theme.colors.brand500 if (fillColor && colors[fillColor]) backgroundColor = colors[fillColor]; let finalTextColor = "#fff"; if (textColor && colors[textColor]) finalTextColor = colors[textColor]; let borderCol = backgroundColor; if (borderColor && colors[borderColor]) borderCol = colors[borderColor]; const labelStyle = { color: finalTextColor, fontWeight: "400" as const, ...(props.labelStyle as object), }; return ( {textContent ? {textContent} : children} ); } // MyTextButton props: same as Props, but no children and with an extra 'text' property interface MyTextButtonProps extends Omit { text: string; } export function MyTextButton({ variant = "blue", fillColor, textColor, text, ...props }: MyTextButtonProps) { return ( {text} ); } export default MyButton;