mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(settings): using local storage to save settings
Need to ensure that when a new setting is set, we re-render the phone.
This commit is contained in:
1 parent
08e21f4129
commit
3e03993d5b
5 files changed
+65
-34
No files matched your search
@@ -1,16 +1,19 @@
|
||||
import Default from "../default.json";
|
||||
import { useConfig } from "../../../config/hooks/useConfig";
|
||||
import { atom } from "recoil";
|
||||
import { createMuiTheme } from "@material-ui/core";
|
||||
import Default from '../default.json';
|
||||
import { useConfig } from '../../../config/hooks/useConfig';
|
||||
import { atom } from 'recoil';
|
||||
import { createMuiTheme } from '@material-ui/core';
|
||||
import useLocalStorage from '../../../os/phone/hooks/useLocalStorage';
|
||||
|
||||
const settingsState = atom({
|
||||
key: "settings",
|
||||
key: 'settings',
|
||||
default: Default,
|
||||
});
|
||||
|
||||
export const useSettings = (): any => {
|
||||
const [settings, setSettings] = useConfig(settingsState);
|
||||
const [, , getStorageItem] = useLocalStorage('theme', 'taso-dark');
|
||||
const [settings, setSettings] = useLocalStorage();
|
||||
const [config] = useConfig();
|
||||
const currentTheme = () => createMuiTheme(config.themes[settings.theme]);
|
||||
const currentTheme = () =>
|
||||
createMuiTheme(config.themes[getStorageItem('theme')]);
|
||||
return { settings, setSettings, currentTheme };
|
||||
};
|
||||
Reference in new issue
Block a user