Fix color schemes!

This commit is contained in:
2025-06-21 14:53:56 -07:00
parent 8c1021e1c9
commit cbd50a811a
13 changed files with 280 additions and 140 deletions
+10 -12
View File
@@ -1,21 +1,19 @@
/**
* Learn more about light and dark modes:
* https://docs.expo.dev/guides/color-schemes/
*/
import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme';
import { useTheme } from 'react-native-paper';
import { lightTheme, darkTheme } from '@/constants/Colors';
export function useThemeColor(
props: { light?: string; dark?: string },
colorName: keyof typeof Colors.light & keyof typeof Colors.dark
colorName?: keyof typeof lightTheme & keyof typeof darkTheme
) {
const theme = useColorScheme() ?? 'light';
const colorFromProps = props[theme];
const theme = useTheme();
const colorScheme = theme.dark ? 'dark' : 'light';
const colorFromProps = props[colorScheme];
if (colorFromProps) {
return colorFromProps;
} else if (colorName) {
return theme[colorName];
} else {
return Colors[theme][colorName];
return theme.colors.onSurface; // fallback
}
}
}