Permalink
Browse files

Update DevLoadingView to Support iPhone X

Summary:
The current implementation of DevLoadingView for iPhone currently gives a static height of `22` and does not take into account iPhoneX screen dimensions.

Devices: All iPhone devices currently available with Xcode v9.2
SDK: 8.1, 9, 10, 11

Validate resize only occurs on iPhone X devices and others remain consistent.

Before:
![feb-10-2018 12-30-20](https://user-images.githubusercontent.com/1743953/36065313-7b41f2ea-0e5e-11e8-87f2-928e26536077.gif)

After:
![feb-10-2018 12-28-15](https://user-images.githubusercontent.com/1743953/36065317-848e4f7e-0e5e-11e8-8aab-70cb5db32f31.gif)

[GENERAL][ENHANCEMENT][{React}] - Improvements to DevLoadingView for iPhone X
Closes #17936

Differential Revision: D6962962

Pulled By: shergin

fbshipit-source-id: e11d9386544fe19a9195e22a03e12f64e934cad7
  • Loading branch information...
mrtnrst authored and facebook-github-bot committed Feb 12, 2018
1 parent 9d21496 commit 47b36d3ff0dbb99fd3fc98f6e981a38084dd4d2c
Showing with 9 additions and 5 deletions.
  1. +9 −5 React/DevSupport/RCTDevLoadingView.m
@@ -73,8 +73,15 @@ - (void)setBridge:(RCTBridge *)bridge
dispatch_async(dispatch_get_main_queue(), ^{
self->_showDate = [NSDate date];
if (!self->_window && !RCTRunningInTestEnvironment()) {
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 22)];
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)];
} else {
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, 22)];
self->_label = [[UILabel alloc] initWithFrame:self->_window.bounds];
}
[self->_window addSubview:self->_label];
#if TARGET_OS_TV
self->_window.windowLevel = UIWindowLevelNormal + 1;
#else
@@ -83,11 +90,8 @@ - (void)setBridge:(RCTBridge *)bridge
// set a root VC so rotation is supported
self->_window.rootViewController = [UIViewController new];
self->_label = [[UILabel alloc] initWithFrame:self->_window.bounds];
self->_label.font = [UIFont systemFontOfSize:12.0];
self->_label.textAlignment = NSTextAlignmentCenter;
[self->_window addSubview:self->_label];
}
self->_label.text = message;

1 comment on commit 47b36d3

@GibranPolonsky

This comment has been minimized.

GibranPolonsky commented on 47b36d3 Jun 5, 2018

What about if user is on landscape ?

Please sign in to comment.