-
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
Make SafeAreaView to work on iOS < 11 #18534
Conversation
Emulation based on tracking UIViewController layout guides.
I'am not sure about proper release notes categorization because SafeAreaView undocumented currently at http://facebook.github.io/react-native/docs . Should it be enhancement or fix, or may be internal? |
I think it would be nice to document if you can :) |
@satya164 I agree. But I think documentation should be distinct PR. And I'm not native speaker, so it would be good, if anyone else create documentation patch. |
@grabbou What is progress on testing? On my side, I integrated this patch to one project and it works. If anyone needs to test it, your can specify this in
Also this branch has other non related modifications, they should not break anything. If you worry, here is the full list of changes:
|
After self review yersterday I found that documentation for
|
@shergin Sorry to bother you, but could you please review this changes. |
I think it'll also be nice to have something like |
@satya164 Generally speaking, I think we should start thinking about creating an Android implementation of this component too (instead of I might be missing something, but a simple padding/margin with StatusBar height on Android would do the trick, right? At least that's what I am usually doing inside my apps. |
Sure. But that's not why I'm proposing
The way |
What is the progress on this? Can I help to land this code faster? |
Looks like one of the tests failed with a build error
Which (my best guess) a simple rerun would fix. I'll try to bring this up to the core, it seems like it's a good feature to have. Regarding the documentation, since there is already a section, if this PR lands I think you should do a small PR to the dedicated md on the docs repo to let people know how to use / that it works with iOS < 11. |
Rerun will do - that error happens quite often.
…On Fri, 6 Apr 2018 at 09:55 Lorenzo Sciandra ***@***.***> wrote:
Looks like one of the tests failed with a build error
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'react-native'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not download bcpkix-jdk15on.jar (org.bouncycastle:bcpkix-jdk15on:1.48)
> Could not get resource 'https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.jar'.
> java.lang.NullPointerException (no error message)
Which (my best guess) a simple rerun would fix.
I'll try to bring this up to the core, it seems like it's a good feature
to have.
Regarding the documentation, since there is already a section, if this PR
lands I think you should do a small PR to the dedicated md on the docs
repo
<https://github.com/facebook/react-native-website/blob/master/docs/safeareaview.md>
to let people know how to use / that it works with iOS < 11.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18534 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACWcxhKBGvZOMzv4YtmtbiVyAVH3l-Yaks5tlx9jgaJpZM4S5ofz>
.
|
I think it's time to move ahead with this PR - where we are? |
I think more standard approach, in my opinion, would be to just rename it to SafeAreaViewIOS until it's landing on Android and problem solved. That would be similar to what we were doing from the very beginning at the Alert / AlertIOS and StatusBar / StatusBarIOS examples. The |
Can't just rename it. It'll break existing libraries. Need to have a deprecation path to rename. And when you add it back later to support Android, it would be pretty confusing for libraries. |
@vovkasm I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
Will not rebase, because current master totally broken with babel 7 transition ( Potential reviewer is @shergin as the author of the original code. |
@vovkasm can you add an |
@satya164 I can, but prefer to do it in distinct PR because:
But if most people vote for it, then I will add. |
Just publish
|
If using expo, we can still use something like |
@Bonobomagno Strictly speaking, no... using |
I'm seriously starting to think that publishing of an independent component to npm is a proper way to go with this issue. It seems that at the moment RN team focuses on hard rewriting core, not in stabilizing the code. |
I can understand your frustration but I can assure we are mostly focusing (at least, the OSS-side of core team) on stabilizing the codebase. Literally, our efforts at the moment are around the CI and fixing issues not strictly related to this feature. Feel free to publish it as a separate package - it's a free world after all - what I can do is try to bring it once more to the attention of the core team. |
We encourage people to go the third party module route whenever possible. As @kelset said, we're focusing on core stability at the moment. As long as our tests are not all green, landing PRs is not the top priority. |
Now that tests are green, I'm going through PRs. I'm hesitant about merging this PR. We have been using |
@hramos I think that "Test Plan" in the PR clearly shows the issue, isn't it? It exists in RNTester.
So... :-) |
Once this PR is merged, we would have to revert this PR: facebook/react-native-website#429. |
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.
hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
This has been accepted. I'll go through the motions of landing the internal diff soon.
This pull request was closed by @vovkasm in 3949e93. Once this commit is added to a release, you will see the corresponding version tag below the description at 3949e93. If the commit has a single |
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.
@hramos, can you provide some info? Why this deoptimization was done? Is it because some technical reasons or code style or something another?
@@ -56,7 +54,7 @@ - (void)safeAreaInsetsDidChange | |||
- (void)layoutSubviews | |||
{ | |||
[super layoutSubviews]; | |||
if (_safeAreaAvailable) { | |||
if ([self respondsToSelector:@selector(safeAreaInsets)]) { |
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.
Does this change come from some internal conversations? What purpose?
I wonder because I intentionally moved relative slow call of respondsToSelector
method out of "critical path" code in layoutSubviews
. It was tradeoff speed/size, cost of this optimization was 1 byte stored in ivars area.
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.
This was one of the changes requested as part of the internal review (cc @PeteTheHeat).
Summary: Currently `SafeAreaView` works only on iOS 11, because implemented in terms of native safeArea API, that not exists in older iOS versions. But this make it hard to use the component in real applications, because content will be under top bars on older versions of iOS and no reliable way to workaround this in js. More motivation in facebook#17638 This changeset emulate safe area in terms of `UIViewController` layout guides API if safeArea not available. Fixes facebook#17638, facebook#18255 I run RNTester with these simulators: iPhone6 (9.3), iPhone6 (10.0), iPhone6 (11.2), iPhoneX (11.2) - Start RNTester application - Look on top header, it should not overlap status bar - Go to the `<SafeAreaView>` example, open modal - Modal area should not overlap status bar <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_10_20662C5B.png" width="40%"> <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_11_20662CC8.png" width="40%"> <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_10_pr_20662DE6.png" width="40%"> <img src="http://vovkasm.skitch.vovkasm.org/iPhone6_11_pr_20662DA8.png" width="40%"> [IOS] [BUGFIX] [SafeAreaView] - Make SafeAreaView to work on iOS < 11 Pull Request resolved: facebook#18534 Reviewed By: PeteTheHeat, shergin Differential Revision: D9166052 Pulled By: hramos fbshipit-source-id: c086e1ae4af13110a7453b770ca75b6e0d5321ea
Currently
SafeAreaView
works only on iOS 11, because implemented in terms of native safeArea API, that not exists in older iOS versions. But this make it hard to use the component in real applications, because content will be under top bars on older versions of iOS and no reliable way to workaround this in js. More motivation in #17638This changeset emulate safe area in terms of
UIViewController
layout guides API if safeArea not available.Fixes #17638, #18255
Test Plan
I run RNTester with these simulators: iPhone6 (9.3), iPhone6 (10.0), iPhone6 (11.2), iPhoneX (11.2)
<SafeAreaView>
example, open modalRNTester before change
RNTester after change
Release Notes
[IOS] [BUGFIX] [SafeAreaView] - Make SafeAreaView to work on iOS < 11