From f237031eb35807bc9d0ff83837e24f0e94b769e5 Mon Sep 17 00:00:00 2001 From: Vomitblood Date: Sat, 10 Aug 2024 03:14:23 +0800 Subject: [PATCH] added debug panel --- .../HeaderBar/Settings/Settings.tsx | 57 ++++++++++--------- .../Settings/SettingsTabs/Background.tsx | 3 +- .../HeaderBar/Settings/SettingsTabs/Debug.tsx | 47 +++++++++++++++ 3 files changed, 79 insertions(+), 28 deletions(-) create mode 100644 src/components/HeaderBar/Settings/SettingsTabs/Debug.tsx diff --git a/src/components/HeaderBar/Settings/Settings.tsx b/src/components/HeaderBar/Settings/Settings.tsx index a0c7423..9375b31 100644 --- a/src/components/HeaderBar/Settings/Settings.tsx +++ b/src/components/HeaderBar/Settings/Settings.tsx @@ -1,5 +1,11 @@ -import { BugReportOutlined, SettingsOutlined } from "@mui/icons-material"; -import { LoadingButton, TabContext, TabList, TabPanel } from "@mui/lab"; +import { + BugReportOutlined, + FormatPaintOutlined, + SettingsOutlined, + WallpaperOutlined, + WebAssetOutlined, +} from "@mui/icons-material"; +import { TabContext, TabList, TabPanel } from "@mui/lab"; import { Box, Button, IconButton, Tab, Tooltip, useTheme } from "@mui/material"; import { useAtom } from "jotai"; import { useRouter } from "next/router"; @@ -10,6 +16,7 @@ import { FloatingDialog } from "../../Generic/FloatingDialog"; import { Background } from "./SettingsTabs/Background"; import { Style } from "./SettingsTabs/Style"; import { Window } from "./SettingsTabs/Window"; +import { Debug } from "./SettingsTabs/Debug"; export const Settings = () => { // contexts @@ -24,8 +31,6 @@ export const Settings = () => { const [settingsOpenState, setSettingsOpenState] = useState(false); const [settingsMaximisedState, setSettingsMaximisedState] = useState(false); const [subTabValue, setSubTabValue] = useState("style"); - const [applyLoading, setApplyLoading] = useState(false); - const [saveLoading, setSaveLoading] = useState(false); const toggleSettings = () => { setSettingsOpenState((prevState) => !prevState); @@ -47,9 +52,7 @@ export const Settings = () => { }; const applyClickEvent = () => { - setApplyLoading(true); updateSettings(stagedSettings); - setApplyLoading(false); }; const saveClickEvent = () => { @@ -61,24 +64,11 @@ export const Settings = () => { // set staged settings back to current settings on close useEffect(() => { if (!settingsOpenState) setStagedSettings(settings); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [settingsOpenState]); return ( - { - router.push("/testing"); - }} - sx={{ - mr: 1, - }} - > - - - - } body={ { variant="scrollable" > } label="Style" value="style" /> } label="Background" value="background" /> } label="Window" value="window" /> + } + label="Debug" + value="debug" + /> @@ -141,6 +140,12 @@ export const Settings = () => { > + + + @@ -164,8 +169,7 @@ export const Settings = () => { Cancel - { variant="outlined" > Apply - - + } close={closeSettings} diff --git a/src/components/HeaderBar/Settings/SettingsTabs/Background.tsx b/src/components/HeaderBar/Settings/SettingsTabs/Background.tsx index 5604f99..1eda5c9 100644 --- a/src/components/HeaderBar/Settings/SettingsTabs/Background.tsx +++ b/src/components/HeaderBar/Settings/SettingsTabs/Background.tsx @@ -18,7 +18,7 @@ interface BackgroundProps { export const Background: FC = ({ sx }) => { // contexts - const { settings, updateSettings } = useSettings(); + const { settings } = useSettings(); // atoms const [stagedSettings, setStagedSettings] = useAtom(stagedSettingsAtom); @@ -112,6 +112,7 @@ export const Background: FC = ({ sx }) => { applyWallpaper(); setOldWallpaperPath(settings.background.background_image_path); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [settings.background.background_image_path]); // update the preview image when stagedSettings.background.background_image_path changes diff --git a/src/components/HeaderBar/Settings/SettingsTabs/Debug.tsx b/src/components/HeaderBar/Settings/SettingsTabs/Debug.tsx new file mode 100644 index 0000000..e6bc8e6 --- /dev/null +++ b/src/components/HeaderBar/Settings/SettingsTabs/Debug.tsx @@ -0,0 +1,47 @@ +import { Box, Typography } from "@mui/material"; +import { FC } from "react"; +import { useSettings } from "../../../../contexts/SettingsContext"; +import { CategoryTitle } from "../CategoryTitle"; + +interface DebugProps { + sx?: any; +} + +export const Debug: FC = ({ sx }) => { + // contexts + const { settings, resetSettings } = useSettings(); + + return ( + + + + Here do be dragons + + + + + + + ); +};