[Global] Code cleanup pass

This commit is contained in:
Beef 2023-04-15 19:54:23 +01:00
parent ffbb507125
commit 85d0bd263b
30 changed files with 65 additions and 80 deletions

View file

@ -1,7 +1,6 @@
import { ErrorBoundaryProps } from "@types";
import { React, ReactNative as RN, stylesheet, constants } from "@metro/common";
import { React, ReactNative as RN, stylesheet } from "@metro/common";
import { Forms, Button, Codeblock } from "@ui/components";
import { semanticColors } from "@ui/color";
interface ErrorBoundaryState {
hasErr: boolean;

View file

@ -1,6 +1,6 @@
import { InputAlertProps } from "@types";
import { findByProps } from "@metro/filters";
import { Forms, Alert } from "@ui/components";
import { InputAlertProps } from "@types";
const { FormInput } = Forms;
const Alerts = findByProps("openLazy", "close");

View file

@ -1,26 +1,25 @@
import { SummaryProps } from "@types";
import { Forms } from "@ui/components";
import { getAssetIDByName } from "@ui/assets";
import { ReactNative as RN } from "@metro/common";
// TODO: Destructuring Forms doesn't work here. Why?
import { getAssetIDByName } from "@ui/assets";
import { Forms } from "@ui/components";
export default function Summary({ label, icon, noPadding = false, noAnimation = false, children }: SummaryProps) {
const { FormRow, FormDivider } = Forms;
const [hidden, setHidden] = React.useState(true);
return (
<>
<Forms.FormRow
<FormRow
label={label}
leading={icon && <Forms.FormRow.Icon source={getAssetIDByName(icon)} />}
trailing={<Forms.FormRow.Arrow style={{ transform: [{ rotate: `${hidden ? 180 : 90}deg` }] }} />}
leading={icon && <FormRow.Icon source={getAssetIDByName(icon)} />}
trailing={<FormRow.Arrow style={{ transform: [{ rotate: `${hidden ? 180 : 90}deg` }] }} />}
onPress={() => {
setHidden(!hidden);
if (!noAnimation) RN.LayoutAnimation.configureNext(RN.LayoutAnimation.Presets.easeInEaseOut);
}}
/>
{!hidden && <>
<Forms.FormDivider />
<FormDivider />
<RN.View style={!noPadding && { paddingHorizontal: 15 }}>{children}</RN.View>
</>}
</>

View file

@ -5,8 +5,8 @@ import { installPlugin } from "@lib/plugins";
import { installTheme } from "@lib/themes";
import { findInReactTree } from "@lib/utils";
import { getAssetIDByName } from "@ui/assets";
import { Forms } from "@ui/components";
import { showToast } from "@ui/toasts";
import { Forms } from "@ui/components";
const ForumPostLongPressActionSheet = findByName("ForumPostLongPressActionSheet", false);
const { FormRow } = Forms;

View file

@ -2,8 +2,8 @@ import { ButtonColors } from "@types";
import { ReactNative as RN, stylesheet } from "@metro/common";
import { findByName, findByProps, findByStoreName } from "@metro/filters";
import { after } from "@lib/patcher";
import { DeviceManager } from "@lib/native";
import { toggleSafeMode } from "@lib/debug";
import { DeviceManager } from "@lib/native";
import { semanticColors } from "@ui/color";
import { Button, Codeblock, ErrorBoundary as _ErrorBoundary, SafeAreaView } from "@ui/components";
import settings from "@lib/settings";

View file

@ -4,9 +4,7 @@ import { showToast } from "@ui/toasts";
import { getAssetIDByName } from "@ui/assets";
import { Forms } from "@ui/components";
interface AssetDisplayProps {
asset: Asset;
}
interface AssetDisplayProps { asset: Asset }
const { FormRow } = Forms;

View file

@ -1,8 +1,8 @@
import { ReactNative as RN, stylesheet } from "@metro/common";
import { findByProps } from "@metro/filters";
import { Forms } from "@ui/components";
import { getAssetIDByName } from "@ui/assets";
import { semanticColors } from "@ui/color";
import { Forms } from "@ui/components";
const { FormRow, FormSwitch, FormRadio } = Forms;
const { hideActionSheet } = findByProps("openLazy", "hideActionSheet");

View file

@ -1,10 +1,10 @@
import { ButtonColors, Plugin } from "@types";
import { NavigationNative, clipboard } from "@metro/common";
import { removePlugin, startPlugin, stopPlugin, getSettings, fetchPlugin } from "@lib/plugins";
import { MMKVManager } from "@lib/native";
import { getAssetIDByName } from "@ui/assets";
import { showToast } from "@ui/toasts";
import { showConfirmationAlert } from "@ui/alerts";
import { removePlugin, startPlugin, stopPlugin, getSettings, fetchPlugin } from "@lib/plugins";
import Card, { CardWrapper } from "@ui/settings/components/Card";
async function stopThenStart(plugin: Plugin, callback: Function) {

View file

@ -1,7 +1,7 @@
import { NavigationNative } from "@metro/common";
import { ErrorBoundary, Forms } from "@ui/components";
import { getAssetIDByName } from "@ui/assets";
import { useProxy } from "@lib/storage";
import { getAssetIDByName } from "@ui/assets";
import { ErrorBoundary, Forms } from "@ui/components";
import settings from "@lib/settings";
const { FormRow, FormSection, FormDivider } = Forms;

View file

@ -1,8 +1,8 @@
import { ButtonColors, Theme } from "@types";
import { clipboard } from "@metro/common";
import { fetchTheme, removeTheme, selectTheme } from "@lib/themes";
import { BundleUpdaterManager } from "@lib/native";
import { useProxy } from "@lib/storage";
import { BundleUpdaterManager } from "@lib/native";
import { getAssetIDByName } from "@ui/assets";
import { showConfirmationAlert } from "@ui/alerts";
import { showToast } from "@ui/toasts";

View file

@ -4,8 +4,8 @@ import { after } from "@lib/patcher";
import { installPlugin } from "@lib/plugins";
import { installTheme } from "@lib/themes";
import { Forms } from "@ui/components";
import findInReactTree from "@utils/findInReactTree";
import without from "@utils/without";
import findInReactTree from "@lib/utils/findInReactTree";
import without from "@lib/utils/without";
import ErrorBoundary from "@ui/components/ErrorBoundary";
import SettingsSection from "@ui/settings/components/SettingsSection";
import InstallButton from "@ui/settings/components/InstallButton";

View file

@ -1,7 +1,6 @@
import { ReactNative as RN } from "@metro/common";
import { all } from "@ui/assets";
import { Forms, Search } from "@ui/components";
import ErrorBoundary from "@ui/components/ErrorBoundary";
import { Forms, Search, ErrorBoundary } from "@ui/components";
import AssetDisplay from "@ui/settings/components/AssetDisplay";
const { FormDivider } = Forms;

View file

@ -1,11 +1,10 @@
import { ReactNative as RN, NavigationNative } from "@metro/common";
import { findByProps } from "@metro/filters";
import { Forms } from "@ui/components";
import { getAssetIDByName } from "@ui/assets";
import { connectToDebugger } from "@lib/debug";
import { useProxy } from "@lib/storage";
import { getAssetIDByName } from "@ui/assets";
import { Forms, ErrorBoundary } from "@ui/components";
import settings, { loaderConfig } from "@lib/settings";
import ErrorBoundary from "@ui/components/ErrorBoundary";
const { FormSection, FormRow, FormSwitchRow, FormInput, FormDivider } = Forms;
const { hideActionSheet } = findByProps("openLazy", "hideActionSheet");

View file

@ -1,13 +1,12 @@
import { ReactNative as RN, url } from "@metro/common";
import { getAssetIDByName } from "@ui/assets";
import { Forms, Summary } from "@ui/components";
import { DISCORD_SERVER, GITHUB } from "@lib/constants";
import { getDebugInfo, toggleSafeMode } from "@lib/debug";
import { useProxy } from "@lib/storage";
import { BundleUpdaterManager } from "@lib/native";
import { getAssetIDByName } from "@ui/assets";
import { Forms, Summary, ErrorBoundary } from "@ui/components";
import settings from "@lib/settings";
import Version from "@ui/settings/components/Version";
import ErrorBoundary from "@ui/components/ErrorBoundary";
const { FormRow, FormSwitchRow, FormSection, FormDivider } = Forms;
const debugInfo = getDebugInfo();

View file

@ -1,6 +1,6 @@
import { toasts } from "@metro/common";
export const showToast = (content: string, asset: number) => toasts.open({
export const showToast = (content: string, asset?: number) => toasts.open({
content: content,
source: asset,
});