react-native-status-bar-size icon indicating copy to clipboard operation
react-native-status-bar-size copied to clipboard

[RFC] Can I drop statusBar*WillChange and add an API directly to react-native?

Open dantman opened this issue 6 years ago • 1 comments

I'd like to make a change to react-native that will fix an issue with the current iOS status bar height calculation and expose an API as part of react-native.

  • The undocumented NativeModules.StatusBarManager.getHeight is going to go away and the format of the statusBarFrameDidChange event will change, so this library will break. But there will be an API that replaces in in react-native itself.
  • I am not going to include the x and width frame properties, usage of them doesn't make sense and keeping them makes doing this cross-platform a mess (They are basically always x=0 and width=viewport.width; and because Android only has a status bar height definition I'd have to overcomplicate the Android StatusBarManager to also lookup screen width for something no-one would use)
  • The problem with height calculation is that the In-Call Status Bar is declared by iOS as making the StatusBar 40px, however when that happens iOS actually pushes the app down 20px. In other words the app still has only 20px to care about. This is an issue now because iPhone X has a 44px Status Bar and we need a native way of exposing this and on top of that iOS 11 has a new behaviour where the Status Bar height is 0 in landscape mode. I found a way to fix this by subtracting the y offset of the root view. However this cannot be done before the status bar actually changes, so I have to drop the statusBarFrameWillChange event.
    • If you explicitly want the actual height of the Status Bar instead of the height of the overlap you have to deal with that is still possible, I expose the y offset as well so you just have to frame.y + frame.height and you'll get the value you had before.

Does this sound ok?

dantman avatar Oct 20 '17 20:10 dantman

@dantman It sounds OK to me, but it seems there are some other issues with the change you have made on react-native. Anyway, thank you for your efforts. I will look forward to seeing that merged.

jgkim avatar Nov 25 '17 06:11 jgkim