Giter Site home page Giter Site logo

Comments (74)

ifsnow avatar ifsnow commented on May 12, 2024 237

statusBarTranslucent property has been added to Modal of RN 0.62

<Modal ... statusBarTranslucent>...</Modal>

I think this problem has been solved. :)

from react-native-modal.

gasparteixeira avatar gasparteixeira commented on May 12, 2024 70

@mmazzarolo and @Stophface I put it in Modal from react-modal-native

<Modal
            isVisible={this.state.isModalVisible}
            backdropColor='transparent'
            transparent={false}
            style={styles.modalContent}>

from react-native-modal.

callmejm avatar callmejm commented on May 12, 2024 67

StatusBar put inside Modal wrap from a View worked for me

  <Modal>
    <View>
      <StatusBar backgroundColor="rgba(0,0,0,0.7)"  barStyle="light-content"/>
    </View>
  </Modal>

from react-native-modal.

viktor992 avatar viktor992 commented on May 12, 2024 52

In my case, the solution was to use the coverScreen and deviceHeight props in the following way:

<Modal
  isVisible={isVisible}
  backdropOpacity={0.9}
  backdropColor="white"
  animationIn="fadeIn"
  animationOut="fadeOut"
  coverScreen={false}
  deviceHeight={Dimensions.get('screen').height}
>
    {/* CONTENT */}
</Modal>

from react-native-modal.

listenzz avatar listenzz commented on May 12, 2024 31

I had fix this issue

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

from react-native-modal.

gasparteixeira avatar gasparteixeira commented on May 12, 2024 20

Hey Guys,

I had same problem. I just put this transparent={false} props and everything is working on Android.

from react-native-modal.

neilfranci avatar neilfranci commented on May 12, 2024 12

11/2021

To anyone that facing this if you tried all from top solutions but doesn't look like what you think then here try mine.

- Because I used stack in a tab so this is what it look like:

The code:

<Modal 
        statusBarTranslucent    //Add this if you trying to Make the StatusBarTranslucent like mine.
        backdropOpacity={0.5}
        backdropColor="#000"
        coverScreen={true}
        deviceHeight={Dimensions.get('screen').height}
        animationIn={'slideInUp'}
        .......   //Other option you want to use.
>
//Your Content
</Modal>

But if you remove this: deviceHeight={Dimensions.get('screen').height}
This's what is look like:

Did you see that weird gray thing at the bottom ? jesus

Or you follow someone above and see this:
coverScreen={false}

You will see nothing

So keep in mind coverScreen={true} must be TRUE

