summaryrefslogtreecommitdiff
path: root/apps/mobile/hooks/useThemeColor.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/mobile/hooks/useThemeColor.ts')
-rw-r--r--apps/mobile/hooks/useThemeColor.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/mobile/hooks/useThemeColor.ts b/apps/mobile/hooks/useThemeColor.ts
new file mode 100644
index 0000000..170a6d6
--- /dev/null
+++ b/apps/mobile/hooks/useThemeColor.ts
@@ -0,0 +1,47 @@
+import { useColorScheme } from 'react-native';
+import { Colors, type ThemeColors } from '../constants/Colors';
+
+/**
+ * Hook to get the current theme colors
+ * @returns The colors for the current color scheme
+ */
+export function useThemeColors(): ThemeColors {
+ const colorScheme = useColorScheme() ?? 'dark';
+ return Colors[colorScheme];
+}
+
+/**
+ * Hook to get a specific color from the theme
+ * @param colorName - The name of the color to retrieve
+ * @returns The color value for the current theme
+ */
+export function useThemeColor<K extends keyof ThemeColors>(
+ colorName: K
+): ThemeColors[K] {
+ const colors = useThemeColors();
+ return colors[colorName];
+}
+
+/**
+ * Hook to get multiple colors from the theme
+ * @param colorNames - Array of color names to retrieve
+ * @returns Object with requested color values
+ */
+export function useThemeColorSet<K extends keyof ThemeColors>(
+ colorNames: K[]
+): Pick<ThemeColors, K> {
+ const colors = useThemeColors();
+ return colorNames.reduce((acc, name) => {
+ acc[name] = colors[name];
+ return acc;
+ }, {} as Pick<ThemeColors, K>);
+}
+
+/**
+ * Hook to check if the current theme is dark
+ * @returns boolean indicating if dark mode is active
+ */
+export function useIsDarkMode(): boolean {
+ const colorScheme = useColorScheme();
+ return colorScheme === 'dark';
+}