diff --git a/src/def.d.ts b/src/def.d.ts index d9e634a..6ff91b3 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -59,6 +59,11 @@ interface Plugin { js: string; } +interface Settings { + debuggerUrl: string; + developerSettings: boolean; +} + type Indexable = { [index: string]: Type } interface VendettaObject { diff --git a/src/lib/settings.ts b/src/lib/settings.ts new file mode 100644 index 0000000..c0b12d5 --- /dev/null +++ b/src/lib/settings.ts @@ -0,0 +1,5 @@ +import createStorage from "@lib/storage"; +import { Settings } from "@types"; + +// TODO: Switch to using 'any' as type? +export default createStorage("VENDETTA_SETTINGS"); \ No newline at end of file diff --git a/src/ui/settings/components/SettingsSection.tsx b/src/ui/settings/components/SettingsSection.tsx index 92a0a23..5494310 100644 --- a/src/ui/settings/components/SettingsSection.tsx +++ b/src/ui/settings/components/SettingsSection.tsx @@ -1,5 +1,6 @@ import { Forms } from "@ui/components"; import { getAssetIDByName } from "@ui/assets"; +import settings from "@/lib/settings"; const { FormRow, FormSection, FormDivider } = Forms; @@ -23,13 +24,17 @@ export default function SettingsSection({ navigation }: SettingsSectionProps) { trailing={FormRow.Arrow} onPress={() => navigation.push("VendettaPlugins")} /> - - } - trailing={FormRow.Arrow} - onPress={() => navigation.push("VendettaAssetBrowser")} - /> + {settings.developerSettings && ( + <> + + } + trailing={FormRow.Arrow} + onPress={() => navigation.push("VendettaDeveloper")} + /> + + )} ) } \ No newline at end of file diff --git a/src/ui/settings/index.tsx b/src/ui/settings/index.tsx index 640afdd..fe12602 100644 --- a/src/ui/settings/index.tsx +++ b/src/ui/settings/index.tsx @@ -5,7 +5,7 @@ import findInReactTree from "@utils/findInReactTree"; import SettingsSection from "@ui/settings/components/SettingsSection"; import General from "@ui/settings/pages/General"; import Plugins from "@ui/settings/pages/Plugins"; -import AssetBrowser from "@ui/settings/pages/AssetBrowser"; +import Developer from "@ui/settings/pages/Developer"; const screensModule = findByDisplayName("getScreens", false); const settingsModule = findByDisplayName("UserSettingsOverviewWrapper", false); @@ -23,10 +23,10 @@ export default function initSettings() { title: "Plugins", render: Plugins }, - VendettaAssetBrowser: { - title: "Asset Browser", - render: AssetBrowser, - }, + VendettaDeveloper: { + title: "Developer", + render: Developer + } } }); diff --git a/src/ui/settings/pages/AssetBrowser.tsx b/src/ui/settings/pages/AssetBrowser.tsx deleted file mode 100644 index 61348fd..0000000 --- a/src/ui/settings/pages/AssetBrowser.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { ReactNative as RN } from "@metro/common"; -import { Forms } from "@ui/components"; -import { all } from "@ui/assets"; -import AssetDisplay from "@ui/settings/components/AssetDisplay"; - -const { FormInput, FormDivider } = Forms; - -export default function AssetBrowser() { - const [searchName, setSearchName] = React.useState(""); - - return ( - <> - setSearchName(v)} - title="SEARCH" - /> - a.name.includes(searchName))} - renderItem={({ item }) => ( - <> - - - - )} - keyExtractor={item => item.name} - /> - - ) -} \ No newline at end of file diff --git a/src/ui/settings/pages/Developer.tsx b/src/ui/settings/pages/Developer.tsx new file mode 100644 index 0000000..a05bd99 --- /dev/null +++ b/src/ui/settings/pages/Developer.tsx @@ -0,0 +1,53 @@ +import { ReactNative as RN } from "@metro/common"; +import { Forms } from "@ui/components"; +import { getAssetIDByName } from "@ui/assets"; +import { connectToDebugger } from "@lib/debug"; +import { all } from "@ui/assets"; +import settings from "@lib/settings"; +import AssetDisplay from "@ui/settings/components/AssetDisplay"; + +const { FormSection, FormRow, FormInput, FormDivider } = Forms; + +export default function Developer() { + const [debuggerUrl, setDebuggerUrl] = React.useState(settings.debuggerUrl || ""); + const [searchName, setSearchName] = React.useState(""); + + return ( + <> + + { + settings.debuggerUrl = v; + setDebuggerUrl(v); + }} + title="DEBUGGER URL" + /> + + } + trailing={FormRow.Arrow} + onPress={() => connectToDebugger(debuggerUrl)} + /> + + + setSearchName(v)} + title="SEARCH" + /> + a.name.includes(searchName))} + renderItem={({ item }) => ( + <> + + + + )} + keyExtractor={item => item.name} + /> + + + ) +} \ No newline at end of file diff --git a/src/ui/settings/pages/General.tsx b/src/ui/settings/pages/General.tsx index 847132c..96fb455 100644 --- a/src/ui/settings/pages/General.tsx +++ b/src/ui/settings/pages/General.tsx @@ -1,17 +1,17 @@ import { ReactNative as RN, url } from "@metro/common"; import { DISCORD_SERVER, GITHUB } from "@lib/constants"; -import { connectToDebugger } from "@lib/debug"; import { getAssetIDByName } from "@ui/assets"; import { Forms } from "@ui/components"; import Version from "@ui/settings/components/Version"; +import settings from "@lib/settings"; -const { FormRow, FormSection, FormInput, FormDivider } = Forms; +const { FormRow, FormSection, FormDivider, FormSwitch } = Forms; const InfoDictionaryManager = RN.NativeModules.InfoDictionaryManager; const hermesProps = window.HermesInternal.getRuntimeProperties(); const rnVer = RN.Platform.constants.reactNativeVersion; export default function General() { - const [debuggerUrl, setDebuggerUrl] = React.useState(""); + const [devSettings, setDevSettings] = React.useState(settings.developerSettings || false); const versions = [ { @@ -41,39 +41,18 @@ export default function General() { } + leading={} trailing={FormRow.Arrow} onPress={() => url.openURL(DISCORD_SERVER)} /> } + leading={} trailing={FormRow.Arrow} onPress={() => url.openURL(GITHUB)} /> - - setDebuggerUrl(v)} - title="DEBUGGER URL" - /> - - } - trailing={FormRow.Arrow} - onPress={() => connectToDebugger(debuggerUrl)} - /> - - } - trailing={FormRow.Arrow} - onPress={() => RN.NativeModules.BundleUpdaterManager.reload()} - /> - {versions.map((v) => ( <> @@ -82,6 +61,26 @@ export default function General() { ))} + + } + trailing={FormRow.Arrow} + onPress={() => RN.NativeModules.BundleUpdaterManager.reload()} + /> + + } + trailing={ { + settings.developerSettings = v; + setDevSettings(v); + }} + />} + /> + ) } \ No newline at end of file diff --git a/src/ui/settings/pages/Plugins.tsx b/src/ui/settings/pages/Plugins.tsx index e8748a9..32a6e82 100644 --- a/src/ui/settings/pages/Plugins.tsx +++ b/src/ui/settings/pages/Plugins.tsx @@ -11,7 +11,6 @@ export default function Plugins() { const [pluginUrl, setPluginUrl] = React.useState(""); const [pluginList, setPluginList] = React.useState(plugins); - return ( <>