forked from heyman333/react-native-responsive-fontSize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
22 lines (18 loc) · 706 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { isIphoneX } from "react-native-iphone-x-helper";
import { Platform, StatusBar, Dimensions } from "react-native";
const { height, width } = Dimensions.get("window");
export default function RF(percent, isOfWidth) {
const deviceHeight = isIphoneX()
? height - 78 // iPhone X style SafeAreaView size in portrait
: Platform.OS === "android"
? height - StatusBar.currentHeight
: height;
const deviceWidth = width;
if ((isOfWidth == undefined) || (isOfWidth == false)) {
const heightPercent = (percent * deviceHeight) / 100;
return Math.round(heightPercent);
} else {
const widthPercent = (percent * deviceWidth) / 100;
return Math.round(widthPercent);
}
}