diff options
| author | jciespuertodelacruz <jc.iespuertodelacruz@gmx.es> | 2026-01-20 08:49:52 +0000 |
|---|---|---|
| committer | jciespuertodelacruz <jc.iespuertodelacruz@gmx.es> | 2026-01-20 08:49:52 +0000 |
| commit | c6f2b6f85d151d6d2a2cc68eb05edd7a1e448106 (patch) | |
| tree | 1080219bee426d5d1372da6c31f138482c1544d7 /hooks/use-theme-color.ts | |
Initial commit
Generated by create-expo-app 3.5.3.
Diffstat (limited to 'hooks/use-theme-color.ts')
| -rw-r--r-- | hooks/use-theme-color.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/hooks/use-theme-color.ts b/hooks/use-theme-color.ts new file mode 100644 index 0000000..0cbc3a6 --- /dev/null +++ b/hooks/use-theme-color.ts @@ -0,0 +1,21 @@ +/** + * Learn more about light and dark modes: + * https://docs.expo.dev/guides/color-schemes/ + */ + +import { Colors } from '@/constants/theme'; +import { useColorScheme } from '@/hooks/use-color-scheme'; + +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]; + } +} |