import { View, Text, ScrollView, ActivityIndicator, TextInput, TouchableOpacity, } from "react-native"; import React, { useState } from "react"; import { useTailwind } from "tailwind-rn"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import Toast from "react-native-toast-message"; import baseRequest from "../../../utils/baseRequest"; import { generateSignature } from "../../../utils/crypto"; import { Button, Divider, CheckBox, Switch, Icon } from "@rneui/themed"; import MyDivider from "../../../components/MyDivider"; export default function SpaceIntroSetting({ navigation, route }) { const tailwind = useTailwind(); const insets = useSafeAreaInsets(); const data = route.params.data; const [isSubmitting, setIsSubmitting] = useState(false); //空间介绍 const [spaceIntro, setSpaceIntro] = useState(data.profile); const handleSubmit = async () => { if (!spaceIntro) { Toast.show({ type: "error", text1: "请完善内容后提交", topOffset: 60, }); return; } if (isSubmitting) return; setIsSubmitting(true); const apiUrl = process.env.EXPO_PUBLIC_API_URL; try { const base = await baseRequest(); const body = { id: data.id, profile: spaceIntro, ...base, }; const signature = await generateSignature(body); const _response = await fetch( `${apiUrl}/api/zone/update?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(body), } ); const _data = await _response.json(); if (_data.ret === -1) { Toast.show({ type: "error", text1: _data.msg, topOffset: 60, }); return; } Toast.show({ type: "success", text1: "修改成功,请重进空间刷新查看", topOffset: 60, }); navigation.goBack(); } catch (error) { console.error(error); } finally { setIsSubmitting(false); } }; return ( *空间介绍 setSpaceIntro(value)} placeholder="介绍下你的空间吧~" placeholderTextColor="#FFFFFF80" underlineColorAndroid="transparent" multiline textAlignVertical="top" style={tailwind( "h-32 bg-[#FFFFFF1A] text-white rounded-2xl mt-2 p-2" )} /> navigation.navigate("EditStreamerMedia")} style={tailwind("flex-row justify-between pt-4 pb-2")} > * 封面、相册、视频设置 ); }