Skip to content

Instantly share code, notes, and snippets.

View neyron163's full-sized avatar
:octocat:
Focusing

Andrew neyron163

:octocat:
Focusing
View GitHub Profile
@neyron163
neyron163 / scaleSize.js
Last active March 21, 2024 07:51
React native font scaling all devices, iphone, android
// This code enables the adaptation of interface element sizes to different screen sizes and font scales,
// using units of measurement that are independent of pixel density.
// This ensures a more consistent and pleasant user experience when using the application.
import { Dimensions, PixelRatio } from 'react-native';
// TARGET_WIDTH signifies the base screen size to which the application adapts.
// The standard screen width for development: 375 dp is often used as the standard screen width for developing interfaces, as it corresponds to the screen size of iPhone 6/7/8 Plus.
// This makes it a good base value for creating an adaptive design that will look good on most modern smartphones.
// PS - You don't need to worry about other iPhones; we've tested on 6s, 8, 10, 14 as well as on several Androids realme 11, gtneo2, samsung s23..., and everything works well.
const TARGET_WIDTH = 375;