import { View, Dimensions } from "react-native"; import React, { useState } from "react"; import { useTailwind } from "tailwind-rn"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Tab, TabView } from "@rneui/themed"; import Follows from "./Follows"; import Fans from "./Fans"; export default function Relationship({ navigation, route }) { const tailwind = useTailwind(); const insets = useSafeAreaInsets(); const [index, setIndex] = useState(route.params.tab); //修复ios使用了tab组件闪退问题 const windowWidth = Dimensions.get("window").width; const tabWidth = windowWidth / 2; const [indicatorX, setIndicatorX] = useState(route.params.tab * tabWidth); return ( { setIndex(e); setIndicatorX(e * tabWidth); }} dense indicatorStyle={{ ...tailwind("bg-[#FF7DCB] rounded-full"), transform: [{ translateX: indicatorX }], }} > 关注 粉丝 { setIndex(e); setIndicatorX(e * tabWidth); }} animationType="spring" > ); }