import { ActivityIndicator, View, type ColorValue, type StyleProp, type ViewStyle } from "react-native"; import { Text } from "@/components/fixed-text"; import { colors } from "@/theme/colors"; import { type } from "@/theme/type"; import { Icon, type IconProps } from "./icon"; import { PressableFeedback } from "./pressable-feedback"; type Variant = "primary" | "tonal" | "plain" | "destructive" | "warning"; type Size = "small" | "medium" | "large"; function fills(): Record { return { primary: { background: colors.accentFill, foreground: colors.onAccent }, tonal: { background: colors.fill, foreground: colors.label }, plain: { background: "transparent", foreground: colors.accent }, destructive: { background: colors.dangerSoft, foreground: colors.danger }, warning: { background: colors.waitingFill, foreground: colors.onAccent }, }; } const sizes: Record = { small: { height: 32, paddingHorizontal: 12, font: type.footnote, icon: 13 }, medium: { height: 40, paddingHorizontal: 16, font: type.subhead, icon: 15 }, large: { height: 50, paddingHorizontal: 20, font: type.headline, icon: 17 }, }; export function Button({ title, onPress, variant = "tonal", size = "medium", icon, busy = false, disabled = false, wide = false, style, accessibilityLabel, }: { title: string; onPress: () => void; variant?: Variant; size?: Size; icon?: Pick; busy?: boolean; disabled?: boolean; wide?: boolean; style?: StyleProp; accessibilityLabel?: string; }) { const fill = fills()[variant]; const metrics = sizes[size]; const inactive = disabled || busy; const height = Math.max(44, metrics.height); return ( {busy ? ( ) : icon ? ( ) : null} {title} ); }