import { Modal, Pressable, View } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import type { IconName } from '../../atoms/Icon'; import { Icon } from '../../atoms/Icon'; import { Text } from '../../atoms/Text'; import { cn } from '../../lib/cn'; /** * ActionSheet legacy. Mantiene la API previa (Paper icon-name string en * `option.icon`) y traduce nombres conocidos a `Icon`. * * Para nuevos casos usar `ConfirmActionSheet` con `IconName` tipado. */ export interface ActionSheetOption { key: string; label: string; icon?: string; destructive?: boolean; onPress: () => void; } interface ActionSheetProps { visible: boolean; onClose: () => void; options: ActionSheetOption[]; } const paperToAppIcon: Record = { pencil: 'pencil', delete: 'trash', archive: 'archive', 'archive-outline': 'archive', send: 'send', edit: 'edit', close: 'close', 'cloud-upload': 'upload', 'cloud-sync': 'refresh', 'content-save-outline': 'save', }; function resolveIcon(name?: string): IconName | undefined { if (!name) return undefined; if (name in paperToAppIcon) return paperToAppIcon[name]; return name as IconName; } export function ActionSheet({ visible, onClose, options }: ActionSheetProps) { const insets = useSafeAreaInsets(); const handleOptionPress = (onPress: () => void) => { onClose(); onPress(); }; return ( {options.map((option) => { const iconName = resolveIcon(option.icon); return ( handleOptionPress(option.onPress)} className={cn('flex-row items-center gap-3 px-5 py-4 active:bg-content2')} > {iconName ? ( ) : null} {option.label} ); })} ); }