feat(ui): simplify unproxied notice

This commit is contained in:
pylixonly 2024-10-11 00:28:36 +08:00
parent e3df56dc58
commit 1d4dfd311f

View file

@ -11,9 +11,9 @@ import { lazyDestructure } from "@lib/utils/lazy";
import { Author } from "@lib/utils/types"; import { Author } from "@lib/utils/types";
import { findByProps } from "@metro"; import { findByProps } from "@metro";
import { NavigationNative } from "@metro/common"; import { NavigationNative } from "@metro/common";
import { Button, Card, FlashList, Text } from "@metro/common/components"; import { Button, Card, FlashList, IconButton, Stack, Text } from "@metro/common/components";
import { ComponentProps } from "react"; import { ComponentProps } from "react";
import { View } from "react-native"; import { Image, View } from "react-native";
import unifyVdPlugin from "./models/vendetta"; import unifyVdPlugin from "./models/vendetta";
@ -35,13 +35,6 @@ export interface UnifiedPluginModel {
const { openAlert } = lazyDestructure(() => findByProps("openAlert", "dismissAlert")); const { openAlert } = lazyDestructure(() => findByProps("openAlert", "dismissAlert"));
const { AlertModal, AlertActions, AlertActionButton } = lazyDestructure(() => findByProps("AlertModal", "AlertActions")); const { AlertModal, AlertActions, AlertActionButton } = lazyDestructure(() => findByProps("AlertModal", "AlertActions"));
function navigateToPluginBrowser(navigation: any) {
navigation.push("BUNNY_CUSTOM_PAGE", {
title: "Plugin Browser",
render: React.lazy(() => import("../PluginBrowser")),
});
}
interface PluginPageProps extends Partial<ComponentProps<typeof AddonPage<UnifiedPluginModel>>> { interface PluginPageProps extends Partial<ComponentProps<typeof AddonPage<UnifiedPluginModel>>> {
useItems: () => unknown[]; useItems: () => unknown[];
} }
@ -80,32 +73,37 @@ export default function Plugins() {
const unproxiedPlugins = Object.values(VdPluginManager.plugins).filter(p => !p.id.startsWith(VD_PROXY_PREFIX) && !p.id.startsWith(BUNNY_PROXY_PREFIX)); const unproxiedPlugins = Object.values(VdPluginManager.plugins).filter(p => !p.id.startsWith(VD_PROXY_PREFIX) && !p.id.startsWith(BUNNY_PROXY_PREFIX));
if (!unproxiedPlugins.length) return null; if (!unproxiedPlugins.length) return null;
// TODO: Make this dismissable return <Card style={{ marginVertical: 12, marginHorizontal: 10 }} border="strong">
return <Card style={{ marginVertical: 8, gap: 4 }}> <View style={{ flex: 1, justifyContent: "center", alignItems: "center", flexDirection: "row" }}>
<Text variant="heading-lg/bold">Unproxied Plugins Detected</Text> <View style={{ gap: 6, flexShrink: 1 }}>
<Text variant="text-md/medium">Installed plugins from unproxied sources may execute unreviewed code in this app without your knowledge.</Text> <Text variant="heading-md/bold">Unproxied Plugins Found</Text>
<View style={{ marginTop: 8, flexDirection: "row" }}> <Text variant="text-sm/medium" color="text-muted">
<Button Plugins installed from unproxied sources may run unverified code in this app without your awareness.
style={{ flexShrink: 1 }} </Text>
size="sm" </View>
text="Review" <View style={{ marginLeft: "auto" }}>
variant="secondary" <IconButton
onPress={() => { size="sm"
navigation.push("BUNNY_CUSTOM_PAGE", { variant="secondary"
title: "Unproxied Plugins", icon={findAssetId("CircleInformationIcon-primary")}
render: () => { style={{ marginLeft: 8 }}
return <FlashList onPress={() => {
data={unproxiedPlugins} navigation.push("BUNNY_CUSTOM_PAGE", {
contentContainerStyle={{ padding: 8 }} title: "Unproxied Plugins",
ItemSeparatorComponent={() => <View style={{ height: 8 }} />} render: () => {
renderItem={({ item: p }: any) => <Card> return <FlashList
<Text variant="heading-md/semibold">{p.id}</Text> data={unproxiedPlugins}
</Card>} contentContainerStyle={{ padding: 8 }}
/>; ItemSeparatorComponent={() => <View style={{ height: 8 }} />}
} renderItem={({ item: p }: any) => <Card>
}); <Text variant="heading-md/semibold">{p.id}</Text>
}} </Card>}
/> />;
}
});
}}
/>
</View>
</View> </View>
</Card>; </Card>;
}} }}