summaryrefslogtreecommitdiffstats
path: root/hooks/use-theme-color.ts
diff options
context:
space:
mode:
Diffstat (limited to 'hooks/use-theme-color.ts')
-rw-r--r--hooks/use-theme-color.ts21
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];
+ }
+}