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 Status Bar Translucent #7157

Closed

Conversation

jemise111
Copy link
Contributor

Currently the Modal component on Android is rendered below the Status Bar, which changes it's color to grey, and in the UIExplorer example the backdrop is just formatted to look the same color. In some scenarios users may want to preserve the color of their status bar and make it look as though the modal is appearing on top. This PR allows for that.

This GIF shows current behavior and new behavior with the translucentStatusBar prop set to true.

I've updated the UIExplorer app to demonstrate and the docs as shown below

image

Thanks!

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @dmmiller and @gabelevi to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Apr 22, 2016
@@ -20,6 +20,8 @@ const View = require('View');
const requireNativeComponent = require('requireNativeComponent');
const RCTModalHostView = requireNativeComponent('RCTModalHostView', null);

const STATUS_BAR_HEIGHT = 24;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fixed on Android?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use StatusBar.currentHeight to get the actual height from native.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janicduplessis thanks for the tip, fixed!

@facebook-github-bot
Copy link
Contributor

@jemise111 updated the pull request.

@@ -20,6 +20,8 @@ const View = require('View');
const requireNativeComponent = require('requireNativeComponent');
const RCTModalHostView = requireNativeComponent('RCTModalHostView', null);

const STATUS_BAR_HEIGHT = StatusBar.currentHeight;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-undef: 'StatusBar' is not defined.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identifier StatusBar Could not resolve name

@facebook-github-bot
Copy link
Contributor

@jemise111 updated the pull request.

@janicduplessis
Copy link
Contributor

janicduplessis commented Apr 26, 2016

Should we add a prop for this? Feels like it should always appear on top of the status bar. It would probably still be possible to achieve the old behavior using the StatusBar module and changing the status bar color when the modal is opened.

Just checked out a few apps and dialogs always appear on top of the status bar.

cc @mkonicek @dmmiller

@janicduplessis
Copy link
Contributor

Have you tested on older android version that do not support the TRANSLUCENT window flag?

@ghost
Copy link

ghost commented Apr 28, 2016

@jemise111 updated the pull request.

@ghost
Copy link

ghost commented Apr 28, 2016

@jemise111 updated the pull request.

@jemise111
Copy link
Contributor Author

@janicduplessis Fixed so the top of the modal is only pushed down on the appropriate API level on android.

Nothing breaks in the Java code for older versions.

Could you please clarify your other comment? Thanks!

@janicduplessis
Copy link
Contributor

I'm wondering if the modal should always render over the status bar (like when you set Translucent Statusbar to true in the example). I think it looks a lot better and is what pretty much every app does.

@satya164
Copy link
Contributor

I think this should be the default behaviour instead of adding a prop.

@mkonicek
Copy link
Contributor

Thanks for looking @janicduplessis and @grabbou. Let's make this default.

@jemise111
Copy link
Contributor Author

@mkonicek great, will do! Think it's necessary to keep a prop for rendering the dialogue the original way? Something like 'persistsStatusBar={true}'?

@satya164
Copy link
Contributor

@jemise111 I don't think anybody really wants that. Do you think people need it?

@jemise111
Copy link
Contributor Author

@satya164 no, I agree with you. Just wanted to check.

@ghost
Copy link

ghost commented May 1, 2016

@jemise111 updated the pull request.

@jemise111
Copy link
Contributor Author

@mkonicek done!

@@ -91,6 +103,18 @@ class Modal extends React.Component {
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eol-last: Newline required at end of file but not found.

@@ -91,6 +103,18 @@ class Modal extends React.Component {
}
}

Modal.propTypes = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these prop types added here? It's already defined in the class as a static member.

@jemise111
Copy link
Contributor Author

@janicduplessis done!

@ghost
Copy link

ghost commented May 5, 2016

@jemise111 updated the pull request.

@dmmiller
Copy link

dmmiller commented May 5, 2016

@facebook-github-bot shipit

@ghost ghost added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels May 5, 2016
@ghost
Copy link

ghost commented May 5, 2016

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost added Import Failed and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels May 6, 2016
@dmmiller
Copy link

