import {
View,
Text,
FlatList,
RefreshControl,
Image as NativeImage,
} from "react-native";
import React, { useState, useEffect } from "react";
import { useTailwind } from "tailwind-rn";
import Toast from "react-native-toast-message";
import Empty from "../../../../components/Empty";
import { ListItem, Icon } from "@rneui/themed";
import { Image } from "expo-image";
import baseRequest from "../../../../utils/baseRequest";
import { generateSignature } from "../../../../utils/crypto";
import formatTimestamp from "../../../../utils/formatTimestamp";
export default function IronfanSpaceMember({ zid }) {
const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk";
const tailwind = useTailwind();
const [data, setData] = useState([]);
const getData = async () => {
if (zid === undefined) return;
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
try {
const base = await baseRequest();
const body = {
zid: zid,
member_type: 2,
...base,
};
const signature = await generateSignature(body);
const _response = await fetch(
`${apiUrl}/api/zone/member_list?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;
}
setData(_data.data.list);
} catch (error) {
console.error(error);
}
};
useEffect(() => {
getData();
}, []);
//下拉刷新
const [refreshing, setRefreshing] = useState(false);
//下拉刷新
const handleRefresh = async () => {
setRefreshing(true);
await getData();
setRefreshing(false);
};
//单个成员组件
const renderItem = ({ item }) => {
return (
{item?.account?.name}
{item?.account?.user_id}
{formatTimestamp(item?.join_ct)}
);
};
return (
handleRefresh()}
/>
}
ListEmptyComponent={}
/>
);
}