import { useMemo } from "react"; import { View, Text, Pressable, StyleSheet, useWindowDimensions } from "react-native"; import { useRouter } from "expo-router"; import { useTranslation } from "react-i18next"; import { Image } from "expo-image"; import { PawPrint, Video, Trophy } from "lucide-react-native"; import { PetAvatar } from "./PetAvatar"; import { getMediaUrl } from "../lib/media-url"; import { useTheme } from "../context/ThemeContext"; import { getTypography, radii, type ColorTokens, type Typography } from "../theme/tokens"; import type { PostCardPost } from "./PostCard"; type Props = { post: PostCardPost; }; /** * Port of web's src/components/feed/RepostCard.tsx — the "Paw-Back" (repost) * attribution wrapper around a read-only rendering of the original post. No * action row (matches web: reposts aren't reactable/commentable as a * separate entity, only the original post is). Unlike web's bordered-card * look, this stays visually flush with mobile's other feed items (hairline * separators between list rows already provide the boundary — see * DESIGN.md's "hairline rings not shadows"). */ export function RepostCard({ post }: Props) { const { t } = useTranslation(); const router = useRouter(); const { width } = useWindowDimensions(); const { colors } = useTheme(); const styles = useMemo(() => makeStyles(colors), [colors]); const cardWidth = width - 32; const originalPost = post.repost?.originalPost; if (!originalPost) return null; const origPet = originalPost.pet; const origImage = originalPost.images[0]; return ( router.push(`/pets/${post.pet.id}`)}> {t("social.repostAttribution", { name: post.pet.name })} router.push(`/pets/${origPet.id}`)}> {origPet.name} {originalPost.milestone ? ( ) : originalPost.type === "VIDEO" ? ( ) : origImage ? ( ) : null} {originalPost.caption ? ( {originalPost.caption} ) : null} ); } function makeStyles(colors: ColorTokens) { const typography: Typography = getTypography(colors); return StyleSheet.create({ card: { gap: 8 }, attribution: { flexDirection: "row", alignItems: "center", gap: 6 }, attributionText: { ...typography.label, textTransform: "none", letterSpacing: 0, color: colors.quietGray }, header: { flexDirection: "row", alignItems: "center", gap: 8 }, name: { ...typography.body, fontFamily: typography.title.fontFamily }, caption: { ...typography.body }, placeholder: { aspectRatio: 1.2, borderRadius: radii.md, backgroundColor: colors.ink, alignItems: "center", justifyContent: "center", }, }); }