View gist:8264796f05f45d6a657ebcef831524b2
This file contains 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
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)) | |
} |
View gist:11f600065689829e8596055a10de285d
This file contains 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 'react-native' | |
declare module 'react-native' { | |
namespace StyleSheet { | |
type Style = ViewStyle | TextStyle | ImageStyle | |
type NamedStyles<T> = { [P in keyof T]: Style } | |
/** | |
* Creates a StyleSheet style reference from the given object. | |
*/ |