And because I use tab with stack to present the modal like in the docs they have this:
screenOptions={{presentation: 'transparentModal'}
and
<StatusBar translucent backgroundColor="transparent" />
in the stack screen
My project structure look like this

  • Tab
    • Stack Navigation
      • Home Screen
      • Modal Screen(container real modal)

So with those too setup above I can have a modal transparent background so when I press tabButton
I can change to the Modal Screen with navigation and the Home Screen will show behind the modal with the transparent StatusBar . Show when it come up with modal screen it look beautiful.

from react-native-modal.

remigallego avatar remigallego commented on May 12, 2024 10

If you are using React Navigation, here is a way to avoid this issue:

  • Instead of creating a component wrapped in Modal, create a screen with transparent background using transition config: react-navigation/react-navigation#1528 (comment)
  • Now instead of conditionally showing/hiding your Modal, navigate to your newly created screen and pass your dialog markup as param:
this.props.navigation.navigate({
        routeName: 'OverlayScreen',
        key: 'OverlayScreen',
        params: {
          content: () => this.renderComponent()
        }
      });

Inside 'OverlayScreen' you can just render your component like so and customize your StatusBar with more params if you want:

const content = this.props.navigation.getParam('content');
return (
  <View>
    <StatusBar
      backgroundColor={choseBackgroundColor()}
      barStyle={choseBarStyle()}
      hidden={false}
    />
    {content()}
  </View>
);

from react-native-modal.

swayok avatar swayok commented on May 12, 2024 10

StatusBar put inside Modal wrap from a View worked for me

  <Modal>
    <View>
      <StatusBar backgroundColor="rgba(0,0,0,0.7)"  barStyle="light-content"/>
    </View>
  </Modal>

Note for react-native-elements Overlay component: only backgroundColor works while barStyle has no effect and always light-content.
Tested in simulator with android 8.1 and on Xiaomi Mi5 8.1

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024 7

Guys, could you please provide the info I asked above?

from react-native-modal.

TheNerdGuyLulu avatar TheNerdGuyLulu commented on May 12, 2024 6

A possible work around...
I took a printscreen and "picked" the color.

asas

Then inside the modal with the StatusBar component I assigned the background color with the previous value.

<Modal>
    <View>
          <StatusBar barStyle="dark-content" backgroundColor={'#4A4B4D'} />  // Assign the background 
          <Text>Test</Text>
    </View>
</Modal>

And... voilรก.

asdasd

It's not perfect when it comes to open and close transition, but far better than all white status bar in my opinion.

P.S.
Adding animated={true} to the component, creates a smooth animation when the statusbar background color changes

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024 4

Ok, I gave it another try and the issue is indeed related to the original react-native modal.
The following code has the same "white statusbar" issue, caused by transparent={true}:

import React from "react";
import { Modal, View } from "react-native";

export default class Root extends React.Component<{}> {
  render() {
    return (
      <View style={{ flex: 1 }}>
        <Modal transparent={true} style={{ flex: 1 }}>
          <View style={{ backgroundColor: "blue", flex: 1 }} />
        </Modal>
      </View>
    );
  }
}

I'm trying the code above on different devices before opening an issue on the official react-native/expo repo.

The following devices have the issue:

  • Google Nexus 9 - 6.0.0 - API 23
  • Google Nexus 5 - 5.1.0 - API 22

The following devices work as expected:

  • 10.1_WGXA_Tablet_API_26

I guess it might be related to the API then, as the StatusBar Expo docs suggest.

Please notices that apps created using react-native (react-native init AppName) work correctly on all devices mentioned above, only Expo apps have the issue.

from react-native-modal.

Daniyal857 avatar Daniyal857 commented on May 12, 2024 4

a better solution for this issue: https://github.com/23mf/react-native-translucent-modal

after-pop1

a perfect one

from react-native-modal.

kallrobin avatar kallrobin commented on May 12, 2024 3

Hi, i am also dealing with a similar issue
Running:
"react-native-modal": "^3.1.0",
"react-native": "^0.47.2",
Android-API 21

When i open my modal i want the Status bar to still be there to keep consistency in the app but when the modal shows the status bar hides. But since the rest of the app is designed to be below the status bar only a white bar is shown in the status bars place.
How am i supposed to disable the modals interference with the status bar?

I tried changing back to the react-native original modal component and the status bar did not hide(animate away upwards).
But when i use the react-native-modal the status bar hides when the modal is activated. I have tried setting StatusBar.setHidden(false) in the onModalShow but it still goes on to hide the status bar.

I hope i have supplied you with enough information to help me, otherwise i'll do my best to try to explain my issue further.

Kind regards

Edit: This issue does not appear on API 19 and 25 and i am in progress of testing on more devices

from react-native-modal.

yalcinozer avatar yalcinozer commented on May 12, 2024 3

statusBarTranslucent property has been added to Modal of RN 0.62

<Modal ... statusBarTranslucent>...</Modal>

I think this problem has been solved. :)

How did I miss that? Thanks bro.

from react-native-modal.

goxr3plus avatar goxr3plus commented on May 12, 2024 3

Unbelievable this was the solution . Unbelievable i was searching for 1.5 year i love you !!! I will cry lol

I have no words no joking .

I am giving you a full example guyz:

				<Modal
			      ...
					useNativeDriverForBackdrop
					hideModalContentWhileAnimating
					style={{ maxWidth: windowWidth, marginLeft: 0, marginRight: 0, marginTop: 0, marginBottom: 0 }}
					coverScreen={false}
					deviceHeight={screenHeight}
				>

image

As you can see no status bar anymore !!!!!!!

from react-native-modal.

wkoutre avatar wkoutre commented on May 12, 2024 2

@listenzz nice! Simple and effective.

I had to do part of the linking manually (as I wrote in this issue: listenzz/react-native-modal-translucent#1) but other than that, good to go.

Doesn't solve (and doesn't intend to solve) completely eliminating the StatusBar for Android when a Modal from react-native is visible, but that's a separate topic.

from react-native-modal.

alex-mironov avatar alex-mironov commented on May 12, 2024 2

Why is this issue closed? It's still there.

from react-native-modal.

lucas-ssv avatar lucas-ssv commented on May 12, 2024 2

Hi there.
There's a modal option that makes this. Try statusBarTranslucent:

` <Modal
animationType="fade"
transparent={true}
statusBarTranslucent
visible={isVisible}

`

from react-native-modal.

