From 9bc89d45530c308134d9ae51923798cfe5668aea Mon Sep 17 00:00:00 2001 From: amsyarasyiq <82711525+amsyarasyiq@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:36:16 +0800 Subject: [PATCH] [main] Whatever this does --- src/core/ui/components/Card.tsx | 131 ++++++++++++---------- src/core/ui/settings/pages/General.tsx | 11 ++ src/lib/settings.ts | 1 + src/lib/ui/components/discord/Redesign.ts | 19 +++- src/lib/ui/settings/patches/tabs.tsx | 5 +- 5 files changed, 102 insertions(+), 65 deletions(-) diff --git a/src/core/ui/components/Card.tsx b/src/core/ui/components/Card.tsx index cd9b7a7..b19e8fd 100644 --- a/src/core/ui/components/Card.tsx +++ b/src/core/ui/components/Card.tsx @@ -1,4 +1,5 @@ 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"; @@ -11,7 +12,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, @@ -57,7 +58,7 @@ const useStyles = createStyles({ right: "30%", top: "-10%" } -}); +})); interface Action { icon: string; @@ -89,6 +90,8 @@ interface CardProps { overflowActions?: OverflowAction[]; } +const reverseIfNeeded = (arr: any[]) => settings.__unfunnyJoke24 !== false ? arr.reverse() : arr; + export default function Card(props: CardProps) { const styles = useStyles(); @@ -99,66 +102,70 @@ export default function Card(props: CardProps) { resizeMode="cover" imageStyle={styles.iconStyle} > - - {props.headerLabel} - {props.headerSublabel && ( - {props.headerSublabel} - )} - - } - trailing={ - - - {props.overflowActions && - showSimpleActionSheet({ - key: "CardOverflow", - header: { - title: props.overflowTitle, - icon: 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 }) => ( - - ))} - - {props.toggleType && (props.toggleType === "switch" ? - - : - { - props.onToggleChange?.(!props.toggleValue); - }}> - - - )} - - } - /> - - {props.descriptionLabel} - - } - /> + { + reverseIfNeeded([ + + {props.headerLabel} + {props.headerSublabel && ( + {props.headerSublabel} + )} + + } + trailing={ + + + {props.overflowActions && + showSimpleActionSheet({ + key: "CardOverflow", + header: { + title: props.overflowTitle, + icon: 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 }) => ( + + ))} + + {props.toggleType && (props.toggleType === "switch" ? + + : + { + props.onToggleChange?.(!props.toggleValue); + }}> + + + )} + + } + />, + + {props.descriptionLabel} + + } + />, + ]) + } ); diff --git a/src/core/ui/settings/pages/General.tsx b/src/core/ui/settings/pages/General.tsx index 0972ef7..5b7ae3e 100644 --- a/src/core/ui/settings/pages/General.tsx +++ b/src/core/ui/settings/pages/General.tsx @@ -63,6 +63,17 @@ export default function General() { onPress={() => url.openURL(GITHUB)} /> + + } + value={settings.__unfunnyJoke24 !== false} + onValueChange={(v: boolean) => { + settings.__unfunnyJoke24 = v; + }} + /> + find(m => m[prop] && Object.keys(m).length === 1)?.[prop]; @@ -14,6 +15,20 @@ 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, @@ -60,7 +75,7 @@ export const { SegmentedControl, SegmentedControlPages, Slider, - Stack, + // Stack, StepModal, StickyContext, StickyHeader, @@ -69,7 +84,7 @@ export const { TableRadioGroup, TableRadioRow, TableRow, - TableRowGroup, + // TableRowGroup, TableRowGroupTitle, TableRowIcon, TableSwitchRow, diff --git a/src/lib/ui/settings/patches/tabs.tsx b/src/lib/ui/settings/patches/tabs.tsx index 9af415a..09e6789 100644 --- a/src/lib/ui/settings/patches/tabs.tsx +++ b/src/lib/ui/settings/patches/tabs.tsx @@ -1,5 +1,6 @@ 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"; @@ -57,10 +58,12 @@ 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: registeredSections[sect].map(a => a.key) + settings: reverseIfNeeded(registeredSections[sect].map(a => a.key)) }); }); }));