react-native-responsive-screen icon indicating copy to clipboard operation
react-native-responsive-screen copied to clipboard

Feature Request: Able to provide viewport sizes

Open quicksilverr opened this issue 3 years ago • 0 comments

Hey, a slight suggestion @marudy

If we could give the option, to provide the sizes that we get from our designs directly to the functions that would be better.

I have written like a code snippet, which would explain better.

import _ from 'lodash';
import {
  widthPercentageToDP,
  heightPercentageToDP
} from 'react-native-responsive-screen';

const VIEWPORT_HEIGHT = 828;
const VIEWPORT_WIDTH = 414;
export const wp = (width: number): number => {
  const widthPercentage = (width / VIEWPORT_WIDTH) * 100;
  return _.ceil(widthPercentage);
};

export const hp = (height: number): number => {
  const heightPercentage = (height / VIEWPORT_HEIGHT) * 100;
  return _.ceil(heightPercentage);
};

quicksilverr avatar Oct 12 '22 15:10 quicksilverr