import { View, Text, TouchableOpacity, Dimensions, Modal, TouchableWithoutFeedback, ActivityIndicator, } from "react-native"; import React, { useState } from "react"; import { useTailwind } from "tailwind-rn"; import { Icon } from "@rneui/themed"; import { Image } from "expo-image"; import ImageViewer from "react-native-image-zoom-viewer"; import VideoModal from "../VideoModal"; import { useNavigation } from "@react-navigation/native"; //todo:给头像加上在线状态 const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk"; const screenWidth = Dimensions.get("window").width; export default function Post({ data }) { const tailwind = useTailwind(); const navigation = useNavigation(); const [like, setLike] = useState(data.like === 1); const [showVideo, setShowVideo] = useState(false); return ( navigation.navigate("StreamerProfile", { mid: data.mid }) } > {data.name} {data.time} setLike(!like)} > {like ? data.like_num + 1 : data.like_num} {data.content} {/* 媒体展示 */} {data.media.type === "image" ? ( ) : ( { setShowVideo(true); }} > )} ); } //媒体为图片时展示内容的组件 function ImageDisplay({ media }) { const tailwind = useTailwind(); const [isModalVisible, setIsModalVisible] = useState(false); const [imageIndex, setImageIndex] = useState(); const images = media.url.map((url) => ({ url })); if (media.url) { return ( {media.url.length > 1 ? ( media.url.map((item, index) => ( { setIsModalVisible(true); setImageIndex(index); }} > )) ) : ( )} setIsModalVisible(false)}> setIsModalVisible(false)} index={imageIndex} loadingRender={() => } /> ); } } //媒体为视频时展示封面的组件 function PosterDisplay({ media }) { const tailwind = useTailwind(); if (media.poster) { return ( ); } }