NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Header Component StatusBar overlap on Android

Open stolinski opened this issue 9 years ago • 17 comments

I'm having the exact same issues that this user is. https://stackoverflow.com/questions/42098186/nativebase-exponent-header

RN v. 0.44.0 NativeBase 2.1.4

stolinski avatar May 29 '17 23:05 stolinski

This is not related to NativeBase Check with Expo

SupriyaKalghatgi avatar Jun 06 '17 10:06 SupriyaKalghatgi

@SupriyaKalghatgi Expo simply sets the statusbar to translucent by default - NativeBase is not correctly handling this.

brozef avatar Jun 21 '17 05:06 brozef

@stolinski @JoeNimble I checked the expo link for NativeBase-KitchenSink, https://exp.host/@geekyants/nativebase-kitchenSink And this is what I found

screenshot_20170621-114656

SupriyaKalghatgi avatar Jun 21 '17 06:06 SupriyaKalghatgi

@SupriyaKalghatgi I will have to assume that app is not using translucent, or has styles set to handle padding. I just tested with just now with completely raw and latest NativeBase and setting the statusbar color in the app.json (expo.json) which makes it opaque vs no color (translucent). statusbar

brozef avatar Jun 21 '17 06:06 brozef

@SupriyaKalghatgi I downloaded the kitchensink and it is not using a translucent statusbar - notice how the drawer and content is not rendering under it: screenshot_20170621-163100

brozef avatar Jun 21 '17 06:06 brozef

Hey @JoeNimble! All the native-base components are developed using plain react-native in a react-native environment. And it works pretty well in plain react-native. So we'd like to believe it's indeed related to Expo and not native-base. As a workaround, you can try using "androidStatusBarColor": "rgba(0,0,0,0.5)" in your app.json.

sankhadeeproy007 avatar Jun 21 '17 06:06 sankhadeeproy007

@sankhadeeproy007 unfortunately setting the StatusBar color to an rgba value doesn't work. Have you tried a translucent StatusBar in plain react-native?

I am in contact with the Expo developers and i assure you, Expo isn't effecting the statusbar or android view in any way other than setting it to be translucent which is now the standard look on android. Plain react native does not set the StatusBar to be translucent by default, but it is a feature available to use.

At this stage the only way around this with NativeBase is to set padding - either on the header or other containing component - to include the StatusBar height (StatusBar.currentHeight)

brozef avatar Jun 22 '17 00:06 brozef

@JoeNimble I understand your point and I'm in no way blaming Expo. My point is, native-base was built keeping vanilla react-native in mind and Expo came much later. Hence the difference. If the solution is as simple as adding a padding to the Header, then we'll add that.

sankhadeeproy007 avatar Jun 23 '17 08:06 sankhadeeproy007

@sankhadeeproy007 it's certainly not a big problem, I think the biggest issue with providing a proper solution is knowing whether the statusbar is translucent or not - I don't believe react native provides a function for this - therefore adding padding is most likely up to each developer.

brozef avatar Jul 07 '17 06:07 brozef

This should solve the problem for android

in app.json

"androidStatusBarColor": "#334393", "androidStatusBar": { "barStyle": "light-content", "backgroundColor": "#334393" }

anilpatnik avatar Aug 28 '17 10:08 anilpatnik

@anilpatnik, I still see the issue. Here is my app.json

{
  "expo": {
    "sdkVersion": "20.0.0"
  },
  "androidStatusBarColor": "#334393",
  "androidStatusBar": {
    "barStyle": "light-content",
    "backgroundColor": "#334393"
  }
}

ramusbucket avatar Sep 01 '17 14:09 ramusbucket

@ramusbucket you can overcome this issue by increasing the height of the Header and adding a top padding.

If you have ejected the theme, you can set paddingTop as paddingTop: platform === "ios" ? (variables.isIphoneX ? 39 : 15) : 0 + StatusBar.currentHeight in /native-base-theme/components/Header.js

and based on the theme selected you can set toolbarHeight as toolbarHeight: platform === "ios" ? (isIphoneX ? 88 : 64) : (56 + StatusBar.currentHeight) in commonColor.js/material.js/platform.js in /native-base-theme/variables

akhil-ga avatar Nov 14 '17 05:11 akhil-ga

#1046

SupriyaKalghatgi avatar Nov 16 '17 07:11 SupriyaKalghatgi

Closing this due to inactivity

SupriyaKalghatgi avatar Jan 04 '18 15:01 SupriyaKalghatgi

Using https://www.npmjs.com/package/react-native-status-bar-height to get status bar height and it works like a charm!

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  header: {
    paddingTop: getStatusBarHeight(),
    height: 54 + getStatusBarHeight(),
  },
});

Almaju avatar Feb 01 '18 01:02 Almaju

@Almaju this works great!

mathiscode avatar Feb 03 '18 03:02 mathiscode

I don't know if this is still an issue for anyone, but this did the trick for me:

{
  "expo": {
    "androidStatusBar": {
      "backgroundColor": "#000000"
    }
  }
}

Peeeep avatar Mar 26 '18 20:03 Peeeep