import type { PostReaction } from '@nalssigak/shared/api/client/types.gen'; import type { PinnedKey } from '@nalssigak/shared/lib/analytics'; import { LinearGradient } from 'expo-linear-gradient'; import { useRef, type ReactNode } from 'react'; import { Pressable, View } from 'react-native'; import { useCSSVariable } from 'uniwind'; import { CommentIcon, HeartIcon, SendIcon } from '@/components/post/icons'; import { Text } from '@/components/text'; import { Ic } from '@/components/ui'; import { usePinnedLike } from '@/lib/pinned-like'; import { useSheet } from '@/lib/sheet'; import { useShare } from '@/lib/share-image'; import { SITE_URL } from '@/lib/site'; type Props = { title: string; account: string; avatar: string; caption?: string; more?: ReactNode; pinned?: { key: PinnedKey; post?: PostReaction | null }; children: ReactNode }; /** 오늘의 각처럼 포스트 틀(머리줄·버튼줄·글 한 줄)만 빌려 쓰는 카드 (웹 PostFrame). 좋아요·댓글은 피드의 반응 칸(pinned)에 붙는다 */ export function PostFrame({ title, account, avatar, caption, more, pinned, children }: Props) { const { open } = useSheet(); const [ink, heart] = useCSSVariable(['--color-ink', '--color-heart']).map(String); const like = usePinnedLike(pinned?.key ?? 'gak_post', pinned?.post); const postId = pinned?.post?.post_id; const shot = useRef(null); const shareView = useShare(); const share = () => void shareView(shot, { title, message: `${title} · 날씨각 ${SITE_URL}` }); return ( 날씨각 {account} {children} {postId != null && ( <> open({ type: 'comments', postId })} hitSlop={8} accessibilityRole="button" accessibilityLabel="댓글 보기"> )} {more != null && {more}} {postId != null && ( {like.failed ? '좋아요를 반영하지 못했어요. 다시 해 주세요.' : `좋아요 ${like.count.toLocaleString()}개`} )} {!!caption && ( 날씨각 {caption} )} {postId != null && ( open({ type: 'comments', postId })}> {pinned?.post?.comment_count ? `댓글 ${pinned.post.comment_count}개 모두 보기` : '첫 댓글 남기기'} )} ); }