diff --git a/bun.lockb b/bun.lockb index f4ba319..aa791be 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 6c2f6f7..e0d7052 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@emotion/server": "^11.11.0", "@emotion/styled": "^11.13.0", "@mui/icons-material": "^5.16.6", - "@mui/lab": "^5.0.0-alpha.173", + "@mui/lab": "5.0.0-alpha.143", "@mui/material": "^5.16.6", "@tauri-apps/api": "^1.6.0", "jotai": "^2.9.1", diff --git a/src/components/Generic/FloatingDialog.tsx b/src/components/Generic/FloatingDialog.tsx index 4274dad..95c8ad0 100644 --- a/src/components/Generic/FloatingDialog.tsx +++ b/src/components/Generic/FloatingDialog.tsx @@ -59,6 +59,7 @@ export const FloatingDialog: FC = ({ > { const router = useRouter(); @@ -42,15 +42,25 @@ export const HeaderBar = () => { flexDirection: "row", }} > - { - router.push("/testing"); + - - - - + { + router.push("/testing"); + }} + > + + + + + ); diff --git a/src/components/HeaderBar/Settings/Settings.tsx b/src/components/HeaderBar/Settings/Settings.tsx index 088235c..5639e1d 100644 --- a/src/components/HeaderBar/Settings/Settings.tsx +++ b/src/components/HeaderBar/Settings/Settings.tsx @@ -1,11 +1,12 @@ import { SettingsOutlined } from "@mui/icons-material"; -import { LoadingButton } from "@mui/lab"; -import { Box, Button, IconButton, Typography, useTheme } from "@mui/material"; +import { LoadingButton, TabContext, TabList, TabPanel } from "@mui/lab"; +import { Box, Button, IconButton, Tab, useTheme } from "@mui/material"; import { useAtom } from "jotai"; import { useEffect, useState } from "react"; import { useSettings } from "../../../contexts/SettingsContext"; import { settingsAtom } from "../../../lib/store/jotai/settings"; import { FloatingDialog } from "../../Generic/FloatingDialog"; +import { SettingsTabDisplay } from "./SettingsTabDisplay"; export const Settings = () => { // contexts @@ -60,7 +61,53 @@ export const Settings = () => { return ( Settings} + body={ + + + { + subTabChangeEvent(value); + }} + scrollButtons={true} + sx={{ + borderBottom: "1px solid " + theme.palette.divider, + }} + variant="scrollable" + > + + + + + + + + + + } bottomBar={ { }); return ( - + = ({ children }) => { const [settings, setSettings] = useState(defaultSettings); const [settingsLoading, setSettingsLoading] = useState(true); + const fetchSettings = async () => { + try { + const existingSettings = await readConfigFile(); + setSettings(existingSettings); + } catch (error) { + logcat.log(`Failed to load settings: ${error}`, "ERROR"); + } finally { + setSettingsLoading(false); + } + }; + const updateSettings = async (newSettings: SettingsType) => { try { await writeConfigFile(newSettings); @@ -43,17 +54,6 @@ export const SettingsProvider: FC<{ children: ReactNode }> = ({ children }) => { // fetch user settings from local on first load every time useEffect(() => { - const fetchSettings = async () => { - try { - const existingSettings = await readConfigFile(); - setSettings(existingSettings); - } catch (error) { - logcat.log(`Failed to load settings: ${error}`, "ERROR"); - } finally { - setSettingsLoading(false); - } - }; - fetchSettings(); }, []); diff --git a/src/lib/settings.ts b/src/lib/settings.ts index d286767..0d14f8f 100644 --- a/src/lib/settings.ts +++ b/src/lib/settings.ts @@ -1,3 +1,4 @@ +import { merge } from "lodash"; import Paths from "./path"; import { readTomlFile, writeTomlFile } from "./utils/toml"; @@ -25,9 +26,12 @@ export const readConfigFile = async (): Promise => { try { // try to read the config file + await Paths.initialize(); const data = await readTomlFile(Paths.getPath("configDirectory") + "config.toml"); if (data) { existingData = data; + console.log("existing data"); + console.log(existingData); } } catch (error) { // file does not exist, called function will throw error @@ -37,11 +41,12 @@ export const readConfigFile = async (): Promise => { // merge the existing data with the default settings // existing data will overwrite the default settings for the properties that exist - const mergedSettings = { ...defaultSettings, ...existingData }; + const mergedSettings = merge({}, defaultSettings, existingData); return mergedSettings; }; export const writeConfigFile = async (settingsValues: SettingsType): Promise => { await writeTomlFile(Paths.getPath("configDirectory") + "config.toml", settingsValues); + console.debug("Settings file written successfully."); }; diff --git a/src/pages/testing.tsx b/src/pages/testing.tsx index 298a0c6..506d982 100644 --- a/src/pages/testing.tsx +++ b/src/pages/testing.tsx @@ -29,7 +29,28 @@ export default function Testing() { > reset settings - +