-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdimensions.js
34 lines (30 loc) · 953 Bytes
/
dimensions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* Author: Sethu kumar
*/
import { Dimensions } from 'react-native';
import {
widthPercentageToDP as wp2dp,
heightPercentageToDP as hp2dp,
} from './npm-helper/react-native-responsive-screen';
/**
* Width-Percentage
* Converts width dimension to percentage
* 360, 760 - design were made using this scale
* @param dimension directly taken from design wireframes
* @returns {string} percentage string e.g. '25%'
*/
export const wp = dimension => {
return wp2dp((dimension / 360) * 100 + '%');
};
/**
* Height-Percentage
* Converts width dimension to percentage
* * 360, 760 - design were made using this scale
* @param dimension directly taken from design wireframes
* @returns {string} percentage string e.g. '25%'
*/
export const hp = dimension => {
return hp2dp((dimension / 760) * 100 + '%');
};
export const windowWidth = wp(Dimensions.get('window').width);
export const windowHeight = hp(Dimensions.get('window').height);