PramelaDevi-S avatar PramelaDevi-S commented on May 12, 2024 2

statusBarTranslucent property has been added to Modal of RN 0.62

<Modal ... statusBarTranslucent>...</Modal>

I think this problem has been solved. :)

Thank you, it's helpful :)

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024 1

Hey @nidaorhan, could you try replacing react-native-modal with the React-Native built in modal and see if it has the same issue?

from react-native-modal.

kallrobin avatar kallrobin commented on May 12, 2024 1

@gasparteixeira I understand why that seems to work. But it's not fixing the issue really.
All you are doing is making the background not transparent and by default it's white. So now the status bar looks "fine" but now i can't see the background (eg. the app).
Although there might be something there to look at. I just can't seem to find some solution.

from react-native-modal.

gasparteixeira avatar gasparteixeira commented on May 12, 2024 1

Hello @Norfeldt
I did an experience to show you what I did. Let me know if it worked for you!

Please check out this experience on github:
https://github.com/gasparteixeira/react-navite-modal-exp or take a look at the only edited file

//App.js
import React from 'react';
import { StyleSheet, Text, View, TouchableOpacity, StatusBar} from 'react-native';
import Modal from 'react-native-modal'

export default class App extends React.Component {
  state = {
    isModalVisible: false,
    barStyle: 'dark-content'
  }
  _showModal = () => this.setState({ isModalVisible: true, barStyle: 'light-content' })

  _hideModal = () => this.setState({ isModalVisible: false, barStyle: 'dark-content' })
  render() {
    return (
      <View style={styles.container}>
        <StatusBar translucent barStyle={this.state.barStyle}/>
        <TouchableOpacity onPress={() => this._showModal()}>
          <Text>Show Modal</Text>
        </TouchableOpacity>
        <Modal
          isVisible={this.state.isModalVisible}
          backdropColor='transparent'
          transparent={false}
          style={styles.modalWindow}>
          <View style={styles.modalContent}>
            <TouchableOpacity onPress={() => this._hideModal()}>
              <Text style={{color: 'white'}}>Close</Text>
            </TouchableOpacity>
            <Text style={{color: 'white'}}>Modal full!</Text>
          </View>
        </Modal>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  modalWindow: {
    margin: 0,
  },
  modalContent: {
    flex: 1,
    backgroundColor: 'rgba(0,0,0,0.8)',
    alignItems: 'center',
    justifyContent: 'center',
  }
});

To scan my "working" code here is the expo link:
https://exp.host/@gasparteixeira/modal-exp

modalandroid
modalios

from react-native-modal.

GollyJer avatar GollyJer commented on May 12, 2024 1

@wkoutre Very cool! Nice work.
Hopefully someone on the core team can use what you've done to get this into the native modal.

We're using Expo so I'm unable to get your fix because I can't react-native link.

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024 1

@alex-mironov because unfortunately we cannot do too much about it since it's a RN issue ๐Ÿ˜ž

from react-native-modal.

leshphonc avatar leshphonc commented on May 12, 2024 1

I had fix this issue

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

nice!

from react-native-modal.

jpamarohorta avatar jpamarohorta commented on May 12, 2024 1

Oh I understand. If that's the case then this one should be closed. You are right sorry.

from react-native-modal.

RichardLindhout avatar RichardLindhout commented on May 12, 2024 1

New issue: facebook/react-native#20623

from react-native-modal.

pinguo-zhouwei avatar pinguo-zhouwei commented on May 12, 2024 1

a better solution for this issue: https://github.com/23mf/react-native-translucent-modal

after-pop1

from react-native-modal.

fangasvsass avatar fangasvsass commented on May 12, 2024 1

the issue still react native 0.59.9

from react-native-modal.

shels107 avatar shels107 commented on May 12, 2024 1

@viktor992 thanks, it's work for me

from react-native-modal.

Linkitsoft avatar Linkitsoft commented on May 12, 2024 1

I have a component with status bar set to hidden like this:

<View style={ style.container } >
   <StatusBar hidden={true} />

        ...
        
   <Modal isVisible={this.state.isModalVisible}>
     <Text>Modal</Text>   
   </Modal>

</View>

When the modal is visible, status bar is hidden but instead there is an empty white block at the top with the exact height of the status bar:

screenshot

react-native : 0.45.1
react-native-moda l: 2.5.0
android : 5.1.1

    <Modal
      visible={showModal}
       backdropColor='#ee535d' <-- Add this
        transparent={false} <-- Add this
        statusBarTranslucent <-- Add this

