1.3.1 • Published 3 years ago

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

Weekly downloads
394,684
License
MIT
Repository
github
Last release
3 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-view@fto-consult/expo-uizippi-market-corewm-react-native-componentswm-react-native-routerwhitetown-uiusechattrudenty-rn-sdk@hammadj/react-native-gifted-chatrn-falcon-gifted-chatrn-plat-envsrn-hglrn-slideshowrn-smart-action-sheetrn-smart-alertrn-utilitiesrn-vant-hyjsharecare-react-native-gifted-chatshow_in_app_notificationssme-react-native-gifted-chat@imatis/react-native-gifted-chatsteste-react-navigation-collapsiblesw-react-native-country-picker-modaltsnodistwuba-designwonderpool-app-driverwonderpool-app-rider@lephanvy/react-native-paperexpando-react-native-in-app-notificationds-rn-test@hinh-eoh/test_publish@hproinformatica/react-native@human-internet/react-native-humanid@human-id/react-native-humanidgo-digital-elements@moobiapp/react-native-woointro@mecute/design@meevilabs/react-native-elementsfsc-react-native-keyboard-aware-scroll-view@matoz/react-native-gifted-chat@mtourj/react-native-keyboard-aware-scroll-view@natuanorg/rn-custom-keyboard@ndl_studio/react-native-gifted-chat@nlabs/storybook-react-nativegia-framework@newagebel/react-native-keyboard-aware-scroll-viewexpo-inputsexpo-image-crop-new-pbexpo-image-crop-v2expo-image-cropexpo-image-crop-epaperexpo-image-crop-fixedexpo-swiftlistexpo-can-cropperexpo-data-forms@kbhardwaj/react-native-gifted-chatilosamos-react-native-gifted-chat@dytesdk/mobilehaba-chat-ui@raydeck/react-native-gifted-chat@react-native-solutions/react-native-keyboard-aware-scroll-view@e-linter/react-navigation-tabs@haflinger/react-native-gifted-chat@ignaciofalco/react-native-gifted-chat@jielu/react-native-gifted-chat@rafikitiki/react-native-paper@qudian_mobile/qd-react-native-tool-kit@peppas/topichouse-middleware-sdk
1.3.1

3 years ago

1.3.0

4 years ago

1.2.1

5 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago