[UI > Settings] Completely overhaul
This commit is contained in:
parent
0ec19aaf5c
commit
91be38564d
6 changed files with 55 additions and 24 deletions
2
src/lib/constants.ts
Normal file
2
src/lib/constants.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export const DISCORD_SERVER = "https://discord.gg/n9QQ4XhhJP";
|
||||||
|
export const GITHUB = "https://github.com/vendetta-mod";
|
|
@ -4,6 +4,7 @@ import { find, findByProps } from "@metro/filters";
|
||||||
export const constants = findByProps("API_HOST");
|
export const constants = findByProps("API_HOST");
|
||||||
export const channels = findByProps("getVoiceChannelId");
|
export const channels = findByProps("getVoiceChannelId");
|
||||||
export const i18n = findByProps("Messages");
|
export const i18n = findByProps("Messages");
|
||||||
|
export const url = findByProps("openURL");
|
||||||
export const toasts = find(m => m.open && m.close && !m.startDrag && !m.init && !m.openReplay && !m.setAlwaysOnTop);
|
export const toasts = find(m => m.open && m.close && !m.startDrag && !m.init && !m.openReplay && !m.setAlwaysOnTop);
|
||||||
|
|
||||||
// React
|
// React
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
import { React, ReactNative as RN, url } from "@metro/common";
|
||||||
|
import { DISCORD_SERVER, GITHUB } from "@lib/constants";
|
||||||
import { connectToDebugWS } from "@lib/debug";
|
import { connectToDebugWS } from "@lib/debug";
|
||||||
import { React, ReactNative as RN } from "@metro/common";
|
import { getAssetIDByName } from "@ui/assets";
|
||||||
import { Forms } from "@ui/components";
|
import { Forms } from "@ui/components";
|
||||||
import Version from "./Version";
|
import Version from "./Version";
|
||||||
|
|
||||||
|
@ -7,57 +9,71 @@ const { FormRow, FormSection, FormInput } = Forms;
|
||||||
const hermesProps = window.HermesInternal.getRuntimeProperties();
|
const hermesProps = window.HermesInternal.getRuntimeProperties();
|
||||||
const rnVer = RN.Platform.constants.reactNativeVersion;
|
const rnVer = RN.Platform.constants.reactNativeVersion;
|
||||||
|
|
||||||
export default function Settings() {
|
export default function General() {
|
||||||
const [debuggerUrl, setDebuggerUrl] = React.useState("");
|
const [debuggerUrl, setDebuggerUrl] = React.useState("");
|
||||||
|
|
||||||
const versions = [
|
const versions = [
|
||||||
{
|
{
|
||||||
label: "Discord",
|
label: "Discord",
|
||||||
version: RN.NativeModules.InfoDictionaryManager.Version,
|
version: RN.NativeModules.InfoDictionaryManager.Version,
|
||||||
|
icon: "Discord",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "React",
|
label: "React",
|
||||||
version: React.version,
|
version: React.version,
|
||||||
|
icon: "ic_category_16px",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "React Native",
|
label: "React Native",
|
||||||
version: `${rnVer.major || 0}.${rnVer.minor || 0}.${rnVer.patch || 0}`,
|
version: `${rnVer.major || 0}.${rnVer.minor || 0}.${rnVer.patch || 0}`,
|
||||||
|
icon: "mobile",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Hermes",
|
label: "Hermes",
|
||||||
version: `${hermesProps["OSS Release Version"]} ${hermesProps["Build"]}`,
|
version: `${hermesProps["OSS Release Version"]} ${hermesProps["Build"]} | Bytecode ${hermesProps["Bytecode Version"]}`,
|
||||||
},
|
icon: "ic_hammer_and_chisel_24px",
|
||||||
{
|
|
||||||
label: "Bytecode",
|
|
||||||
version: hermesProps["Bytecode Version"],
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<RN.ScrollView>
|
||||||
{/* Why is there still a divider? */}
|
{/* Why is there still a divider? */}
|
||||||
<FormSection title="Debug" android_noDivider>
|
<FormSection title="Links" android_noDivider>
|
||||||
|
<FormRow
|
||||||
|
label="Discord Server"
|
||||||
|
leading={() => <FormRow.Icon source={getAssetIDByName("Discord")} />}
|
||||||
|
trailing={FormRow.Arrow}
|
||||||
|
onPress={() => url.openURL(DISCORD_SERVER)}
|
||||||
|
/>
|
||||||
|
<FormRow
|
||||||
|
label="GitHub"
|
||||||
|
leading={() => <FormRow.Icon source={getAssetIDByName("img_account_sync_github_white")} />}
|
||||||
|
trailing={FormRow.Arrow}
|
||||||
|
onPress={() => url.openURL(GITHUB)}
|
||||||
|
/>
|
||||||
|
</FormSection>
|
||||||
|
<FormSection title="Debug">
|
||||||
<FormInput
|
<FormInput
|
||||||
value={debuggerUrl}
|
value={debuggerUrl}
|
||||||
onChange={(v: string) => setDebuggerUrl(v)}
|
onChange={(v: string) => setDebuggerUrl(v)}
|
||||||
title="DEBUGGER URL"
|
title="DEBUGGER URL"
|
||||||
/>
|
/>
|
||||||
</FormSection>
|
|
||||||
<FormSection title="Actions">
|
|
||||||
<FormRow
|
|
||||||
label="Reload Discord"
|
|
||||||
trailing={FormRow.Arrow}
|
|
||||||
onPress={() => RN.NativeModules.BundleUpdaterManager.reload()}
|
|
||||||
/>
|
|
||||||
<FormRow
|
<FormRow
|
||||||
label="Connect to debug websocket"
|
label="Connect to debug websocket"
|
||||||
|
leading={() => <FormRow.Icon source={getAssetIDByName("copy")} />}
|
||||||
trailing={FormRow.Arrow}
|
trailing={FormRow.Arrow}
|
||||||
onPress={() => connectToDebugWS(debuggerUrl)}
|
onPress={() => connectToDebugWS(debuggerUrl)}
|
||||||
/>
|
/>
|
||||||
|
<FormRow
|
||||||
|
label="Reload Discord"
|
||||||
|
leading={() => <FormRow.Icon source={getAssetIDByName("ic_message_retry")} />}
|
||||||
|
trailing={FormRow.Arrow}
|
||||||
|
onPress={() => RN.NativeModules.BundleUpdaterManager.reload()}
|
||||||
|
/>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
<FormSection title="Versions">
|
<FormSection title="Versions">
|
||||||
{versions.map((v) => <Version label={v.label} version={v.version} /> )}
|
{versions.map((v) => <Version label={v.label} version={v.version} icon={v.icon} /> )}
|
||||||
</FormSection>
|
</FormSection>
|
||||||
</>
|
</RN.ScrollView>
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import { React } from "@metro/common";
|
import { React } from "@metro/common";
|
||||||
import { Forms } from "@ui/components";
|
import { Forms } from "@ui/components";
|
||||||
|
import { getAssetIDByName } from "@ui/assets";
|
||||||
|
|
||||||
const { FormRow, FormSection } = Forms;
|
const { FormRow, FormSection } = Forms;
|
||||||
|
|
||||||
|
@ -11,12 +12,14 @@ export default function SettingsSection({ navigation }: SettingsSectionProps) {
|
||||||
return (
|
return (
|
||||||
<FormSection key="Vendetta" title="Vendetta">
|
<FormSection key="Vendetta" title="Vendetta">
|
||||||
<FormRow
|
<FormRow
|
||||||
label="Settings"
|
label="General"
|
||||||
|
leading={() => <FormRow.Icon source={getAssetIDByName("settings")} />}
|
||||||
trailing={FormRow.Arrow}
|
trailing={FormRow.Arrow}
|
||||||
onPress={() => navigation.push("VendettaSettings")}
|
onPress={() => navigation.push("VendettaSettings")}
|
||||||
/>
|
/>
|
||||||
<FormRow
|
<FormRow
|
||||||
label="Asset Browser"
|
label="Asset Browser"
|
||||||
|
leading={() => <FormRow.Icon source={getAssetIDByName("grid")} />}
|
||||||
trailing={FormRow.Arrow}
|
trailing={FormRow.Arrow}
|
||||||
onPress={() => navigation.push("VendettaAssetBrowser")}
|
onPress={() => navigation.push("VendettaAssetBrowser")}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,18 +1,27 @@
|
||||||
import { React } from "@metro/common";
|
import { React } from "@metro/common";
|
||||||
|
import { getAssetIDByName } from "@ui/assets";
|
||||||
|
import { showToast } from "@ui/toasts";
|
||||||
import { Forms } from "@ui/components";
|
import { Forms } from "@ui/components";
|
||||||
|
import copyText from "@utils/copyText";
|
||||||
|
|
||||||
interface VersionProps {
|
interface VersionProps {
|
||||||
label: string;
|
label: string;
|
||||||
version: string
|
version: string;
|
||||||
|
icon: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { FormRow, FormText } = Forms;
|
const { FormRow, FormText } = Forms;
|
||||||
|
|
||||||
export default function Version({ label, version }: VersionProps) {
|
export default function Version({ label, version, icon }: VersionProps) {
|
||||||
return (
|
return (
|
||||||
<FormRow
|
<FormRow
|
||||||
label={label}
|
label={label}
|
||||||
|
leading={() => <FormRow.Icon source={getAssetIDByName(icon)} />}
|
||||||
trailing={() => <FormText>{version}</FormText>}
|
trailing={() => <FormText>{version}</FormText>}
|
||||||
|
onPress={() => {
|
||||||
|
copyText(`${label} - ${version}`);
|
||||||
|
showToast("Copied version to clipboard.", getAssetIDByName("toast_copy_link"))
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@ import { React, i18n } from "@metro/common";
|
||||||
import { findByDisplayName } from "@metro/filters";
|
import { findByDisplayName } from "@metro/filters";
|
||||||
import { after } from "@lib/patcher";
|
import { after } from "@lib/patcher";
|
||||||
import findInReactTree from "@utils/findInReactTree";
|
import findInReactTree from "@utils/findInReactTree";
|
||||||
import Settings from "./components/Settings";
|
|
||||||
import SettingsSection from "./components/SettingsSection";
|
import SettingsSection from "./components/SettingsSection";
|
||||||
|
import General from "./components/General";
|
||||||
import AssetBrowser from "./components/AssetBrowser";
|
import AssetBrowser from "./components/AssetBrowser";
|
||||||
|
|
||||||
const screensModule = findByDisplayName("getScreens", false);
|
const screensModule = findByDisplayName("getScreens", false);
|
||||||
|
@ -14,8 +14,8 @@ export default function initSettings() {
|
||||||
return {
|
return {
|
||||||
...ret,
|
...ret,
|
||||||
VendettaSettings: {
|
VendettaSettings: {
|
||||||
title: "Vendetta Settings",
|
title: "Vendetta",
|
||||||
render: Settings
|
render: General
|
||||||
},
|
},
|
||||||
VendettaAssetBrowser: {
|
VendettaAssetBrowser: {
|
||||||
title: "Asset Browser",
|
title: "Asset Browser",
|
||||||
|
|
Loading…
Reference in a new issue