Created
February 12, 2021 10:12
-
-
Save olanipekunife/de8b5cb18413718a6d86b0bddbc17e7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Dimensions} from 'react-native'; | |
const baseWidth = 412; | |
const baseHeight = 896; | |
const maxHeightScale = 1.1; | |
let heightScale = Dimensions.get('window').height / baseHeight; | |
let fontScale = Dimensions.get('window').height / 800; | |
if (heightScale > maxHeightScale) { | |
heightScale = maxHeightScale; | |
} | |
const widthScale = Dimensions.get('window').width / baseWidth; | |
export const getResponsiveHeight = (height) => height * heightScale; | |
export const getResponsiveWidth = (width) => width * widthScale; | |
export const getResponsiveFont = (fontSize) => fontSize * fontScale; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment