eletrotupi / tcc/ commit / 98f51d9

frontend: let useThemeColor accept any light-palette key

Pedro Lucas Porcellis porcellis@eletrotupi.com · 12 days ago 98f51d926694a10e1a4625987f1b32e03ec683da Browse files
Parents d57731d
Changed files
1
Additions
+1
Deletions
-1
frontend/hooks/use-theme-color.ts
1 1
/**
2 2
 * Learn more about light and dark modes:
3 3
 * https://docs.expo.dev/guides/color-schemes/
4 4
 */
5 5

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

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

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