Fix default colors on fresh install

This commit is contained in:
Brandon Presley 2023-11-14 14:34:10 +13:00
parent bec564e18b
commit 5a06b7ee2c
3 changed files with 5 additions and 22 deletions

View File

@ -54,8 +54,9 @@ const App = () => {
setAppSettings({ setAppSettings({
startup: gotSettings.startup, startup: gotSettings.startup,
theme: gotSettings.theme, theme: gotSettings.theme,
lightColor: gotSettings.lightColor, lightColor:
darkColor: gotSettings.darkColor, gotSettings.lightColor || CombinedDefaultTheme.colors.primary,
darkColor: gotSettings.darkColor || CombinedDarkTheme.colors.primary,
}); });
})(); })();
}, []); }, []);
@ -67,7 +68,6 @@ const App = () => {
...CombinedDarkTheme.colors, ...CombinedDarkTheme.colors,
primary: appSettings.darkColor, primary: appSettings.darkColor,
}, },
dark: true,
}; };
const lightTheme = { const lightTheme = {
...CombinedDefaultTheme, ...CombinedDefaultTheme,
@ -75,7 +75,6 @@ const App = () => {
...CombinedDefaultTheme.colors, ...CombinedDefaultTheme.colors,
primary: appSettings.lightColor, primary: appSettings.lightColor,
}, },
dark: false,
}; };
let theme = systemTheme === "dark" ? darkTheme : lightTheme; let theme = systemTheme === "dark" ? darkTheme : lightTheme;
if (appSettings.theme === "dark") theme = darkTheme; if (appSettings.theme === "dark") theme = darkTheme;

View File

@ -1,29 +1,15 @@
import { ComponentProps, useMemo } from "react"; import { ComponentProps } from "react";
import { FAB, useTheme } from "react-native-paper"; import { FAB } from "react-native-paper";
import { CombinedDarkTheme, CombinedDefaultTheme } from "./App";
import { lightColors } from "./colors";
export default function AppFab(props: Partial<ComponentProps<typeof FAB>>) { export default function AppFab(props: Partial<ComponentProps<typeof FAB>>) {
const { colors } = useTheme();
const fabColor = useMemo(
() =>
lightColors.map((color) => color.hex).includes(colors.primary)
? CombinedDarkTheme.colors.background
: CombinedDefaultTheme.colors.background,
[colors.primary]
);
return ( return (
<FAB <FAB
icon="plus" icon="plus"
testID="add" testID="add"
color={fabColor}
style={{ style={{
position: "absolute", position: "absolute",
right: 20, right: 20,
bottom: 20, bottom: 20,
backgroundColor: colors.primary,
}} }}
{...props} {...props}
/> />

View File

@ -73,13 +73,11 @@ export default function TimerPage() {
<FAB <FAB
icon="plus" icon="plus"
color={colors.background}
onPress={add} onPress={add}
style={{ style={{
position: "absolute", position: "absolute",
left: 20, left: 20,
bottom: 20, bottom: 20,
backgroundColor: colors.primary,
}} }}
/> />
<AppFab icon="stop" onPress={stop} /> <AppFab icon="stop" onPress={stop} />