修改没开会员时对动态的模糊程度;修复动态的media_component为null时报错的问题

This commit is contained in:
yezian 2024-01-26 14:32:50 +08:00
parent 38b44979c1
commit b86bf9fe9e
1 changed files with 13 additions and 64 deletions

View File

@ -6,6 +6,7 @@ import {
TouchableWithoutFeedback,
ActivityIndicator,
Image as NativeImage,
Platform,
} from "react-native";
import React, { useState } from "react";
import { useTailwind } from "tailwind-rn";
@ -14,7 +15,7 @@ import ImageViewer from "react-native-image-zoom-viewer";
import VideoModal from "../VideoModal";
import { useNavigation } from "@react-navigation/native";
import formatTimestamp from "../../utils/formatTimestamp";
import { follow, unfollow, block } from "../../utils/relation";
import { follow, unfollow } from "../../utils/relation";
import baseRequest from "../../utils/baseRequest";
import { generateSignature } from "../../utils/crypto";
import Toast from "react-native-toast-message";
@ -87,63 +88,6 @@ export default function Post({ blur, data }) {
follow(account.mid, data.mid);
};
//
// const [operationOpen, setOperationOpen] = useState(false);
// const Operation = () => {
// const handleFeedback = () => {
// navigation.navigate("MessageDetail", { mid: 1 });
// setOperationOpen(false);
// };
// const handleBlock = async () => {
// const account = await get("account");
// const subMid = account.mid;
// const objMid = data.mid;
// await block(subMid, objMid);
// setOperationOpen(false);
// };
// return (
// <View style={tailwind("absolute right-4 top-2")}>
// <Icon
// type="ionicon"
// name="ellipsis-vertical"
// size={32}
// color="white"
// onPress={() => setOperationOpen(true)}
// />
// {operationOpen && (
// <TouchableWithoutFeedback onPress={() => setOperationOpen(false)}>
// <View
// style={{
// ...tailwind("items-center bg-white rounded-lg p-2"),
// }}
// >
// <TouchableOpacity
// onPress={handleBlock}
// style={tailwind("flex-row items-center px-4")}
// >
// <Icon
// type="ionicon"
// name="remove-circle"
// color="#f87171"
// size={24}
// />
// <Text style={tailwind("text-base")}></Text>
// </TouchableOpacity>
// <Divider style={tailwind("w-full my-2")} />
// <TouchableOpacity
// onPress={handleFeedback}
// style={tailwind("flex-row items-center px-4")}
// >
// <Icon type="ionicon" name="warning" color="#60a5fa" size={24} />
// <Text style={tailwind("text-base")}></Text>
// </TouchableOpacity>
// </View>
// </TouchableWithoutFeedback>
// )}
// </View>
// );
// };
return (
<View style={tailwind("flex flex-col")}>
<View style={tailwind("flex pt-3.5 pb-1.5 pl-3.5")}>
@ -192,8 +136,12 @@ export default function Post({ blur, data }) {
</Text>
{/* 媒体展示 */}
<View style={tailwind("pr-10 mb-1")}>
{data.media_component.video_ids.length === 0 ? (
<ImageDisplay blur={blur} media={data.media_component.images} />
{data.media_component.video_ids?.length === 0 ||
data.media_component.video_ids === null ? (
<ImageDisplay
blur={blur}
media={data.media_component?.images}
/>
) : (
<TouchableOpacity
activeOpacity={1}
@ -246,7 +194,7 @@ export default function Post({ blur, data }) {
<Text
style={tailwind("mx-1 text-sm font-medium text-[#FF669E]")}
>
开通会员永久看动态
会员永久所有动态
</Text>
<NativeImage
source={require("../../assets/icon/others/pinklink.png")}
@ -296,6 +244,7 @@ function ImageDisplay({ blur, media }) {
const [isModalVisible, setIsModalVisible] = useState(false);
const [imageIndex, setImageIndex] = useState();
const images = media.map((item) => ({ url: item.urls[0] }));
if (images.length === 0) return null;
return (
<View style={tailwind("flex flex-row flex-wrap")}>
{media.length > 1 ? (
@ -318,7 +267,7 @@ function ImageDisplay({ blur, media }) {
>
<Image
style={tailwind("w-full h-full rounded")}
blurRadius={blur ? 75 : 0}
blurRadius={blur ? (Platform.OS === "ios" ? 130 : 7) : 0}
source={item.urls[0]}
placeholder={blurhash}
contentFit="cover"
@ -350,7 +299,7 @@ function ImageDisplay({ blur, media }) {
>
<Image
style={tailwind("w-full h-full rounded")}
blurRadius={blur ? 75 : 0}
blurRadius={blur ? (Platform.OS === "ios" ? 130 : 7) : 0}
source={media[0].urls[0]}
placeholder={blurhash}
contentFit="contain"
@ -393,7 +342,7 @@ function PosterDisplay({ blur, media }) {
>
<Image
style={tailwind("w-full h-full rounded")}
blurRadius={blur ? 75 : 0}
blurRadius={blur ? (Platform.OS === "ios" ? 130 : 7) : 0}
source={media.cover_urls[0]}
placeholder={blurhash}
contentFit="cover"