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

View File

@ -1,29 +1,15 @@
import { ComponentProps, useMemo } from "react";
import { FAB, useTheme } from "react-native-paper";
import { CombinedDarkTheme, CombinedDefaultTheme } from "./App";
import { lightColors } from "./colors";
import { ComponentProps } from "react";
import { FAB } from "react-native-paper";
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 (
<FAB
icon="plus"
testID="add"
color={fabColor}
style={{
position: "absolute",
right: 20,
bottom: 20,
backgroundColor: colors.primary,
}}
{...props}
/>

View File

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