/** * PostRefCard — renders a shared feed post inside a chat bubble. * * Visually distinct from plain messages so the user sees at-a-glance * that this came from the feed, not a direct-typed text. Matches * VK's "shared wall post" embed pattern: * * [newspaper icon] ПОСТ * @author · 2 строки excerpt'а * [📷 Фото in this post] * * Tap → /(app)/feed/{postID}. The full post (with image + stats + * like button) is displayed in the standard post-detail screen. */ import React from 'react'; import { View, Text, Pressable } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { router } from 'expo-router'; import { useStore } from '@/lib/store'; import { Avatar } from '@/components/Avatar'; export interface PostRefCardProps { postID: string; author: string; excerpt: string; hasImage?: boolean; /** True when the card appears inside the sender's own bubble (our own * share). Adjusts colour contrast so it reads on the blue bubble * background. */ own: boolean; } function shortAddr(a: string, n = 6): string { if (!a) return '—'; return a.length <= n * 2 + 1 ? a : `${a.slice(0, n)}…${a.slice(-n)}`; } export function PostRefCard({ postID, author, excerpt, hasImage, own }: PostRefCardProps) { const contacts = useStore(s => s.contacts); // Resolve author name the same way the feed does. const contact = contacts.find(c => c.address === author); const displayName = contact?.username ? `@${contact.username}` : contact?.alias ?? shortAddr(author); const onOpen = () => { router.push(`/(app)/feed/${postID}` as never); }; // Tinted palette based on bubble side — inside an "own" (blue) bubble // the card uses a deeper blue so it reads as a distinct nested block, // otherwise we use the standard card colours. const bg = own ? 'rgba(0, 0, 0, 0.22)' : '#0a0a0a'; const border = own ? 'rgba(255, 255, 255, 0.15)' : '#1f1f1f'; const labelColor = own ? 'rgba(255, 255, 255, 0.75)' : '#1d9bf0'; const bodyColor = own ? '#ffffff' : '#ffffff'; const subColor = own ? 'rgba(255, 255, 255, 0.65)' : '#8b8b8b'; return ( ({ marginBottom: 6, borderRadius: 14, backgroundColor: pressed ? 'rgba(0,0,0,0.35)' : bg, borderWidth: 1, borderColor: border, overflow: 'hidden', })} > {/* Top ribbon: "ПОСТ" label — makes the shared nature unmistakable. */} POST {/* Author + excerpt */} {displayName} {excerpt.length > 0 && ( {excerpt} )} {hasImage && ( photo )} ); }