import { Pressable, View } from 'react-native'; import { cn } from '../../lib/cn'; import type { IconName } from '../Icon'; import { Icon } from '../Icon'; import { Text } from '../Text'; export type SnackbarVariant = 'default' | 'success' | 'info' | 'warning' | 'error'; export interface SnackbarProps { visible: boolean; message: string; variant?: SnackbarVariant; onDismiss?: () => void; actionLabel?: string; onActionPress?: () => void; className?: string; /** Si `true`, no muestra el icono inicial. */ hideIcon?: boolean; } const variantContainer: Record = { default: 'bg-content2', success: 'bg-success-50', info: 'bg-primary-50', warning: 'bg-warning-50', error: 'bg-danger-50', }; const variantText: Record = { default: 'text-foreground', success: 'text-success-700', info: 'text-primary-700', warning: 'text-warning-700', error: 'text-danger-700', }; const variantIcon: Record = { default: 'info', success: 'check', info: 'info', warning: 'alert', error: 'alert', }; /** * Snackbar atómico estilizado con NativeWind. * Reemplaza la versión basada en `react-native-paper`. * El control de duración y de la pila vive en el organism `Toaster`. */ export function Snackbar({ visible, message, variant = 'default', onDismiss, actionLabel, onActionPress, className, hideIcon = false, }: SnackbarProps) { if (!visible) { return null; } return ( {hideIcon ? null : ( )} {message} {actionLabel ? ( {actionLabel} ) : null} {onDismiss && !actionLabel ? ( ) : null} ); }