Files
OrionTV/hooks/useThemeColor.ts
Neil.X.Zhang 3b79d06b7d Update
2025-06-27 16:16:14 +08:00

23 lines
522 B
TypeScript

/**
* Learn more about light and dark modes:
* https://docs.expo.dev/guides/color-schemes/
*/
import {useColorScheme} from 'react-native';
import {Colors} from '@/constants/Colors';
export function useThemeColor(
props: {light?: string; dark?: string},
colorName: keyof typeof Colors.light & keyof typeof Colors.dark,
) {
const theme = useColorScheme() ?? 'light';
const colorFromProps = props[theme];
if (colorFromProps) {
return colorFromProps;
} else {
return Colors[theme][colorName];
}
}