react-native-pure-dimension

0.0.9 • Public • Published

react-native-pure-dimension

This is a module which help you get screen dimension info.

Installation

npm i react-native-pure-dimension
// link below 0.60
react-native link react-native-pure-dimension

Setup

iOS

modify AppDelegate.m

#import <RNTDimension.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  // add this line
  [RNTDimension bind:rootView];
  return YES;
}

Android

nothing to do.

Usage

import dimension, {
  STATUS_BAR_HEIGHT,
  NAVIGATION_BAR_HEIGHT,
  SCREEN_WIDTH,
  SCREEN_HEIGHT,
  SAFE_AREA_TOP,
  SAFE_AREA_BOTTOM,
  SAFE_AREA_LEFT,
  SAFE_AREA_RIGHT,
} from 'react-native-pure-dimension'

// If the size stays the same(such as you don't rotate your phone), you can use the constants.
// Otherwise, you should get the latest size by the methods below.

dimension.getStatusBarHeight().then(data => {
  data.height
})

dimension.getNavigationBarHeight().then(data => {
  data.height
})

dimension.getScreenSize().then(data => {
  data.width
  data.height
})

dimension.getSafeArea().then(data => {
  data.top
  data.right
  data.bottom
  data.left
})

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i react-native-pure-dimension

      Weekly Downloads

      3

      Version

      0.0.9

      License

      MIT

      Unpacked Size

      22.7 kB

      Total Files

      11

      Last publish

      Collaborators

      • musicode