-
-
Save femicodes/f83e3089886683d8a9a43dd0811eeb1c 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
const widthPercentageToDP = widthPercent => { | |
const screenWidth = Dimensions.get('window').width; | |
const elemWidth = parseFloat(widthPercent); | |
return PixelRatio.roundToNearestPixel(screenWidth * elemWidth / 100); | |
}; | |
const heightPercentageToDP = heightPercent => { | |
const screenHeight = Dimensions.get('window').height; | |
const elemHeight = parseFloat(heightPercent); | |
return PixelRatio.roundToNearestPixel(screenHeight * elemHeight / 100); | |
}; | |
const proportionedPixel = designPixels => { | |
const screenProportion = Dimensions.get('window').width / 180; | |
return PixelRatio.roundToNearestPixel(designPixels * screenProportion); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment