react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Modal-StatusBar-Android] Statusbar shows up with setHidden(true)

Open duketwo opened this issue 10 years ago • 81 comments

While the modal component is open on an android device with StatusBar.setHidden(true) the StatusBar still shows up.

Is this intended? If yes, is there any workaround?

Edit: On iOS the StatusBar remains hidden when a modal component is open.

duketwo avatar May 09 '16 16:05 duketwo

Looks like a bug, I never tested StatusBar + Modal, I'll take a look at it when I get some time.

janicduplessis avatar May 12 '16 08:05 janicduplessis

Any idea about this? I lose background color and translucent properties as well. It looks pretty bad.

sixcircuit avatar Jul 17 '16 06:07 sixcircuit

I have the same problem, iOS works fine indeed

timvanp avatar Jul 20 '16 09:07 timvanp

check my comments on #8627 if have any help

nihgwu avatar Jul 20 '16 15:07 nihgwu

Any updates on this?

ggordan avatar Sep 01 '16 10:09 ggordan

I have the same problem.

  • ReactNative 0.32
  • Android 6+

bhrott avatar Sep 05 '16 20:09 bhrott

Idem, same problem.

RN: 0.34

scerelli avatar Oct 03 '16 14:10 scerelli

+1. RN: 0.34

Component 01 (showBar Hide):

componentWillUnmount() {
  StatusBar.setHidden(true)
}

TO

Component 02:

componentWillMount() {
  StatusBar.setHidden(false)
}

result: ShowBar SHOW

But

Component 01 (showBar Hide):

componentWillUnmount() {
  AppActions.showBar(true)
}

TO

Component 02:

componentDidMount() {
  AppActions.showBar(false)
}

result: ShowBar HIDE

BeckZero avatar Oct 06 '16 19:10 BeckZero

Also noticed that if you highlight some text in the modal, the 'Text Selection' menu has a very undesirable transparent look that shows the view below.

Any ideas how to fix this appearance?

Screen shot:

screen shot

jasongaare avatar Nov 07 '16 16:11 jasongaare

It's amazing that this issue was opened the May 9th and nobody still figured out why it has this behaviour!

scerelli avatar Nov 15 '16 16:11 scerelli

@scerelli I've answered months ago to see my answer in #8627, so why this issue is still opening?

nihgwu avatar Nov 15 '16 22:11 nihgwu

@nihgwu honestly i don't know, and the fact that you explained the cause of this problem in an other issue it's even stranger. This fix/feature is not in roadmap at the moment and it's not good at all! it brings a lot of inconsistency inside applications that use a lot of modals and requires the status bar to be hidden.

scerelli avatar Nov 15 '16 23:11 scerelli

There are still cases where the statusbar is not updated properly because the activity was null at the time it was updated, I think this happens mostly when moving the app from the background to foreground. I haven't really hit this issue yet since I'm not changing the statusbar much in my apps so I don't have a repro case to try to fix it. If someone wants to spend some time looking into why it happens and possible fixes it would be great.

A quick fix I can think of would be to subscribe to AppState and force an update of the statusbar native values at that time when we are sure the activity is available.

Edit: confused some issues not sure about this one :)

janicduplessis avatar Nov 16 '16 00:11 janicduplessis

I don't have much time to look into this at the moment, I suspect we'd want to change the dialog window flags to match the current statusbar config. We already set some flags here https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java#L199

To do that we could try to read flags from the main app window and use the same for the modal.

janicduplessis avatar Nov 16 '16 00:11 janicduplessis

+1 RNv: 0.40

edencakir avatar Feb 11 '17 09:02 edencakir

@janicduplessis I already checked this issue. The reason it doesn't work is because WindowInsets is been set to the wrong window. Modal is implemented with Dialog, Dialog will create a window on the top of Activity's Window. So it won't work for now. But I couldn't find a good way to get the Window of Dialog, do you have any idea?

Swordsman-Inaction avatar Feb 23 '17 10:02 Swordsman-Inaction

Any news about this issue? Still getting it with RN 0.4.2

omerdn1 avatar Mar 12 '17 02:03 omerdn1

I was able to work around this issue by going into my app's android/app/src/main/res/values/styles.xml file and changing the parent theme to Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen. This essentially disables the status bar by default for your entire app, including for the modal. If you have other screens that need to show the status bar then you can still use the normal StatusBar api to show it if you want.

Here's my full styles.xml file for reference:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen">
        <!-- Customize your theme here. -->
    </style>
    <style name="AppTheme.Launcher">
        <item name="android:windowBackground">@drawable/launch_screen</item>
    </style>
</resources>

Traviskn avatar Mar 23 '17 18:03 Traviskn

@Traviskn This solution also has a issue, in some time, at bottom of the Modal has a transparent bar , and height equal to StartBar height.

yijian166 avatar Apr 09 '17 03:04 yijian166

Still happens at 0.43 version.

Any updates?

AdriaRios avatar Apr 26 '17 14:04 AdriaRios