eletrotupi / tcc/ frontend/hooks/use-theme-color.ts2b1f0479416f5033b2f7f43bd11b6ad759f5ec98
517 B | 21 lines Raw
1
/**
2
 * Learn more about light and dark modes:
3
 * https://docs.expo.dev/guides/color-schemes/
4
 */
5

6
import { Colors } from '@/constants/theme';
7
import { useColorScheme } from '@/hooks/use-color-scheme';
8

9
export function useThemeColor(
10
  props: { light?: string; dark?: string },
11
  colorName: keyof typeof Colors.light & keyof typeof Colors.dark
12
) {
13
  const theme = 'light';
14
  const colorFromProps = props[theme];
15

16
  if (colorFromProps) {
17
    return colorFromProps;
18
  } else {
19
    return Colors[theme][colorName];
20
  }
21
}