[UI] Refactors all around

This commit is contained in:
Beef 2023-01-30 22:56:48 +00:00
parent 473205a1ca
commit 09f4c37e94
5 changed files with 27 additions and 19 deletions

View file

@ -47,11 +47,18 @@ export function patchLogHook() {
export const versionHash = "__vendettaVersion"; export const versionHash = "__vendettaVersion";
export function getDebugInfo() { export function getDebugInfo() {
// Discord
const InfoDictionaryManager = RN.NativeModules.InfoDictionaryManager; const InfoDictionaryManager = RN.NativeModules.InfoDictionaryManager;
const DCDDeviceManager = RN.NativeModules.DCDDeviceManager;
// Hermes
const hermesProps = window.HermesInternal.getRuntimeProperties(); const hermesProps = window.HermesInternal.getRuntimeProperties();
const hermesVer = hermesProps["OSS Release Version"];
const padding = "for RN ";
// RN
const PlatformConstants = RN.Platform.constants as RNConstants; const PlatformConstants = RN.Platform.constants as RNConstants;
const rnVer = PlatformConstants.reactNativeVersion; const rnVer = PlatformConstants.reactNativeVersion;
const DCDDeviceManager = RN.NativeModules.DCDDeviceManager;
return { return {
vendetta: { vendetta: {
@ -63,10 +70,10 @@ export function getDebugInfo() {
}, },
react: { react: {
version: React.version, version: React.version,
nativeVersion: `${rnVer.major || 0}.${rnVer.minor || 0}.${rnVer.patch || 0}`, nativeVersion: hermesVer.startsWith(padding) ? hermesVer.substring(padding.length) : `${rnVer.major}.${rnVer.minor}.${rnVer.patch}`,
}, },
hermes: { hermes: {
version: hermesProps["OSS Release Version"], version: hermesVer,
buildType: hermesProps["Build"], buildType: hermesProps["Build"],
bytecodeVersion: hermesProps["Bytecode Version"], bytecodeVersion: hermesProps["Bytecode Version"],
}, },

View file

@ -16,17 +16,17 @@ const styles = stylesheet.createThemedStyleSheet({
}); });
export default function AssetBrowser() { export default function AssetBrowser() {
const [searchName, setSearchName] = React.useState(""); const [search, setSearch] = React.useState("");
return ( return (
<RN.View style={{ flex: 1 }}> <RN.View style={{ flex: 1 }}>
<Search <Search
style={styles.search} style={styles.search}
onChangeText={(v: string) => setSearchName(v)} onChangeText={(v: string) => setSearch(v)}
placeholder="Search..." placeholder="Search"
/> />
<RN.FlatList <RN.FlatList
data={Object.values(all).filter(a => a.name.includes(searchName))} data={Object.values(all).filter(a => a.name.includes(search) || a.id.toString() === search)}
renderItem={({ item }) => ( renderItem={({ item }) => (
<> <>
<AssetDisplay asset={item} /> <AssetDisplay asset={item} />

View file

@ -15,13 +15,12 @@ export default function Developer() {
useProxy(settings); useProxy(settings);
return ( return (
<RN.View style={{ flex: 1 }}> <RN.ScrollView style={{ flex: 1 }}>
<FormSection title="Debug"> <FormSection title="Debug" titleStyleType="no_border">
<FormInput <FormInput
value={settings.debuggerUrl} value={settings.debuggerUrl}
onChange={(v: string) => { onChange={(v: string) => settings.debuggerUrl = v}
settings.debuggerUrl = v; placeholder="127.0.0.1:9090"
}}
title="DEBUGGER URL" title="DEBUGGER URL"
/> />
<FormDivider /> <FormDivider />
@ -41,6 +40,7 @@ export default function Developer() {
resolveRNStyle: RN.StyleSheet.flatten, resolveRNStyle: RN.StyleSheet.flatten,
}); });
} catch(e) { } catch(e) {
// TODO: Check if this ever actually catches anything
logger.error("Failed to connect to React DevTools!", e); logger.error("Failed to connect to React DevTools!", e);
showToast("Failed to connect to React DevTools!", getAssetIDByName("Small")); showToast("Failed to connect to React DevTools!", getAssetIDByName("Small"));
} }
@ -58,6 +58,6 @@ export default function Developer() {
})} })}
/> />
</FormSection> </FormSection>
</RN.View> </RN.ScrollView>
) )
} }

View file

@ -35,8 +35,8 @@ export default function General() {
icon: "mobile", icon: "mobile",
}, },
{ {
label: "Hermes", label: "Bytecode",
version: `${debugInfo.hermes.version} ${debugInfo.hermes.buildType} (Bytecode ${debugInfo.hermes.bytecodeVersion})`, version: debugInfo.hermes.bytecodeVersion,
icon: "ic_server_security_24px", icon: "ic_server_security_24px",
}, },
]; ];
@ -55,7 +55,7 @@ export default function General() {
{ {
label: "Manufacturer", label: "Manufacturer",
version: debugInfo.device.manufacturer, version: debugInfo.device.manufacturer,
icon: "ic_hammer_and_chisel_24px" icon: "ic_badge_staff"
}, },
{ {
label: "Brand", label: "Brand",
@ -75,8 +75,8 @@ export default function General() {
]; ];
return ( return (
<RN.ScrollView> <RN.ScrollView style={{ flex: 1 }}>
<FormSection title="Links"> <FormSection title="Links" titleStyleType="no_border">
<FormRow <FormRow
label="Discord Server" label="Discord Server"
leading={<FormRow.Icon source={getAssetIDByName("Discord")} />} leading={<FormRow.Icon source={getAssetIDByName("Discord")} />}

View file

@ -17,11 +17,12 @@ export default function Plugins() {
<FormInput <FormInput
value={pluginUrl} value={pluginUrl}
onChange={(v: string) => setPluginUrl(v)} onChange={(v: string) => setPluginUrl(v)}
placeholder="https://example.com/"
title="PLUGIN URL" title="PLUGIN URL"
/> />
<FormRow <FormRow
label="Install plugin" label="Install plugin"
leading={<FormRow.Icon source={getAssetIDByName("ic_add_perk_24px")} />} leading={<FormRow.Icon source={getAssetIDByName("ic_add_18px")} />}
onPress={() => { onPress={() => {
fetchPlugin(pluginUrl).then(() => { fetchPlugin(pluginUrl).then(() => {
setPluginUrl(""); setPluginUrl("");