Created
May 31, 2020 18:39
-
-
Save ankurg22/edbff5cdb9be6e1dd34d8be7920738c0 to your computer and use it in GitHub Desktop.
React native responsive layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Author: Ankur Gupta(ankurg22) | |
*/ | |
import { | |
widthPercentageToDP as wp2dp, | |
heightPercentageToDP as hp2dp, | |
} from '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 + '%'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment