Skip to content

Instantly share code, notes, and snippets.

@sakymar
Created September 16, 2022 22:25
Show Gist options
  • Save sakymar/8264796f05f45d6a657ebcef831524b2 to your computer and use it in GitHub Desktop.
Save sakymar/8264796f05f45d6a657ebcef831524b2 to your computer and use it in GitHub Desktop.
export const SCREEN_WIDTH = Dimensions.get('window').width
export const SCREEN_HEIGHT = Dimensions.get('window').height
// based on iphone 11 pro's scale
const scale = SCREEN_WIDTH / 375
const scaleHeight = SCREEN_HEIGHT / 812
export const normalize = (size: number, forHeight?: boolean) => {
const newSize = size * (forHeight ? scaleHeight : scale)
return Math.round(PixelRatio.roundToNearestPixel(newSize))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment