UNPKG

react-native-week-schedule-1

Version:
60 lines (57 loc) 1.45 kB
"use strict"; import { Platform, Dimensions, PixelRatio } from 'react-native'; export class Utils { idealWidth = 375; idealHeight = 812; _isIOS = Platform.OS === 'ios'; _size = Dimensions.get('window'); _ratio = PixelRatio.getFontScale(); get isIOS() { return this._isIOS; } get size() { return { ...this._size }; } declOfNum = (number, translates) => { const newNumber = number % 10; if (number > 10 && number < 20) { return translates[2]; } if (newNumber > 1 && newNumber < 5) { return translates[1]; } if (newNumber === 1) { return translates[0]; } return translates[2]; }; /* Scale */ scaleHorizontal = (inWidth = 1) => { const delimiter = this.idealWidth / inWidth; return this._size.width / delimiter; }; scaleVertical = (inHeight = 1) => { const delimiter = this.idealHeight / inHeight; return this._size.height / delimiter; }; scaleFontSize = (fontSize = 1) => { const divisionRatio = this.idealWidth / (fontSize / this._ratio); return this._size.width / divisionRatio; }; scaleLineHeight = (lineHeight = 1) => { const divisionRatio = this.idealHeight / (lineHeight / this._ratio); return this._size.height / divisionRatio; }; } const utils = new Utils(); export const { scaleHorizontal, scaleVertical, scaleFontSize, scaleLineHeight, size, isIOS } = utils; //# sourceMappingURL=Utils.js.map