删除ios保存图片功能;切换账号后若身份有变化重新渲染动态页面
This commit is contained in:
parent
0db205bb1e
commit
dbcd874261
|
@ -4,6 +4,7 @@ import {
|
||||||
Modal,
|
Modal,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
|
Platform,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import React, { useState, useCallback, useEffect } from "react";
|
import React, { useState, useCallback, useEffect } from "react";
|
||||||
import { ImageViewer as OriginImageViewer } from "react-native-image-zoom-viewer";
|
import { ImageViewer as OriginImageViewer } from "react-native-image-zoom-viewer";
|
||||||
|
@ -32,19 +33,12 @@ export default function ImageViewer({
|
||||||
|
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
|
||||||
const [isSaved, setIsSaved] = useState(false);
|
const checkRole = useCallback(async () => {
|
||||||
const [isVip, setIsVip] = useState(false);
|
const account = await get("account");
|
||||||
|
const role = account.role;
|
||||||
useEffect(() => {
|
const isVip = account.is_a_member;
|
||||||
const checkRole = async () => {
|
if (role !== 0 || isVip === 1) return true;
|
||||||
const account = await get("account");
|
return false;
|
||||||
const role = account.role;
|
|
||||||
const isVip = account.is_a_member;
|
|
||||||
if (role !== 0 || isVip === 1) {
|
|
||||||
setIsVip(true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
checkRole();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const MenusComponent = useCallback(
|
const MenusComponent = useCallback(
|
||||||
|
@ -73,23 +67,24 @@ export default function ImageViewer({
|
||||||
>
|
>
|
||||||
<View style={tailwind("flex flex-1 flex-row items-center px-4")}>
|
<View style={tailwind("flex flex-1 flex-row items-center px-4")}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={
|
onPress={async () => {
|
||||||
isVip
|
const isVip = await checkRole();
|
||||||
? saveToLocal
|
if (isVip) {
|
||||||
: () => {
|
saveToLocal();
|
||||||
setIsVisible(false);
|
return;
|
||||||
navigation.navigate("WebWithoutHeader", {
|
}
|
||||||
uri: process.env.EXPO_PUBLIC_WEB_URL + "/vip",
|
setIsVisible(false);
|
||||||
});
|
navigation.navigate("WebWithoutHeader", {
|
||||||
}
|
uri: process.env.EXPO_PUBLIC_WEB_URL + "/vip",
|
||||||
}
|
});
|
||||||
|
}}
|
||||||
style={tailwind("flex flex-col items-center px-4")}
|
style={tailwind("flex flex-col items-center px-4")}
|
||||||
>
|
>
|
||||||
<Icon type="ionicon" name="image" size={30} color="white" />
|
<Icon type="ionicon" name="image" size={30} color="white" />
|
||||||
<Text
|
<Text
|
||||||
style={tailwind("text-sm text-[#FFFFFF80] font-medium mt-1")}
|
style={tailwind("text-sm text-[#FFFFFF80] font-medium mt-1")}
|
||||||
>
|
>
|
||||||
{isSaved ? "已保存" : "保存(会员特权)"}
|
保存(会员特权)
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
@ -113,12 +108,13 @@ export default function ImageViewer({
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</Modal>
|
</Modal>
|
||||||
),
|
),
|
||||||
[isSaved, isVip]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
const [isVipModalVisible, setIsVipModalVisible] = useState(false);
|
const [isVipModalVisible, setIsVipModalVisible] = useState(false);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
const hanldSaveImage = async (index) => {
|
const hanldSaveImage = async (index) => {
|
||||||
|
const isVip = await checkRole();
|
||||||
if (!isVip) {
|
if (!isVip) {
|
||||||
setIsVipModalVisible(true);
|
setIsVipModalVisible(true);
|
||||||
return;
|
return;
|
||||||
|
@ -126,7 +122,6 @@ export default function ImageViewer({
|
||||||
if (isSaving) return;
|
if (isSaving) return;
|
||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
const isSuccess = await saveImage(imageUrls[index].url);
|
const isSuccess = await saveImage(imageUrls[index].url);
|
||||||
setIsSaved(isSuccess);
|
|
||||||
setIsSaving(false);
|
setIsSaving(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,33 +134,36 @@ export default function ImageViewer({
|
||||||
onSwipeDown={() => setIsVisible(false)}
|
onSwipeDown={() => setIsVisible(false)}
|
||||||
enableSwipeDown
|
enableSwipeDown
|
||||||
backgroundColor="#07050A"
|
backgroundColor="#07050A"
|
||||||
renderFooter={(index) => (
|
renderFooter={
|
||||||
<TouchableOpacity
|
Platform.OS === "android"
|
||||||
onPress={() => hanldSaveImage(index)}
|
? (index) => (
|
||||||
style={{
|
<TouchableOpacity
|
||||||
marginLeft: 20,
|
onPress={() => hanldSaveImage(index)}
|
||||||
marginBottom: insets.bottom,
|
style={{
|
||||||
...tailwind(
|
marginLeft: 20,
|
||||||
"flex justify-center items-center w-12 h-12 bg-[#FFFFFF1A] rounded-full"
|
marginBottom: insets.bottom,
|
||||||
),
|
...tailwind(
|
||||||
}}
|
"flex justify-center items-center w-12 h-12 bg-[#FFFFFF1A] rounded-full"
|
||||||
>
|
),
|
||||||
{isSaving && <ActivityIndicator size="small" />}
|
}}
|
||||||
{!isSaving && (
|
>
|
||||||
<Icon
|
{isSaving && <ActivityIndicator size="small" />}
|
||||||
type="ionicon"
|
{!isSaving && (
|
||||||
name="save-outline"
|
<Icon
|
||||||
size={20}
|
type="ionicon"
|
||||||
color="white"
|
name="save-outline"
|
||||||
/>
|
size={20}
|
||||||
)}
|
color="white"
|
||||||
</TouchableOpacity>
|
/>
|
||||||
)}
|
)}
|
||||||
|
</TouchableOpacity>
|
||||||
|
)
|
||||||
|
: () => <></>
|
||||||
|
}
|
||||||
onSave={async (url) => {
|
onSave={async (url) => {
|
||||||
const isSuccess = await saveImage(url);
|
const isSuccess = await saveImage(url);
|
||||||
setIsSaved(isSuccess);
|
|
||||||
}}
|
}}
|
||||||
saveToLocalByLongPress={true}
|
saveToLocalByLongPress={Platform.OS === "android"}
|
||||||
menus={MenusComponent}
|
menus={MenusComponent}
|
||||||
loadingRender={() => <ActivityIndicator size="large" />}
|
loadingRender={() => <ActivityIndicator size="large" />}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -193,7 +193,7 @@ export default function FeedPosts({ blur }) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getVipPrice();
|
getVipPrice();
|
||||||
getData(2);
|
getData(2);
|
||||||
}, []);
|
}, [blur]);
|
||||||
|
|
||||||
const tailwind = useTailwind();
|
const tailwind = useTailwind();
|
||||||
const renderItem = ({ item }) => <Post isBlur={blur} data={item} />;
|
const renderItem = ({ item }) => <Post isBlur={blur} data={item} />;
|
||||||
|
|
|
@ -174,7 +174,7 @@ export default function FollowPosts({ blur }) {
|
||||||
//当关注的主播mids改变,获取新数据
|
//当关注的主播mids改变,获取新数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getData("top");
|
getData("top");
|
||||||
}, [followMids, currentTime]);
|
}, [followMids, currentTime, blur]);
|
||||||
|
|
||||||
const tailwind = useTailwind();
|
const tailwind = useTailwind();
|
||||||
const renderItem = ({ item }) => <Post isBlur={blur} data={item} />;
|
const renderItem = ({ item }) => <Post isBlur={blur} data={item} />;
|
||||||
|
|
|
@ -80,8 +80,15 @@ export default function Posts({ navigation }) {
|
||||||
const isVip = accountData.data.account.is_a_member;
|
const isVip = accountData.data.account.is_a_member;
|
||||||
if (role !== 0 || isVip === 1) {
|
if (role !== 0 || isVip === 1) {
|
||||||
setBlur(false);
|
setBlur(false);
|
||||||
|
} else {
|
||||||
|
setBlur(true);
|
||||||
}
|
}
|
||||||
await save("account", accountData.data.account);
|
await save("account", accountData.data.account);
|
||||||
|
if (role === 3) {
|
||||||
|
setIsStreamer(true);
|
||||||
|
} else {
|
||||||
|
setIsStreamer(false);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue