rn-custom-style-sheet
Version:
React Native component to select a specific value from a range of values.
33 lines (30 loc) • 1.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getGeneralScreenResolution = getGeneralScreenResolution;
var _reactNative = require("react-native");
function getGeneralScreenResolution(screenResolution, guideLineLayout, baseSizeLayout) {
const baseWidth = screenResolution.shortDimension / guideLineLayout.width;
const baseHeight = screenResolution.longDimension / guideLineLayout.height;
// Calculate the base size by averaging the base width and base height.
const baseSizeRatio = (baseWidth + baseHeight) / 2;
// Consider 1.2 as a threshold for identifying tablets based on analyzing multiple devices.
const isIPad = _reactNative.Platform.OS === 'ios' && _reactNative.Platform.isPad;
const isTablet = isIPad || baseSizeRatio > (baseSizeLayout?.androidTabletRatio ?? 1.2);
let threshold = isTablet ? baseSizeLayout?.thresholdOfTablet ?? 0.4 : baseSizeLayout?.thresholdOfPhone ?? 0.5;
if (baseSizeLayout?.thresholdFunction) {
threshold = baseSizeLayout.thresholdFunction(baseSizeRatio, isTablet);
}
// Adjust the base size based on whether the device is identified as a tablet or not.
const baseSizeWithThreshold = (baseWidth + baseHeight) * threshold;
return {
baseWidth,
baseHeight,
isTablet,
threshold,
baseSizeRatio,
baseSizeWithThreshold
};
}
//# sourceMappingURL=GeneralScreenResolutionUtils.js.map