Answers for "get status bar height react native"

0

get status bar height react native

import {NativeModules} from 'react-native';
const {StatusBarManager} = NativeModules;
const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? 20 : StatusBarManager.HEIGHT;
Posted by: Guest on July-21-2021
1

react native ios status bar height

// You can use this helper function which enables you to get the 
// Status Bar height on iOS and Android. For iOS, the calculation 
// is done to get the different StatusBar height when >= iPhone X 
// (with notch) is used.

// functions-file.js
import { Dimensions, Platform, StatusBar } from 'react-native';
const X_WIDTH = 375
	, X_HEIGHT = 812
	, XSMAX_WIDTH = 414
	, XSMAX_HEIGHT = 896
	, { height, width } = Dimensions.get('window')

export const isIPhoneX = () => Platform.OS === 'ios' && !Platform.isPad && !Platform.isTVOS
    ? width === X_WIDTH && height === X_HEIGHT || width === XSMAX_WIDTH && height === XSMAX_HEIGHT
    : false;
export const StatusBarHeight = Platform.select({
    ios: isIPhoneX() ? 44 : 20,
    android: StatusBar.currentHeight,
    default: 0
})

//Then use it directly when imported:
import { StatusBarHeight } from './functions-file.js'
height: StatusBarHeight
Posted by: Guest on August-09-2021

Code answers related to "get status bar height react native"

Code answers related to "Javascript"

Browse Popular Code Answers by Language