- gitgram-web (4): external link-preview/unfurl cards, rich inline embed players (YouTube/Twitch/Spotify/Vimeo) - gitgram-backend (1): natural-language feed filtering (preferredLangOnly) + Post.contentLanguage - gitgram-mobile (4): notification grouping/aggregation, shared timeAgo util - aitm-api (7): GitNexus graph-RAG query + context retrieval endpoints (flagship surface) - aitm-mcp (2): beads_claim atomic claim-for-work tool + brief-deps projection Note: gitgram-backend adds Post.contentLanguage — run prisma migrate at deploy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
224 lines
5.1 KiB
TypeScript
224 lines
5.1 KiB
TypeScript
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 (
|
|
<Modal
|
|
visible={visible}
|
|
animationType="fade"
|
|
transparent={true}
|
|
onRequestClose={onClose}
|
|
>
|
|
<TouchableOpacity
|
|
style={styles.overlay}
|
|
activeOpacity={1}
|
|
onPress={onClose}
|
|
>
|
|
<View style={styles.container}>
|
|
<View style={styles.content}>
|
|
<View style={styles.handleBar} />
|
|
{visibleOptions.map((option, index) => (
|
|
<TouchableOpacity
|
|
key={option.label}
|
|
style={[
|
|
styles.option,
|
|
index === visibleOptions.length - 1 && styles.lastOption,
|
|
]}
|
|
onPress={option.onPress}
|
|
>
|
|
<Text style={styles.optionIcon}>{option.icon}</Text>
|
|
<Text
|
|
style={[
|
|
styles.optionLabel,
|
|
option.destructive && styles.destructiveLabel,
|
|
]}
|
|
>
|
|
{option.label}
|
|
</Text>
|
|
</TouchableOpacity>
|
|
))}
|
|
</View>
|
|
|
|
<TouchableOpacity style={styles.cancelButton} onPress={onClose}>
|
|
<Text style={styles.cancelText}>Cancel</Text>
|
|
</TouchableOpacity>
|
|
</View>
|
|
</TouchableOpacity>
|
|
</Modal>
|
|
);
|
|
}
|
|
|
|
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,
|
|
},
|
|
});
|