Skip to content

Commit

Permalink
Replace magic numbers with safeAreaInsets in RCTDevLoadingView
Browse files Browse the repository at this point in the history
Summary:
This PR replaces magic numbers used for offsetting `RCTDevLoadingView` when running on iPhone X, in favour of `safeAreaInsets`.

Tested on iPhone X and iPhone 8. Here is a screenshot showing how it looks on iPhone X.
![nansi](https://user-images.githubusercontent.com/3900360/39599961-b4239d90-4ef3-11e8-97f4-269d571a6c8d.png)
Closes facebook#19119

Differential Revision: D7984823

Pulled By: hramos

fbshipit-source-id: 0c7c3ba0fa258a64f6c4a1e0620f87bf0620984c
  • Loading branch information
fedetrim authored and facebook-github-bot committed May 13, 2018
1 parent 870775e commit 3d3edfc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions React/DevSupport/RCTDevLoadingView.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ - (void)setBridge:(RCTBridge *)bridge
self->_showDate = [NSDate date];
if (!self->_window && !RCTRunningInTestEnvironment()) {
CGSize screenSize = [UIScreen mainScreen].bounds.size;
if (screenSize.height == 812 /* iPhone X */) {
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, 60)];
self->_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, self->_window.bounds.size.width, 30)];

if (@available(iOS 11.0, *)) {
UIWindow *window = UIApplication.sharedApplication.keyWindow;
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, window.safeAreaInsets.top + 30)];
self->_label = [[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top, screenSize.width, 30)];
} else {
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, 22)];
self->_label = [[UILabel alloc] initWithFrame:self->_window.bounds];
Expand Down

0 comments on commit 3d3edfc

Please sign in to comment.