UNPKG

@oxyhq/services

Version:

OxyHQ Expo/React Native SDK — UI components, screens, and native features

29 lines (26 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useColorScheme = useColorScheme; var _react = require("react"); var _reactNative = require("react-native"); var _ThemeContext = require("../context/ThemeContext.js"); /** * Hook to get the current color scheme (theme). * Returns the resolved theme from ThemeContext if available, otherwise falls back to React Native's useColorScheme. * * Always calls hooks in the same order to maintain React hook rules. */ function useColorScheme() { // Always call hooks in the same order - never conditionally const rnColorScheme = (0, _reactNative.useColorScheme)(); const themeContext = (0, _react.useContext)(_ThemeContext.ThemeContext); // If ThemeContext is available, use it; otherwise fall back to React Native's color scheme if (themeContext?.resolvedTheme) { return themeContext.resolvedTheme; } // Fall back to React Native's color scheme detection return rnColorScheme ?? 'light'; } //# sourceMappingURL=useColorScheme.js.map