import { View, Text, ScrollView, TouchableOpacity, Image as NativeImage, } from "react-native"; import React, { useCallback, useState } from "react"; import { useTailwind } from "tailwind-rn"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import MyDivider from "../../../components/MyDivider"; import { Icon } from "@rneui/themed"; import { Image } from "expo-image"; import MyModal from "../../../components/MyModal"; import baseRequest from "../../../utils/baseRequest"; import { generateSignature } from "../../../utils/crypto"; import Toast from "react-native-toast-message"; //todo:修改MyModal组件,让确认按钮摆在左边 export default function SelectSpaceSettingItem({ navigation, route, data }) { const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk"; const tailwind = useTailwind(); const insets = useSafeAreaInsets(); //可进详情的选项组件 const SettingItem = useCallback(({ title, to }) => { return ( <> navigation.navigate(to, { data: data })} style={tailwind("flex-row justify-between pt-4 pb-2")} > {title} ); }, []); //格式化时间 const formatDate = useCallback((timestamp) => { const date = new Date(timestamp * 1000); const year = date.getFullYear(); const month = date.getMonth() + 1; // 月份从0开始,所以需要加1 const day = date.getDate(); return `${year}/${month}/${day}`; }, []); //退出空间 const [isExitSpaceModalVisible, setIsExitSpaceModalVisible] = useState(false); const handleExitSpace = async () => { const apiUrl = process.env.EXPO_PUBLIC_API_URL; try { const base = await baseRequest(); const body = { zid: data?.id, ...base, }; const signature = await generateSignature(body); const _response = await fetch( `${apiUrl}/api/zone/exit?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), } ); const _data = await _response.json(); console.log(_data); if (_data.ret === -1) { Toast.show({ type: "error", text1: _data.msg, topOffset: 60, }); return; } Toast.show({ type: "success", text1: "退出空间成功", topOffset: 60, }); setTimeout(() => navigation.replace("HomeTab"), 500); } catch (error) { console.error(error); } }; return ( navigation.navigate("SpaceIntroSetting", { data: data }) : null } style={tailwind("flex flex-row items-center mb-2")} > {data?.streamer_ext?.name} {data?.streamer_ext?.user_id} {formatDate(data?.ct)} {data?.visitor_role === 3 && ( )} {data?.visitor_role === 3 && ( )} {data?.visitor_role === 3 && ( )} {(data?.visitor_role === 1 || data?.visitor_role === 2) && ( )} {data?.visitor_role === 3 && ( )} {data?.refund_enable === 1 && data?.admission_price > 0 && ( )} {data?.visitor_role === 0 && ( <> setIsExitSpaceModalVisible(true)} style={tailwind("flex-row justify-between pt-4 pb-2")} > 退出空间 )} { setIsExitSpaceModalVisible(false); }} confirm={() => { setIsExitSpaceModalVisible(false); handleExitSpace(); }} /> ); }