80 lines
2.5 KiB
React
80 lines
2.5 KiB
React
|
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 AlreadyAddWechat from "./AlreadyAddWechat";
|
||
|
import HaveNotAddWechat from "./HaveNotAddWechat";
|
||
|
|
||
|
export default function WechatWaitingToAdd({ navigation, route }) {
|
||
|
const tailwind = useTailwind();
|
||
|
const insets = useSafeAreaInsets();
|
||
|
const [index, setIndex] = useState(route.params?.tab);
|
||
|
//修复ios使用了tab组件闪退问题
|
||
|
const [indicatorX, setIndicatorX] = useState(0);
|
||
|
const windowWidth = Dimensions.get("window").width;
|
||
|
const tabWidth = windowWidth / 2;
|
||
|
return (
|
||
|
<View
|
||
|
style={{
|
||
|
paddingLeft: insets.left,
|
||
|
paddingRight: insets.right,
|
||
|
...tailwind("flex flex-1"),
|
||
|
}}
|
||
|
>
|
||
|
<View style={tailwind("flex pb-1 flex-row justify-between items-center")}>
|
||
|
<View style={tailwind("flex w-full")}>
|
||
|
<Tab
|
||
|
value={index}
|
||
|
onChange={(e) => {
|
||
|
setIndex(e);
|
||
|
setIndicatorX(e * tabWidth);
|
||
|
}}
|
||
|
dense
|
||
|
indicatorStyle={{
|
||
|
...tailwind("bg-[#FF7DCB] rounded-full"),
|
||
|
transform: [{ translateX: indicatorX }],
|
||
|
}}
|
||
|
>
|
||
|
<Tab.Item
|
||
|
titleStyle={
|
||
|
index === 0
|
||
|
? tailwind("text-white font-medium text-base")
|
||
|
: tailwind("text-[#FFFFFF80] text-base font-medium")
|
||
|
}
|
||
|
>
|
||
|
待添加
|
||
|
</Tab.Item>
|
||
|
<Tab.Item
|
||
|
titleStyle={
|
||
|
index === 1
|
||
|
? tailwind("text-white font-medium text-base")
|
||
|
: tailwind("text-[#FFFFFF80] text-base font-medium")
|
||
|
}
|
||
|
>
|
||
|
已完成
|
||
|
</Tab.Item>
|
||
|
</Tab>
|
||
|
</View>
|
||
|
</View>
|
||
|
<View style={tailwind("flex flex-1 w-full")}>
|
||
|
<TabView
|
||
|
value={index}
|
||
|
onChange={(e) => {
|
||
|
setIndex(e);
|
||
|
setIndicatorX(e * tabWidth);
|
||
|
}}
|
||
|
animationType="spring"
|
||
|
>
|
||
|
<TabView.Item style={tailwind("w-full flex-1")}>
|
||
|
<HaveNotAddWechat />
|
||
|
</TabView.Item>
|
||
|
<TabView.Item style={tailwind("w-full flex-1")}>
|
||
|
<AlreadyAddWechat />
|
||
|
</TabView.Item>
|
||
|
</TabView>
|
||
|
</View>
|
||
|
</View>
|
||
|
);
|
||
|
}
|