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 https://github.com/facebook/react-native/pull/17936

Differential Revision: D6962962

Pulled By: shergin

fbshipit-source-id: e11d9386544fe19a9195e22a03e12f64e934cad7
This commit is contained in:
Martin Arista 2018-02-11 22:21:02 -08:00 committed by Facebook Github Bot
parent 9d214967d2
commit 47b36d3ff0
1 changed files with 9 additions and 5 deletions

View File

@ -73,8 +73,15 @@ RCT_EXPORT_METHOD(showMessage:(NSString *)message color:(UIColor *)color backgro
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 @@ RCT_EXPORT_METHOD(showMessage:(NSString *)message color:(UIColor *)color backgro
// 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;