Hi. You are right, I don't know how I can forgot to talk about responsiveness. I will update that soon on my repository. Here are what I do to handle that:
Avoid as much as I can "absolute" position, hard values (100, 300, 1680,...) especially for big ones.
Instead, I use flex, and % values
I have this normalize function for adapting hard values accordingly to the screen's width or height. I might upload it on the repository later:
import{Dimensions,Platform,PixelRatio}from'react-native';exportconst{width:SCREEN_WIDTH,height:SCREEN_HEIGHT}=Dimensions.get('window',);// based on iphone X's scaleconstwscale=SCREEN_WIDTH/375;consthscale=SCREEN_HEIGHT/812;exportfunctionnormalize(size,based='width'){constnewSize=based==='height'?size*hscale:size*wscale;if(Platform.OS==='ios'){returnMath.round(PixelRatio.roundToNearestPixel(newSize));}else{returnMath.round(PixelRatio.roundToNearestPixel(newSize))-2;}}
So now I can use:
// iphone Xnormalize(100)// = 100// iphone 5snormalize(100)// = maybe 80// You can choose either "width" (default) or "height" depend on cases:container={width:normalize(100,"width"),// "width" is optional, it's defaultheight:normalize(100,"height")}
Before pushing, I test my work on 3 differents emulators: iphone5s (small), iphone 8 (medium) and iphone Xs Max (big)
Hope this help :D
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi. You are right, I don't know how I can forgot to talk about responsiveness. I will update that soon on my repository. Here are what I do to handle that:
normalize
function for adapting hard values accordingly to the screen's width or height. I might upload it on the repository later:So now I can use:
Hope this help :D