mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-10 16:21:36 +00:00
Refactor ordering of constructing theme
This commit is contained in:
parent
8108c4146b
commit
eb923b4e6f
@ -12,23 +12,8 @@ import i18n from './i18n/Web';
|
|||||||
import { systemClient } from './services/System';
|
import { systemClient } from './services/System';
|
||||||
import { Settings } from './models';
|
import { Settings } from './models';
|
||||||
|
|
||||||
const defaultTheme: Theme = createTheme({
|
const makeTheme = function (settings: Settings) {
|
||||||
palette: {
|
const theme: Theme = createTheme({
|
||||||
mode: new Settings().mode,
|
|
||||||
background: {
|
|
||||||
default: new Settings().mode === 'dark' ? '#070707' : '#fff',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
typography: { fontSize: new Settings().fontSize },
|
|
||||||
});
|
|
||||||
|
|
||||||
const App = (): JSX.Element => {
|
|
||||||
const [theme, setTheme] = useState<Theme>(defaultTheme);
|
|
||||||
const [settings, setSettings] = useState<Settings>(new Settings());
|
|
||||||
|
|
||||||
const updateTheme = function () {
|
|
||||||
setTheme(
|
|
||||||
createTheme({
|
|
||||||
palette: {
|
palette: {
|
||||||
mode: settings.mode,
|
mode: settings.mode,
|
||||||
background: {
|
background: {
|
||||||
@ -36,12 +21,17 @@ const App = (): JSX.Element => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
typography: { fontSize: settings.fontSize },
|
typography: { fontSize: settings.fontSize },
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
|
return theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const App = (): JSX.Element => {
|
||||||
|
const [theme, setTheme] = useState<Theme>(makeTheme(new Settings()));
|
||||||
|
const [settings, setSettings] = useState<Settings>(new Settings());
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateTheme();
|
setTheme(makeTheme(settings));
|
||||||
}, [settings.fontSize, settings.mode]);
|
}, [settings.fontSize, settings.mode]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user