Refactor some code in App.tsx
This commit is contained in:
parent
4b5e7011d6
commit
be3af4db22
26
App.tsx
26
App.tsx
|
@ -37,7 +37,7 @@ export const CombinedDarkTheme = {
|
|||
};
|
||||
|
||||
const App = () => {
|
||||
const phoneTheme = useColorScheme();
|
||||
const systemTheme = useColorScheme();
|
||||
|
||||
const [appSettings, setAppSettings] = useState({
|
||||
startup: undefined,
|
||||
|
@ -61,29 +61,27 @@ const App = () => {
|
|||
}, []);
|
||||
|
||||
const paperTheme = useMemo(() => {
|
||||
const darkTheme = appSettings.darkColor
|
||||
? {
|
||||
const darkTheme = {
|
||||
...CombinedDarkTheme,
|
||||
colors: {
|
||||
...CombinedDarkTheme.colors,
|
||||
primary: appSettings.darkColor,
|
||||
},
|
||||
}
|
||||
: CombinedDarkTheme;
|
||||
const lightTheme = appSettings.lightColor
|
||||
? {
|
||||
dark: true,
|
||||
};
|
||||
const lightTheme = {
|
||||
...CombinedDefaultTheme,
|
||||
colors: {
|
||||
...CombinedDefaultTheme.colors,
|
||||
primary: appSettings.lightColor,
|
||||
},
|
||||
}
|
||||
: CombinedDefaultTheme;
|
||||
let value = phoneTheme === "dark" ? darkTheme : lightTheme;
|
||||
if (appSettings.theme === "dark") value = darkTheme;
|
||||
else if (appSettings.theme === "light") value = lightTheme;
|
||||
return value;
|
||||
}, [phoneTheme, appSettings]);
|
||||
dark: false,
|
||||
};
|
||||
let theme = systemTheme === "dark" ? darkTheme : lightTheme;
|
||||
if (appSettings.theme === "dark") theme = darkTheme;
|
||||
else if (appSettings.theme === "light") theme = lightTheme;
|
||||
return theme;
|
||||
}, [systemTheme, appSettings]);
|
||||
|
||||
return (
|
||||
<PaperProvider
|
||||
|
|
Loading…
Reference in New Issue
Block a user