UNPKG

react-native-modern-elements

Version:

A modern, customizable UI component library for React Native

10 lines (9 loc) 593 B
import { Dimensions, PixelRatio } from "react-native"; const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("window"); const [shortDimension, longDimension] = SCREEN_WIDTH < SCREEN_HEIGHT ? [SCREEN_WIDTH, SCREEN_HEIGHT] : [SCREEN_HEIGHT, SCREEN_WIDTH]; const guidelineBaseWidth = 375; const guidelineBaseHeight = 812; export const scale = (size) => Math.round(PixelRatio.roundToNearestPixel((shortDimension / guidelineBaseWidth) * size)); export const verticalScale = (size) => Math.round(PixelRatio.roundToNearestPixel((longDimension / guidelineBaseHeight) * size));