import React from 'react'; import { useXGestures } from '../hooks/useXGestures'; import { useXStrings } from '../hooks/useXStrings'; import { XImage, XVideo } from './XMedia'; import { XPostActionBar, type XPostActionIds } from './XPostActionBar'; import type { XPost } from '../types'; type TimelineAuthor = { id?: string; name?: string; avatar?: string; verified?: boolean; }; type TimelineQuotedPost = Partial & { id: string; content?: string; time?: string; author?: TimelineAuthor; }; export type XTimelinePost = XPost & { author?: TimelineAuthor; quotedPost?: TimelineQuotedPost; replyToUserId?: string; }; interface XTimelinePostCardProps { post: XTimelinePost; actionIds: XPostActionIds; isActive?: boolean; headerRight?: React.ReactNode; topContent?: React.ReactNode; onRetweetTrigger?: (postId: string) => void; onBookmarkAdded?: (postId: string) => void; showCounts?: boolean; } export const XTimelinePostCard: React.FC = ({ post, actionIds, isActive = true, headerRight, topContent, onRetweetTrigger, onBookmarkAdded, showCounts, }) => { const { bindTap } = useXGestures(isActive); const s = useXStrings(); const authorName = post.author?.name ?? 'Unknown'; const authorHandle = post.author?.id ? `@${post.author.id}` : '@unknown'; return (
{topContent}
{post.author?.avatar ? ( ) : (
{authorName[0] ?? '?'}
)}
{authorName} {post.author?.verified ? ✓ : null} {authorHandle} · {post.time}
{headerRight}
{post.replyToUserId ? (
{s.reply_to_prefix} {`@${post.replyToUserId}`}
) : null}
{post.content}
{post.image && !post.video ? (
) : null} {post.video ? (
) : null} {post.quotedPost ? (
{post.quotedPost.author?.avatar ? ( ) : null}
{post.quotedPost.author?.name ?? 'Unknown'} {post.quotedPost.author?.verified && ✓}
{post.quotedPost.author?.id ? `@${post.quotedPost.author.id}` : '@unknown'}
{post.quotedPost.content}
) : null}
); };