Refactor some code in App.tsx

This commit is contained in:
Brandon Presley 2023-11-13 19:40:05 +13:00
parent 4b5e7011d6
commit be3af4db22
1 changed files with 22 additions and 24 deletions

46
App.tsx
View File

@ -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
? {
...CombinedDarkTheme,
colors: {
...CombinedDarkTheme.colors,
primary: appSettings.darkColor,
},
}
: CombinedDarkTheme;
const lightTheme = appSettings.lightColor
? {
...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]);
const darkTheme = {
...CombinedDarkTheme,
colors: {
...CombinedDarkTheme.colors,
primary: appSettings.darkColor,
},
dark: true,
};
const lightTheme = {
...CombinedDefaultTheme,
colors: {
...CombinedDefaultTheme.colors,
primary: appSettings.lightColor,
},
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