Revert "[main] Whatever this does"

This reverts commit 9bc89d4553.
This commit is contained in:
amsyarasyiq 2024-04-01 19:06:37 +08:00
parent 9bc89d4553
commit 9809ef2cd4
5 changed files with 65 additions and 102 deletions

View file

@ -1,5 +1,4 @@
import { getAssetIDByName } from "@lib/api/assets";
import { settings } from "@lib/settings";
import { FormRow } from "@lib/ui/components/discord/Forms";
import { FormCheckbox, FormSwitch, IconButton } from "@lib/ui/components/discord/Redesign";
import { createStyles, TextStyleSheet } from "@lib/ui/styles";
@ -12,7 +11,7 @@ const { hideActionSheet } = findByProps("openLazy", "hideActionSheet");
const { showSimpleActionSheet } = findByProps("showSimpleActionSheet");
// TODO: These styles work weirdly. iOS has cramped text, Android with low DPI probably does too. Fix?
const useStyles = createStyles(() => ({
const useStyles = createStyles({
card: {
backgroundColor: semanticColors?.CARD_SECONDARY_BG,
borderRadius: 12,
@ -58,7 +57,7 @@ const useStyles = createStyles(() => ({
right: "30%",
top: "-10%"
}
}));
});
interface Action {
icon: string;
@ -90,8 +89,6 @@ interface CardProps {
overflowActions?: OverflowAction[];
}
const reverseIfNeeded = (arr: any[]) => settings.__unfunnyJoke24 !== false ? arr.reverse() : arr;
export default function Card(props: CardProps) {
const styles = useStyles();
@ -102,70 +99,66 @@ export default function Card(props: CardProps) {
resizeMode="cover"
imageStyle={styles.iconStyle}
>
{
reverseIfNeeded([
<FormRow
style={styles.header}
label={
<View style={styles.headerLeading}>
<RN.Text style={styles.headerLabel}>{props.headerLabel}</RN.Text>
{props.headerSublabel && (
<RN.Text style={styles.headerSubtitle}>{props.headerSublabel}</RN.Text>
)}
</View>
}
trailing={
<View style={styles.headerTrailing}>
<View style={styles.actions}>
{props.overflowActions &&
<IconButton
onPress={() => showSimpleActionSheet({
key: "CardOverflow",
header: {
title: props.overflowTitle,
icon: props.headerIcon && <FormRow.Icon style={{ marginRight: 8 }} source={getAssetIDByName(props.headerIcon)} />,
onClose: () => hideActionSheet(),
},
options: props.overflowActions?.map(i => ({ ...i, icon: getAssetIDByName(i.icon) })),
})}
size="sm"
variant="secondary"
icon={getAssetIDByName("CircleInformationIcon")}
/>}
{props.actions?.map(({ icon, onPress, disabled }) => (
<IconButton
onPress={onPress}
disabled={disabled}
size="sm"
variant="secondary"
icon={getAssetIDByName(icon)}
/>
))}
</View>
{props.toggleType && (props.toggleType === "switch" ?
<FormSwitch
value={props.toggleValue}
onValueChange={props.onToggleChange}
/>
:
<RN.Pressable onPress={() => {
props.onToggleChange?.(!props.toggleValue);
}}>
<FormCheckbox checked={props.toggleValue} />
</RN.Pressable>
)}
</View>
}
/>,
<FormRow
label={
<RN.View>
<RN.Text style={styles.descriptionLabel}>{props.descriptionLabel}</RN.Text>
</RN.View>
}
/>,
])
}
<FormRow
style={styles.header}
label={
<View style={styles.headerLeading}>
<RN.Text style={styles.headerLabel}>{props.headerLabel}</RN.Text>
{props.headerSublabel && (
<RN.Text style={styles.headerSubtitle}>{props.headerSublabel}</RN.Text>
)}
</View>
}
trailing={
<View style={styles.headerTrailing}>
<View style={styles.actions}>
{props.overflowActions &&
<IconButton
onPress={() => showSimpleActionSheet({
key: "CardOverflow",
header: {
title: props.overflowTitle,
icon: props.headerIcon && <FormRow.Icon style={{ marginRight: 8 }} source={getAssetIDByName(props.headerIcon)} />,
onClose: () => hideActionSheet(),
},
options: props.overflowActions?.map(i => ({ ...i, icon: getAssetIDByName(i.icon) })),
})}
size="sm"
variant="secondary"
icon={getAssetIDByName("CircleInformationIcon")}
/>}
{props.actions?.map(({ icon, onPress, disabled }) => (
<IconButton
onPress={onPress}
disabled={disabled}
size="sm"
variant="secondary"
icon={getAssetIDByName(icon)}
/>
))}
</View>
{props.toggleType && (props.toggleType === "switch" ?
<FormSwitch
value={props.toggleValue}
onValueChange={props.onToggleChange}
/>
:
<RN.Pressable onPress={() => {
props.onToggleChange?.(!props.toggleValue);
}}>
<FormCheckbox checked={props.toggleValue} />
</RN.Pressable>
)}
</View>
}
/>
<FormRow
label={
<RN.View>
<RN.Text style={styles.descriptionLabel}>{props.descriptionLabel}</RN.Text>
</RN.View>
}
/>
</ImageBackground>
</RN.View>
);

View file

@ -63,17 +63,6 @@ export default function General() {
onPress={() => url.openURL(GITHUB)}
/>
</TableRowGroup>
<TableRowGroup title={"???"}>
<TableSwitchRow
label={"Whatever this does"}
subLabel={"A mystery toggle with a calendar icon, hmm..."}
icon={<TableRow.Icon source={getAssetIDByName("CalendarIcon")} />}
value={settings.__unfunnyJoke24 !== false}
onValueChange={(v: boolean) => {
settings.__unfunnyJoke24 = v;
}}
/>
</TableRowGroup>
<TableRowGroup title={Strings.ACTIONS}>
<TableRow
label={Strings.RELOAD_DISCORD}

View file

@ -5,7 +5,6 @@ export interface Settings {
debuggerUrl: string;
developerSettings: boolean;
enableDiscordDeveloperSettings: boolean;
__unfunnyJoke24?: boolean;
safeMode?: {
enabled: boolean;
currentThemeId?: string;

View file

@ -1,5 +1,4 @@
import { find, findByProps } from "@lib/metro";
import { settings } from "@lib/settings";
import { RedesignModuleKeys } from "@lib/ui/types";
const findSingular = (prop: string) => find(m => m[prop] && Object.keys(m).length === 1)?.[prop];
@ -15,20 +14,6 @@ export const FormSwitch = findSingular("FormSwitch");
export const FormRadio = findSingular("FormRadio");
export const FormCheckbox = findSingular("FormCheckbox");
export function TableRowGroup(...args: any[]) {
if (settings.__unfunnyJoke24 !== false && Array.isArray(args[0]?.children)) {
args[0].children = args[0].children.reverse();
}
return Redesign.TableRowGroup(...args);
}
export function Stack(...args: any[]) {
if (settings.__unfunnyJoke24 !== false && Array.isArray(args[0]?.children)) {
args[0].children = args[0].children.reverse();
}
return Redesign.Stack(...args);
}
export const {
AlertActionButton,
AlertModal,
@ -75,7 +60,7 @@ export const {
SegmentedControl,
SegmentedControlPages,
Slider,
// Stack,
Stack,
StepModal,
StickyContext,
StickyHeader,
@ -84,7 +69,7 @@ export const {
TableRadioGroup,
TableRadioRow,
TableRow,
// TableRowGroup,
TableRowGroup,
TableRowGroupTitle,
TableRowIcon,
TableSwitchRow,

View file

@ -1,6 +1,5 @@
import { findByName, findByProps } from "@lib/metro";
import { i18n } from "@lib/metro/common";
import { settings } from "@lib/settings";
import { registeredSections } from "@lib/ui/settings";
import { findInReactTree } from "@lib/utils";
import { after } from "spitroast";
@ -58,12 +57,10 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
const { sections } = findInReactTree(ret, i => i.props?.sections).props;
let index = -~sections.findIndex((i: any) => i.label === i18n.Messages.ACCOUNT_SETTINGS) || 1;
const reverseIfNeeded = (arr: any[]) => settings.__unfunnyJoke24 !== false ? arr.reverse() : arr;
Object.keys(registeredSections).forEach(sect => {
sections.splice(index++, 0, {
label: sect,
settings: reverseIfNeeded(registeredSections[sect].map(a => a.key))
settings: registeredSections[sect].map(a => a.key)
});
});
}));