import { View, Text, Modal, TouchableOpacity, Image as NativeImage, } from "react-native"; import React, { useState, useEffect } from "react"; import { useTailwind } from "tailwind-rn"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useNavigation } from "@react-navigation/native"; import Toast from "react-native-toast-message"; import baseRequest from "../../utils/baseRequest"; import { generateSignature } from "../../utils/crypto"; export default function CreatePostModal({ visible, setVisible }) { const tailwind = useTailwind(); const insets = useSafeAreaInsets(); const navigation = useNavigation(); //查看主播是否已经创建空间 const [isSpaceExist, setIsSpaceExist] = useState(true); useEffect(() => { const checkSpaceStatus = async () => { if (!visible) return; const apiUrl = process.env.EXPO_PUBLIC_API_URL; try { const base = await baseRequest(); const body = { mid: base.b_mid, ...base, }; const signature = await generateSignature(body); const _response = await fetch( `${apiUrl}/api/zone/list_by_mid?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), } ); const _data = await _response.json(); if (_data.ret === -1) { return; } if (_data.data.list.length === 0) { setIsSpaceExist(false); } } catch (error) { console.error(error); } }; checkSpaceStatus(); }, [visible]); return ( setVisible(false)} > { navigation.navigate("CreateImagePost"); setVisible(false); } : () => Toast.show({ type: "error", text1: "您还未创建空间,当前仅可发布广场动态", topOffset: 60, }) } style={tailwind("flex flex-col items-center")} > 发图片 { navigation.navigate("CreateVideoPost"); setVisible(false); } : () => Toast.show({ type: "error", text1: "您还未创建空间,当前仅可发布广场动态", topOffset: 60, }) } style={tailwind("flex flex-col items-center")} > 发视频 { navigation.navigate("CreatePost"); setVisible(false); }} style={tailwind("flex flex-col items-center")} > 广场动态 setVisible(false)} style={{ height: 52, ...tailwind( "flex justify-center items-center border-t border-[#FFFFFF14]" ), }} > 取消 ); }