diff --git a/src/Phone.js b/src/Phone.js index e5455fd..ff4bc70 100644 --- a/src/Phone.js +++ b/src/Phone.js @@ -11,23 +11,21 @@ import MessageIcon from "@material-ui/icons/Email"; import { HomeApp } from "./apps/home/components/Home"; import { ContactsApp } from "./apps/contacts/components/Contacts"; import { SettingsApp } from "./apps/settings/components/Settings"; -import { ThemeProvider, createMuiTheme } from "@material-ui/core"; -import { useConfig } from "./config/hooks/useConfig"; +import { ThemeProvider } from "@material-ui/core"; function Phone() { - const { settings } = useSettings(); - const [config] = useConfig(); + const { settings, currentTheme } = useSettings(); return ( -
-
-
-
- + +
+
+
+
- +
-
+ ); } diff --git a/src/apps/settings/hooks/useSettings.js b/src/apps/settings/hooks/useSettings.js index d80f98e..bd791ed 100644 --- a/src/apps/settings/hooks/useSettings.js +++ b/src/apps/settings/hooks/useSettings.js @@ -1,6 +1,7 @@ import Default from "../default.json"; import { useConfig } from "../../../config/hooks/useConfig"; import { atom } from "recoil"; +import { createMuiTheme } from "@material-ui/core"; const settingsState = atom({ key: "settings", @@ -9,5 +10,7 @@ const settingsState = atom({ export const useSettings = () => { const [settings, setSettings] = useConfig(settingsState); - return { settings, setSettings }; + const [config] = useConfig(); + const currentTheme = () => createMuiTheme(config.themes[settings.theme]); + return { settings, setSettings, currentTheme }; };