1.3.1 • Published 5 years ago

react-native-iphone-x-helper v1.3.1

Weekly downloads
394,684
License
MIT
Repository
github
Last release
5 years ago

npm version

react-native-iphone-x-helper

A library to help you design your react-native app for notched iPhones.

Installing

npm i react-native-iphone-x-helper --save

API

ifIphoneX(iphoneXStyle, [regularStyle])

this method it for creating stylesheets with the iPhone X in mind

Parameters

iphoneXStyle - the style to apply if you're on iPhone X

regularStyle (optional) - the style to apply if you're not on iPhone X

Example

// in style.js

import { StyleSheet } from 'react-native';
import { ifIphoneX } from 'react-native-iphone-x-helper'

export default StyleSheet.create({
    header:{
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        padding:10,
        height: 60,
        backgroundColor: 'transparent',
        ...ifIphoneX({
            paddingTop: 50
        }, {
            paddingTop: 20
        })
    },
});

isIphoneX()

returns - true if you running on an iPhone X.

Example

import { isIphoneX } from 'react-native-iphone-x-helper'

// ...

if (isIphoneX()) {
    // do this...
} else {
    // do that...
}

getStatusBarHeight(safe)

Parameters

safe - whether you want for get safe area height or not

returns - the height of the status bar: 44 for safe iPhoneX, 30 for unsafe iPhoneX, 20 for other iOS devices and StatusBar.currentHeight for Android.

Example

// in style.js

import { StyleSheet } from 'react-native';
import { getStatusBarHeight } from 'react-native-iphone-x-helper'

export default StyleSheet.create({
    header:{
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        padding:10,
        height: 60,
        backgroundColor: 'transparent',
        paddingTop: getStatusBarHeight()
    },
});

NOTE: If your using the the unsafe statusbar height, make sure to add 14dp of padding to your content, otherwise it's going to be flush against the notch

getBottomSpace

returns - the height of the bottom to fit the safe area: 34 for iPhone X and 0 for other devices.

Example

// in style.js

import { StyleSheet } from 'react-native';
import { getBottomSpace } from 'react-native-iphone-x-helper'

export default StyleSheet.create({
    totalview: {
        flex: 1,
        backgroundColor: 'transparent',
        marginBottom: getBottomSpace()
    },
});

Licence

MIT

react-native-kyybarn-gifted-chat-gitmiot-workspace@platformbuilders/react-native-chatbot@ubaids/react-native-gifted-chatekyc-video-call@belkalab/fic-rn-design-system-storybook@summerkiflain/react-navigation-addon-search-layoutreact-native-in-app-notification-forki-invest-wealthreact-native-tc-conversations-testmira-test-3tinh-mirareact-native-isw-starterreact-native-todocu-chatreact-native-gifted-chat-ac@gimwee81/react-native-gifted-chatreact-native-nuno-uiairmoddictionarymacmillandice-ui@harvestwm/rn-component-libwilscanner@ckbab/react-native-componentsrn-vantreact-native-template-spaceship@infinitebrahmanuniverse/nolb-react-native-i@sdv-streaming/mobilereact-native-gifted-chat-18@everything-registry/sub-chunk-2581@bobbyecho/react-native-humanid@synctree/react-native-keyboard-aware-scroll-viewsyntx-chatsw-react-native-country-picker-modalwhitetown-uiwonderpool-app-driverwonderpool-app-riderwm-react-native-componentswm-react-native-routerwuba-design@drivekyte/react-native-flash-message@cuongweallnet/rn-gifted-chat@cutls/react-native-tiny-toast@connectedbits/react-native-paper@cookiespam/react-native-gifted-chat@blueromans/react-native-ui-kit@belkalab/fic-rn-design-system@rbl93/react-native-keyboard-aware-scroll-viewjingtestjb-commonslapanoid-storybook-react-native@changanauto-sda/rn-uireact-native-livelo-componentsreact-native-storybok-atomic-templatesteste-react-navigation-collapsibletmt-react-native-gifted-chattrudenty-rn-sdktsnodist@anastely/rn-gifted-chat@atomic-space-component-library/buttons@admond/react-native-paper@ahmedfouad2255/react-native-gifted-chat@aexer/react-native-gifted-chat@alaneu/react-native-gifted-chat@baijiayunwangxiao/reactnav-bottom-tabs@baijiayunwangxiao/reactnav-stack@beaudinn/react-native-gifted-chat@beatjs/react-native-keyboard-aware-scroll-view@beatjs/react-native-skeleton-placeholder@blackdice/storybook-react-native@bibletags/bibletags-react-native-app@betonyou/react-navigation-stack@bumbag-native/toast@bravemobile/react-native-gifted-chat@chatkitty/react-native-in-app-notification@cloud-varejo/cloud-varejo-ui@2060.io/react-native-gifted-chat588middleware58middleware@5stones/react-navigation-collapsible@codler/react-native-keyboard-aware-scroll-view@codingitwrong/react-native-paper@deelzat/react-native-gifted-chatusechatzippi-market-core@hammadj/react-native-gifted-chat@e-linter/react-navigation-tabs@dytesdk/mobile@force-dev/react-mobile@foreword/react-native-gifted-chat@hproinformatica/react-native@haflinger/react-native-gifted-chat@hatkom/react-native-gifted-chat@hinh-eoh/test_publish@human-id/react-native-humanid@human-internet/react-native-humanid@ignaciofalco/react-native-gifted-chat@fto-consult/expo-ui@lephanvy/react-native-paper@mecute/design
1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

6 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago