UNPKG

rn-custom-style-sheet

Version:

React Native component to select a specific value from a range of values.

29 lines 1.43 kB
import { useEffect } from 'react'; import { ReducerEventEnum } from '../../Reducer'; import { listenOrientationChange, removeOrientationListener } from './UseDeviceOrientationUtils'; import { getCurrentBreakpointIndex } from '../../../BreakPoint'; import { getGeneralScreenResolution } from '../UseGeneralScreenResolution'; export default function useDeviceOrientation(dispatch, isSupportedOrientation, values, withPortraitBehaviorInLandscapeMode, guideLineLayout, baseSizeLayout) { useEffect(() => { let subscription; if (isSupportedOrientation) { subscription = listenOrientationChange(withPortraitBehaviorInLandscapeMode, screenConfig => { dispatch({ type: ReducerEventEnum.ChangeResolution, payload: { currentBreakpointIndex: getCurrentBreakpointIndex(values, screenConfig.screenResolution.windowWidth), orientation: screenConfig.orientation, screenResolution: screenConfig.screenResolution, generalScreenResolution: getGeneralScreenResolution(screenConfig.screenResolution, guideLineLayout, baseSizeLayout) } }); }); } return () => { removeOrientationListener(subscription); subscription = undefined; }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [isSupportedOrientation, values, guideLineLayout, baseSizeLayout]); } //# sourceMappingURL=UseDeviceOrientation.js.map