rn-custom-style-sheet
Version:
React Native component to select a specific value from a range of values.
38 lines • 1.69 kB
JavaScript
import { useMemo } from 'react';
import { ThemeModeEnum, OrientationEnum, useCurrentOrientation, useDeepCompareMemo, useGuideLineBreakpoint, useGuideLineLayout, useScreenResolution, useCurrentBreakpointIndex, useGeneralScreenResolution } from '../../../Core';
import { useDevice } from '../../../MediaQuery';
import { useCurrentThemeMode } from '../UseCurrentThemeMode';
import { useCurrentThemeName } from '../UseCurrentThemeName';
export default function useTheme(styleSheetFn, device) {
const themeName = useCurrentThemeName();
const themeMode = useCurrentThemeMode();
const screenResolution = useScreenResolution();
const guideLineLayout = useGuideLineLayout();
const guideLineBreakpoint = useGuideLineBreakpoint();
const generalScreenResolution = useGeneralScreenResolution();
const localDevice = useDevice();
const orientation = useCurrentOrientation();
const currentBreakpointIndex = useCurrentBreakpointIndex();
const isDark = useMemo(() => themeMode === ThemeModeEnum.Dark, [themeMode]);
const isPortrait = useMemo(() => orientation === OrientationEnum.Portrait, [orientation]);
const styles = useDeepCompareMemo(() => styleSheetFn?.({
isDark,
isPortrait,
themeName,
themeMode,
screenResolution,
guideLineLayout,
guideLineBreakpoint,
generalScreenResolution,
device: device ?? localDevice,
currentBreakpointIndex
}) ?? {}, [isDark, isPortrait, themeName, themeMode, screenResolution, guideLineLayout, guideLineBreakpoint, generalScreenResolution, device, localDevice, currentBreakpointIndex]);
return {
styles,
themeName,
themeMode,
isDark,
isPortrait
};
}
//# sourceMappingURL=UseTheme.js.map