Skip to content

Commit

Permalink
Smaller loading bar based on feedback
Browse files Browse the repository at this point in the history
Summary:
This diff removes the hostname from the loading bar and shrinks it down so it's inside the margins of the safe area view, never blocking app content inside the safe area.

Changelog: [General] [iOS] Shrink loading bar down to not cover safe area.

Reviewed By: shergin

Differential Revision: D21339480

fbshipit-source-id: e8416af63b7e06bcc21c7b6277d5d01d61eb3f73
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed May 1, 2020
1 parent 0569221 commit f0dfd35
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions React/CoreModules/RCTDevLoadingView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ @interface RCTDevLoadingView () <NativeDevLoadingViewSpec>
@implementation RCTDevLoadingView {
UIWindow *_window;
UILabel *_label;
UILabel *_host;
NSDate *_showDate;
BOOL _hiding;
dispatch_block_t _initialMessageBlock;
Expand Down Expand Up @@ -120,23 +119,14 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
if (@available(iOS 11.0, *)) {
UIWindow *window = RCTSharedApplication().keyWindow;
self->_window =
[[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, window.safeAreaInsets.top + 52)];
self->_label = [[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top, screenSize.width, 22)];
self->_host =
[[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top + 20, screenSize.width, 22)];
self->_host.font = [UIFont monospacedDigitSystemFontOfSize:10.0 weight:UIFontWeightRegular];
self->_host.textAlignment = NSTextAlignmentCenter;

[self->_window addSubview:self->_label];
[self->_window addSubview:self->_host];

[[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, window.safeAreaInsets.top + 10)];
self->_label =
[[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top - 10, screenSize.width, 20)];
} else {
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, 22)];
self->_window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, 20)];
self->_label = [[UILabel alloc] initWithFrame:self->_window.bounds];

[self->_window addSubview:self->_label];
// TODO: Add host to iOS < 11.0
}
[self->_window addSubview:self->_label];

self->_window.windowLevel = UIWindowLevelStatusBar + 1;
// set a root VC so rotation is supported
Expand All @@ -149,11 +139,6 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
self->_label.text = message;
self->_label.textColor = color;

if (self->_host != nil) {
self->_host.text = [self getTextForHost];
self->_host.textColor = [self dimColor:color];
}

self->_window.backgroundColor = backgroundColor;
self->_window.hidden = NO;

Expand Down Expand Up @@ -186,11 +171,11 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(

dispatch_async(dispatch_get_main_queue(), ^{
self->_hiding = true;
const NSTimeInterval MIN_PRESENTED_TIME = 0.5;
const NSTimeInterval MIN_PRESENTED_TIME = 0.6;
NSTimeInterval presentedTime = [[NSDate date] timeIntervalSinceDate:self->_showDate];
NSTimeInterval delay = MAX(0, MIN_PRESENTED_TIME - presentedTime);
CGRect windowFrame = self->_window.frame;
[UIView animateWithDuration:0.1
[UIView animateWithDuration:0.25
delay:delay
options:0
animations:^{
Expand All @@ -216,7 +201,7 @@ - (void)showWithURL:(NSURL *)URL
return;
#endif
color = [UIColor whiteColor];
backgroundColor = [UIColor colorWithHue:105 saturation:0 brightness:.25 alpha:1];
backgroundColor = [UIColor blackColor];
message = [NSString stringWithFormat:@"Connect to %@ to develop JavaScript.", RCT_PACKAGER_NAME];
[self showMessage:message color:color backgroundColor:backgroundColor];
} else {
Expand Down

0 comments on commit f0dfd35

Please sign in to comment.