-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Modal Status Bar Translucent #7157
Conversation
@@ -20,6 +20,8 @@ const View = require('View'); | |||
const requireNativeComponent = require('requireNativeComponent'); | |||
const RCTModalHostView = requireNativeComponent('RCTModalHostView', null); | |||
|
|||
const STATUS_BAR_HEIGHT = 24; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
@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; | |||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@jemise111 updated the pull request. |
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 Just checked out a few apps and dialogs always appear on top of the status bar. |
Have you tested on older android version that do not support the TRANSLUCENT window flag? |
@jemise111 updated the pull request. |
@jemise111 updated the pull request. |
@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! |
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. |
I think this should be the default behaviour instead of adding a prop. |
Thanks for looking @janicduplessis and @grabbou. Let's make this default. |
@mkonicek great, will do! Think it's necessary to keep a prop for rendering the dialogue the original way? Something like 'persistsStatusBar={true}'? |
@jemise111 I don't think anybody really wants that. Do you think people need it? |
@satya164 no, I agree with you. Just wanted to check. |
@jemise111 updated the pull request. |
@mkonicek done! |
@@ -91,6 +103,18 @@ class Modal extends React.Component { | |||
} |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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.
@janicduplessis done! |
@jemise111 updated the pull request. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to Phabricator to review. |
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! |
@dmmiller thanks! Let me know if I can help in any way. And that's really cool! Glad to hear it. |
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. |
@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. |
Awesome @dmmiller. Thanks for the update. |
191d278
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
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
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
Is this behaviour achievable currently? |
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
Thanks!