import React, { useState, useEffect, useCallback } from "react"; import { Image, TouchableOpacity, View } from "react-native"; import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; import Stream from "../Stream"; import My from "../My"; import Posts from "../Posts"; import Space from "../Space"; import { get } from "../../utils/storeInfo"; import CreatePostModal from "../../components/CreatePostModal"; const Tab = createBottomTabNavigator(); export default function HomeTab({ navigation, route }) { const [isCreatePostTabVisible, setIsCreatePostTabVisible] = useState(false); useEffect(() => { const checkRole = async () => { const account = await get("account"); if (account.role === 3) setIsCreatePostTabVisible(true); }; checkRole(); }, []); const CustomTabBarButton = useCallback(({ children }) => { const [visible, setVisible] = useState(false); return ( setVisible(!visible)} > {children} ); }, []); const EmptyComponent = () => <>; return ( ({ tabBarActiveTintColor: "#FF669E", tabBarInactiveTintColor: "gray", tabBarStyle: { backgroundColor: "#07050A", borderTopColor: "#FFFFFF26", }, })} > { if (focused) { return ( ); } else { return ( ); } }, }} /> { if (focused) { return ( ); } else { return ( ); } }, }} /> {isCreatePostTabVisible && ( ( ), tabBarButton: (props) => , }} /> )} { if (focused) { return ( ); } else { return ( ); } }, }} /> { if (focused) { return ( ); } else { return ( ); } }, }} /> ); }