Provide solutions to make your app flexible for different screen sizes, different devices.
npm install react-native-utils-scale$ yarn add react-native-utils-scale
$ cd ios && pod install && cd ../
javascriptimport React from 'react';
import {SafeAreaView, ScrollView, StyleSheet, Text, View} from 'react-native';
import {
dimensionsScale,
isAndroid,
isIOS,
hasNotch,
isTablet,
isSmallDevice,
getDeviceInch,
} from 'react-native-utils-scale';
const {scale, fontScale, deviceWidth, deviceHeight} = dimensionsScale;
const App = () => {
return (
Device width: {deviceWidth()}
Device height: {deviceHeight()}
Device inch: {getDeviceInch()}
isAndroid: {isAndroid().toString()}
isIOS: {isIOS().toString()}
isTablet: {isTablet().toString()}
hasNotch: {hasNotch().toString()}
isSmallDevice: {isSmallDevice().toString()}
150x150
Scale: {scale(150)}x{scale(150)}
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
fontScale: {
fontSize: fontScale(16),
},
box: {
width: 150,
height: 150,
backgroundColor: 'black',
alignItems: 'center',
justifyContent: 'center',
margin: 16,
},
scale: {
width: scale(150),
height: scale(150),
},
color: {
color: 'white',
},
});
export default App;
``