    >
        ..
        .
        .
    </Modal>

from react-native-modal.

nidaorhan avatar nidaorhan commented on May 12, 2024

Yes, I tried, no issues with the React-Native built in modal

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

Sorry for being late, I was on holiday.
Could you provide an exact code example to reproduce the issue?

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

Closing, feel free to create a new issue if needed ๐Ÿ‘

Also, please be aware that I created the following "new issue template" that, if followed correctly, will speed up a lot the issue resolution:


When reporting a bug, please be sure to check if the issue still persists with react-native original modal:

Under the hood react-native-modal uses react-native original Modal component.
Before reporting a bug, try swapping react-native-modal with react-native original Modal component to check if the problem persists.

When reporting a bug, please be sure to include the following:

  • The outcome of the react-native-modal swap described above
  • A descriptive title
  • An isolated way to reproduce the behavior (example: GitHub repository with code isolated to the issue that anyone can clone to observe the problem)
  • What version of react-native-modal you're using, and the platform(s) you're running it on (iOS, Android, device)
  • What packages or other dependencies you're using
  • The behavior you expect to see, and the actual behavior

When you open an issue for a feature request, please add as much detail as possible:

  • A descriptive title
  • A description of the problem you're trying to solve, including why you think this is a problem
  • An overview of the suggested solution
  • If the feature changes current behavior, reasons why your solution is better

Please note by far the quickest way to get a new feature is to file a Pull Request.

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

@kallrobin thanks a lot, I'm re-opening the issue, could you please provide a bit more info on the subject?
What device are you using?
Did you try it on more than one device?
Are you using an emulator?
What navigation library are you using?
Also, if you provide a snippet of the js file where you use the modal it would be awesome :)

from react-native-modal.

orestis-z avatar orestis-z commented on May 12, 2024

+1

from react-native-modal.

EnriqueDev avatar EnriqueDev commented on May 12, 2024

I'm dealing with the same issue in RN0.48.

from react-native-modal.

EnriqueDev avatar EnriqueDev commented on May 12, 2024

What device are you using?

  • Samsung Galaxy A5 2017 - 6.0.1
  • Huawey Ascent P8 - Android 6.0
  • Sony Xperia Z1 - Android 5.1.1

What navigation library are you using?
Read-Native-Router-Flux

Note
When trying on:

  • BQ Aquaris 5H - Android 4.4.2
  • Google Nexus 5X- Android 7.1.2

it works properly.

Seems like is SO version related.

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

@EnriqueDev that's exactly what I suspected :(
I'll try to investigate, thanks for the info

from react-native-modal.

kallrobin avatar kallrobin commented on May 12, 2024

Hi!
Sorry for the delayed response.
But i can also confirm that its a problem with specific devices. So far i only encounter this problem om the nexus5.
All of my android tests had been on emulated devices.
And the navigation lib i'm using is react-navigation.
I decided that atleast on the app i'm developing now i'll just leave it and sadly users on the nexus 5 will have that white bar on top. Might try and do something about it later when i don't have so much more important things to do.

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

That's weird, I'm not having the issue on the N5 on simulator...

from react-native-modal.

kallrobin avatar kallrobin commented on May 12, 2024

Wow. That's strange!
That might indicate it has to do with some specific combination of libraries that i'm using together with the N5.

from react-native-modal.

Stophface avatar Stophface commented on May 12, 2024

@gasparteixeira where exactly do you pass these props?

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

@Stophface in the StatusBar component i guess... ๐Ÿค”

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

Can anyone confirm @gasparteixeira solution?

from react-native-modal.

zmartell avatar zmartell commented on May 12, 2024

@mmazzarolo doesn't seem to work.

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

Might be related to this issue

from react-native-modal.

gasparteixeira avatar gasparteixeira commented on May 12, 2024

@kallrobin you right! I made an "ugly" solution. It worked for me and maybe it was not the right way.... I also did another weird thing. I set the background transparent and declare a View with background color inside this!

from react-native-modal.

Norfeldt avatar Norfeldt commented on May 12, 2024

@gasparteixeira Would you mind sharing your "working" code?

from react-native-modal.

webraptor avatar webraptor commented on May 12, 2024

Can be fixed with facebook/react-native#7474 (comment)

from react-native-modal.

toussa avatar toussa commented on May 12, 2024

@webraptor well, this workaround does not work with Expo.

By the way, I can confirm the problem with react-native: 0.50.3, expo and Google Nexus 9 - 5.0.0 (API 21) (emulator)

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

