diff --git a/src/def.d.ts b/src/def.d.ts index eff8a91..277ffdc 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -101,7 +101,8 @@ interface VendettaObject { } ui: { components: { - Forms: PropIntellisense<"FormSection">; + Forms: PropIntellisense<"Form" | "FormSection">; + General: PropIntellisense<"Button" | "Text" | "View">; } toasts: { showToast: (content: string, asset: number) => void; diff --git a/src/lib/plugins.ts b/src/lib/plugins.ts index ac534f8..6857f74 100644 --- a/src/lib/plugins.ts +++ b/src/lib/plugins.ts @@ -4,6 +4,7 @@ import logger from "./logger"; type EvaledPlugin = { onLoad?(): void; onUnload(): void; + settings: JSX.Element; }; export const plugins: Indexable = {}; @@ -92,5 +93,7 @@ export function stopPlugin(id: string) { plugin.enabled = false; } +export const getSettings = (id: string) => loadedPlugins[id]?.settings; + // TODO: When startAllPlugins exists, return this so cleanup in index.ts is easier const stopAllPlugins = () => Object.keys(loadedPlugins).forEach(stopPlugin); \ No newline at end of file diff --git a/src/ui/components.ts b/src/ui/components.ts index 0acad0a..6e88552 100644 --- a/src/ui/components.ts +++ b/src/ui/components.ts @@ -1,3 +1,4 @@ import { findByProps } from "@metro/filters"; -export const Forms = findByProps("FormSection"); \ No newline at end of file +export const Forms = findByProps("Form", "FormSection"); +export const General = findByProps("Button", "Text", "View"); \ No newline at end of file diff --git a/src/ui/settings/components/PluginCard.tsx b/src/ui/settings/components/PluginCard.tsx index 79f0e8a..505813b 100644 --- a/src/ui/settings/components/PluginCard.tsx +++ b/src/ui/settings/components/PluginCard.tsx @@ -1,10 +1,13 @@ import { ReactNative as RN, stylesheet } from "@metro/common"; -import { Forms } from "@ui/components"; +import { Forms, General } from "@ui/components"; import { Plugin } from "@types"; import { getAssetIDByName } from "@ui/assets"; -import { startPlugin, stopPlugin } from "@lib/plugins"; +import { getSettings, startPlugin, stopPlugin } from "@lib/plugins"; +import { findByProps } from "@metro/filters"; const { FormRow, FormSwitch } = Forms; +const { TouchableOpacity, Image } = General; +const navigation = findByProps("pushLazy"); const styles = stylesheet.createThemedStyleSheet({ card: { @@ -16,6 +19,16 @@ const styles = stylesheet.createThemedStyleSheet({ backgroundColor: stylesheet.ThemeColorMap.BACKGROUND_TERTIARY, borderTopLeftRadius: 5, borderTopRightRadius: 5, + }, + actions: { + justifyContent: "flex-end", + flexDirection: "row", + alignItems: "center", + }, + icon: { + width: 22, + height: 22, + tintColor: stylesheet.ThemeColorMap.INTERACTIVE_NORMAL, } }) @@ -25,6 +38,7 @@ interface PluginCardProps { export default function PluginCard({ plugin }: PluginCardProps) { const [enabled, setEnabled] = React.useState(plugin.enabled); + const Settings = getSettings(plugin.id); return ( @@ -44,6 +58,17 @@ export default function PluginCard({ plugin }: PluginCardProps) { /> + {Settings && { + navigation.push(Settings); + }} + > + + } + + } /> )