UNPKG

react-native-full-responsive

Version:

Create a fully responsive React Native app for all supported platforms

48 lines (47 loc) 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useResponsiveMethods = exports.useRM = void 0; var _react = require("react"); var _useDevice = require("./useDevice"); var _reactNative = require("react-native"); var _layout = require("../layout"); const useResponsiveMethods = () => { const device = (0, _useDevice.useDevice)(); const { width, height } = (0, _reactNative.useWindowDimensions)(); /** * The responsive scaled size will be calculated using the passed size. * @param size * @returns scaled size, if the passed size is not a number, it will be the passed value. */ const rs = (0, _react.useCallback)(size => { return (0, _layout.responsiveScale)(size, width, height, device); }, [device, height, width]); /** * The responsive width size will be calculated using the passed percentage. * @param widthPercentage * @returns calculated size, if the passed percentage is not a number, it will be the passed value. */ const rw = (0, _react.useCallback)(widthPercentage => { return (0, _layout.responsiveWidth)(widthPercentage, width); }, [width]); /** * The responsive height size will be calculated using the passed percentage. * @param heightPercentage * @returns calculated size, if the passed percentage is not a number, it will be the passed value. */ const rh = (0, _react.useCallback)(heightPercentage => { return (0, _layout.responsiveHeight)(heightPercentage, height); }, [height]); return { rs, rw, rh }; }; exports.useRM = exports.useResponsiveMethods = useResponsiveMethods; //# sourceMappingURL=useResponsiveMethods.js.map