Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
duketwo opened this issue May 9, 2016 · 81 comments
Closed

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

duketwo opened this issue May 9, 2016 · 81 comments
Labels
Help Wanted :octocat: Issues ideal for external contributors. Resolution: Locked This issue was locked by the bot. Resolution: PR Submitted A pull request with a fix has been provided.

Comments

@duketwo
Copy link

duketwo commented May 9, 2016

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.

@janicduplessis
Copy link
Contributor

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

@janicduplessis janicduplessis self-assigned this May 21, 2016
@sixcircuit
Copy link

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

@timvanp
Copy link

timvanp commented Jul 20, 2016

I have the same problem, iOS works fine indeed

@nihgwu
Copy link
Contributor

nihgwu commented Jul 20, 2016

check my comments on #8627 if have any help

@ggordan
Copy link

ggordan commented Sep 1, 2016

Any updates on this?

@bhrott
Copy link

bhrott commented Sep 5, 2016

I have the same problem.

  • ReactNative 0.32
  • Android 6+

@scerelli
Copy link

scerelli commented Oct 3, 2016

Idem, same problem.

RN: 0.34

@BeckZero
Copy link

BeckZero commented Oct 6, 2016

+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

@jasongaare
Copy link
Contributor

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

@scerelli
Copy link

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

@nihgwu
Copy link
Contributor

nihgwu commented Nov 15, 2016

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

@scerelli
Copy link

scerelli commented Nov 15, 2016

@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.

@janicduplessis
Copy link
Contributor

janicduplessis commented Nov 16, 2016

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 janicduplessis removed their assignment Nov 16, 2016
@janicduplessis
Copy link
Contributor

janicduplessis commented Nov 16, 2016

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 janicduplessis added the Help Wanted :octocat: Issues ideal for external contributors. label Nov 16, 2016
@edencakir
Copy link

+1 RNv: 0.40

@Swordsman-Inaction
Copy link
Contributor

@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?

@omerdn1
Copy link

omerdn1 commented Mar 12, 2017

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

@Traviskn
Copy link

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>

@yijian166
Copy link

@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.

@AdriaRios
Copy link

Still happens at 0.43 version.

Any updates?

@gezichenshan
Copy link

Mark!

@carlesnunez
Copy link

Any updates on this?

@iamcxa
Copy link

iamcxa commented Jul 3, 2018

I confirm @Traviskn 's way too. this workaround may produce some issue at a particular scene(such as you need status bar shows more frequently than hidden), but it still may be the best way to solve modal status bar problem once for all.

@banli17
Copy link

banli17 commented Jul 17, 2018

can use origin android to resolve it ?

@ghost
Copy link

ghost commented Jul 31, 2018 via email

@jdnichollsc
Copy link

@t4deu I can see the issue with react-native 0.56.0 from Android, any solution to fix the issue of the bottom of the modal?
Thanks in advance

@jdnichollsc
Copy link

jdnichollsc commented Aug 31, 2018

Ok, fixed by using
<style name="AppTheme" parent="Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen">
instead of
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

@farzd
Copy link

farzd commented Sep 7, 2018

still an issue, using expo so cant change android specific xml files etc

@lyseiha
Copy link

lyseiha commented Sep 13, 2018

When will you fixed this issue ?

@andrewzey
Copy link

The better solution is to not use the native React Modal. Use this library instead: https://github.com/maxs15/react-native-modalbox

@anshul-kai
Copy link

There is still a problem with devices that have a soft menu bar like the Samsung Galaxy S8 and no solution solves the problem with the soft menu bar region not being drawn over by the Modal.

@wayne214
Copy link

wayne214 commented Nov 15, 2018

ok,fixed by using
<style name="AppTheme" parent="Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen"> <item name="android:windowTranslucentStatus">true</item> // 设置状态栏不占据空间 </style>

If the theme color is white, fixed by using
<style name="AppTheme" parent="Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen"> <item name="android:windowLightStatusBar">true</item> // Android 6.0以上设置白底黑字 </style>

@pablobrodt
Copy link

I used https://github.com/listenzz/react-native-modal-translucent, and worked like a charm.

settings.gradle
include ':modal-translucent'
project(':modal-translucent').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-modal-translucent/android')
build.gradle
implementation project(":modal-translucent")
MainApplication
import me.listenzz.modal.TranslucentModalReactPackage;

@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(new MainReactPackage(), ..., new TranslucentModalReactPackage());
}

@mtshrmn
Copy link

mtshrmn commented Dec 1, 2018

@pablobrodt Can you explain to me how did you make it work? I'm getting an error using the package. I've opened there a new issue.

@pablobrodt
Copy link

@Jelomite I just linked this https://github.com/listenzz/react-native-modal-translucent manually, like i said above, then used the react-native Modal with transparent prop.

@mtshrmn
Copy link

mtshrmn commented Dec 5, 2018

I see, thanks 😄

@wkmcyz
Copy link

wkmcyz commented Jan 17, 2019

I changed the default Modal implementation of react-native and solved this problem. What I do is to replace the official Modal package with one a-little-modified Modal package which shows Modal in full screen with status bar above, you can refer to https://www.cnblogs.com/wkmcyz/articles/10277436.html for details.

scottmas added a commit to scottmas/react-native that referenced this issue Jan 24, 2019
This fixes the longstanding issue highlighted at this issue: facebook#7474

A janky postinstall fix making this exact change is quite popular on NPM, demonstrating that there's a clear need for this (see https://www.npmjs.com/package/react-native-modal-translucent)
@nihp
Copy link

nihp commented Aug 20, 2019

I need to hide the iOS status bar of my app in some screens and not for all screens. Any solution for this.

I tried this but it did not work for me.

<StatusBar hidden={true} />

@arfa123
Copy link

arfa123 commented Aug 31, 2019

Still happening in RN 0.60.5.

@arfa123
Copy link

arfa123 commented Aug 31, 2019

react-native-modal-translucent solved my problem https://github.com/listenzz/react-native-modal-translucent

@joaodematejr
Copy link

+1

2 similar comments
@cristianoccazinsp
Copy link
Contributor

+1

@snamstorm
Copy link

+1

@AndreyPatseiko
Copy link

@facebook facebook locked as resolved and limited conversation to collaborators Dec 11, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Help Wanted :octocat: Issues ideal for external contributors. Resolution: Locked This issue was locked by the bot. Resolution: PR Submitted A pull request with a fix has been provided.
Projects
None yet
Development

Successfully merging a pull request may close this issue.