For everyone having the issue, could you try placing the modal on the root of you app and see if it still shows the white bar?
By root level I mean outside of your Navigator too (if you're using a navigation library at all).

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

I also had the same issue using react-native-material-dropdown (which uses the native modal), see this related issue

from react-native-modal.

toussa avatar toussa commented on May 12, 2024

@mmazzarolo I did the test (modal on Root component, outside of navigator) => same issue ๐Ÿ˜ž

from react-native-modal.

wkoutre avatar wkoutre commented on May 12, 2024

@GollyJer It can always be manually linked.

Haven't used Expo in over a year so I can't speak to the process/possibility but.. react-native link is finicky as it is, so I usually either use Cocoapods (if supported) or manually link.

from react-native-modal.

jiangbophd avatar jiangbophd commented on May 12, 2024

so bad, the issue still there

from react-native-modal.

jpamarohorta avatar jpamarohorta commented on May 12, 2024

Why is this issue closed?

@listenzz package indeed fixes it but, isn't this still a bug?

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

Why is this issue closed?

Because, as far as I know, it's caused by RN own Modal, and not by react-native-modal.
I'll reopen it, but if this is still the case the issue should be addressed directly in react-native :(

from react-native-modal.

mmazzarolo avatar mmazzarolo commented on May 12, 2024

No worries, here's the issue: facebook/react-native#9090 (comment)

from react-native-modal.

swayok avatar swayok commented on May 12, 2024

a better solution for this issue: https://github.com/23mf/react-native-translucent-modal

I'm using react-native-elements Ovarlay component so it does not solve my case easily =(
Maybe I should reconsider this choice.

from react-native-modal.

RichardLindhout avatar RichardLindhout commented on May 12, 2024

Just use the portal branch of this modal ;)

from react-native-modal.

headfire94 avatar headfire94 commented on May 12, 2024

Possible workaround:

  1. Create simple modal component wrapped with View instead of native Modal.
  2. Use https://github.com/headfire94/react-native-gateway to render modal on top of everything (above statusBar, content, tabBat and so on), it works just like react Portal.
  3. apply back handler from react-navigation-backhandler to allow close it on hardware back button on Android

Modal works just like native in this case (If i'm not missing something)

from react-native-modal.

sidlu-company avatar sidlu-company commented on May 12, 2024

I had fix this issue

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

perfect!

from react-native-modal.

wenkangzhou avatar wenkangzhou commented on May 12, 2024

Has any progerss?

from react-native-modal.

rdgomt avatar rdgomt commented on May 12, 2024

Didn't work for me :(

from react-native-modal.

iroslehu avatar iroslehu commented on May 12, 2024

Hey Guys,

I had same problem. I just put this transparent={false} props and everything is working on Android.

Thanks, it works for me.

from react-native-modal.

rayj10 avatar rayj10 commented on May 12, 2024

Anyone experiencing this?
I made my app full screen on Android, the modal is clashing with the hidden android nav bar and status bar
this happens on most android devices with soft nav bar for me, but this screenshot is from emulator (Nexus 5 API 27)
this is used in conjunction with RNRF

any pointers would be awesome
Screenshot_1599637240

from react-native-modal.

gregogalante avatar gregogalante commented on May 12, 2024

@rayj10 have you found a solution for the problem?

from react-native-modal.

abdulrehmanicm avatar abdulrehmanicm commented on May 12, 2024

<StatusBar backgroundColor={visibleModal? "rgba(0,0,0,0.7)": 'transparent'} barStyle={visibleModal ? 'light-content' : 'dark-content'} />

from react-native-modal.

nkutechologies avatar nkutechologies commented on May 12, 2024

backdropColor='#ee535d' <-- Add this
transparent={false} <-- Add this
statusBarTranslucent <-- Add this

this works for me Thanks

from react-native-modal.

cocoa-1012 avatar cocoa-1012 commented on May 12, 2024

Hi, there.
I've made a Android app without statusbar. But when I show the modal, it includes statusbar and it makes the app is poor.

Is there any way to hide the statusbar in modal?
I doesn't mean transparent, I need to hide the statusbar.

Thanks.

from react-native-modal.

goxr3plus avatar goxr3plus commented on May 12, 2024

You will find some problems though if you stuck 2 modals on top of each other etc so you have to be careful with the above solution .

from react-native-modal.

CAglarBilkent avatar CAglarBilkent commented on May 12, 2024

@cocoa-1012
Were you able to find a solution? I am facing the same issue. This is so weird

from react-native-modal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.