dmmiller commented May 6, 2016

This is failing some internal tests. I am working to get those fixed and have this landed.

As a bonus, this pull request fixed an internal issue that someone posted about yesterday. I told them to try this patch and it solved the issue. That's pretty awesome!

@jemise111
Copy link
Contributor Author

@dmmiller thanks! Let me know if I can help in any way.

And that's really cool! Glad to hear it.

@dmmiller
Copy link

dmmiller commented May 6, 2016

I'm working on open sourcing the test that is failing so you can look into it :) And I'll keep looking at it as well.

@dmmiller
Copy link

dmmiller commented May 9, 2016

@jemise111 So the problem is that by introducing a dependency on StatusBar, we have to update ReactPackage to include StatusBarManager which some of our internal apps don't do. Instead what I've done is expose a StatusBarHeight constant on Modal to use. I should be landing it today with that change and you can see.

@jemise111
Copy link
Contributor Author

Awesome @dmmiller. Thanks for the update.

@ghost ghost closed this in 191d278 May 9, 2016
zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
Summary:
Currently the Modal component on Android is rendered below the Status Bar, which changes it's color to grey, and in the UIExplorer example the backdrop is just formatted to look the same color. In some scenarios users may want to preserve the color of their status bar and make it look as though the modal is appearing on top. This PR allows for that.

This GIF shows current behavior and new behavior with the translucentStatusBar prop set to true.

![](http://g.recordit.co/BSX5g9obRC.gif)

I've updated the UIExplorer app to demonstrate and the docs as shown below

![image](https://cloud.githubusercontent.com/assets/4265163/14742854/500e1292-086c-11e6-9275-71808b0cbed7.png)

Thanks!
Closes facebook#7157

Differential Revision: D3264497

Pulled By: dmmiller

fb-gh-sync-id: 61346d99414d331d3420f44a4c5f6341b0973be6
fbshipit-source-id: 61346d99414d331d3420f44a4c5f6341b0973be6
bubblesunyum pushed a commit to iodine/react-native that referenced this pull request Aug 23, 2016
Summary:
Currently the Modal component on Android is rendered below the Status Bar, which changes it's color to grey, and in the UIExplorer example the backdrop is just formatted to look the same color. In some scenarios users may want to preserve the color of their status bar and make it look as though the modal is appearing on top. This PR allows for that.

This GIF shows current behavior and new behavior with the translucentStatusBar prop set to true.

![](http://g.recordit.co/BSX5g9obRC.gif)

I've updated the UIExplorer app to demonstrate and the docs as shown below

![image](https://cloud.githubusercontent.com/assets/4265163/14742854/500e1292-086c-11e6-9275-71808b0cbed7.png)

Thanks!
Closes facebook#7157

Differential Revision: D3264497

Pulled By: dmmiller

fb-gh-sync-id: 61346d99414d331d3420f44a4c5f6341b0973be6
fbshipit-source-id: 61346d99414d331d3420f44a4c5f6341b0973be6
mpretty-cyro pushed a commit to HomePass/react-native that referenced this pull request Aug 25, 2016
Summary:
Currently the Modal component on Android is rendered below the Status Bar, which changes it's color to grey, and in the UIExplorer example the backdrop is just formatted to look the same color. In some scenarios users may want to preserve the color of their status bar and make it look as though the modal is appearing on top. This PR allows for that.

This GIF shows current behavior and new behavior with the translucentStatusBar prop set to true.

![](http://g.recordit.co/BSX5g9obRC.gif)

I've updated the UIExplorer app to demonstrate and the docs as shown below

![image](https://cloud.githubusercontent.com/assets/4265163/14742854/500e1292-086c-11e6-9275-71808b0cbed7.png)

Thanks!
Closes facebook#7157

Differential Revision: D3264497

Pulled By: dmmiller

fb-gh-sync-id: 61346d99414d331d3420f44a4c5f6341b0973be6
fbshipit-source-id: 61346d99414d331d3420f44a4c5f6341b0973be6
@patrick-ngo
Copy link

Is this behaviour achievable currently?

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants