import React from 'react'; import { View, Text, StyleSheet, Modal, TouchableOpacity, } from 'react-native'; import { Colors } from '../../constants/Colors'; interface PostOptionsModalProps { visible: boolean; onClose: () => void; onReport: () => void; onShare?: () => void; onSave?: () => void; onCopyLink?: () => void; isOwner?: boolean; onEdit?: () => void; onDelete?: () => void; /** Hide this post / "Not interested" — client-side feed filter. */ onHidePost?: () => void; /** Block the post's author. */ onBlockUser?: () => void; /** Username shown in the block/hide labels for clarity. */ authorUsername?: string; /** Whether the author is already blocked (toggles label to Unblock). */ isBlocked?: boolean; } interface OptionItem { label: string; icon: string; onPress: () => void; destructive?: boolean; hidden?: boolean; } export default function PostOptionsModal({ visible, onClose, onReport, onShare, onSave, onCopyLink, isOwner = false, onEdit, onDelete, onHidePost, onBlockUser, authorUsername, isBlocked = false, }: PostOptionsModalProps) { const handleOptionPress = (onPress: () => void) => { onClose(); // Small delay to allow modal to close before opening another modal setTimeout(() => onPress(), 200); }; const options: OptionItem[] = [ { label: 'Share', icon: '📤', onPress: () => onShare?.(), hidden: !onShare, }, { label: 'Save', icon: '🔖', onPress: () => onSave?.(), hidden: !onSave, }, { label: 'Copy link', icon: '🔗', onPress: () => onCopyLink?.(), hidden: !onCopyLink, }, { label: 'Edit', icon: '✏️', onPress: () => onEdit?.(), hidden: !isOwner || !onEdit, }, { // Client-side "not interested" filter — hides the post from the feed. label: 'Hide this post', icon: '🙈', onPress: () => onHidePost?.(), hidden: isOwner || !onHidePost, }, { label: isBlocked ? `Unblock${authorUsername ? ` @${authorUsername}` : ''}` : `Block${authorUsername ? ` @${authorUsername}` : ''}`, icon: '🚫', onPress: () => onBlockUser && handleOptionPress(onBlockUser), destructive: !isBlocked, hidden: isOwner || !onBlockUser, }, { label: 'Report', icon: '🚩', onPress: () => handleOptionPress(onReport), destructive: true, hidden: isOwner, // Don't show report option for own posts }, { label: 'Delete', icon: '🗑️', onPress: () => onDelete?.(), destructive: true, hidden: !isOwner || !onDelete, }, ]; const visibleOptions = options.filter(opt => !opt.hidden); return ( {visibleOptions.map((option, index) => ( {option.icon} {option.label} ))} Cancel ); } const styles = StyleSheet.create({ overlay: { flex: 1, backgroundColor: 'rgba(0, 0, 0, 0.5)', justifyContent: 'flex-end', }, container: { padding: 8, paddingBottom: 34, // Safe area padding }, content: { backgroundColor: Colors.surface, borderRadius: 14, overflow: 'hidden', }, handleBar: { width: 40, height: 4, backgroundColor: Colors.border, borderRadius: 2, alignSelf: 'center', marginTop: 8, marginBottom: 8, }, option: { flexDirection: 'row', alignItems: 'center', paddingVertical: 16, paddingHorizontal: 20, borderBottomWidth: 1, borderBottomColor: Colors.border, }, lastOption: { borderBottomWidth: 0, }, optionIcon: { fontSize: 20, marginRight: 14, }, optionLabel: { fontSize: 16, color: Colors.text, }, destructiveLabel: { color: Colors.error, }, cancelButton: { backgroundColor: Colors.surface, borderRadius: 14, marginTop: 8, paddingVertical: 16, alignItems: 'center', }, cancelText: { fontSize: 16, fontWeight: '600', color: Colors.accent, }, });