@@ -29,6 +29,7 @@ @interface RCTDevLoadingView () <NativeDevLoadingViewSpec>
29
29
@implementation RCTDevLoadingView {
30
30
UIWindow *_window;
31
31
UILabel *_label;
32
+ UILabel *_host;
32
33
NSDate *_showDate;
33
34
}
34
35
@@ -64,6 +65,24 @@ - (void)setBridge:(RCTBridge *)bridge
64
65
}
65
66
}
66
67
68
+ - (UIColor *)dimColor : (UIColor *)c
69
+ {
70
+ // Given a color, return a slightly lighter or darker color for dim effect.
71
+ CGFloat h, s, b, a;
72
+ if ([c getHue: &h saturation: &s brightness: &b alpha: &a])
73
+ return [UIColor colorWithHue: h saturation: s brightness: b < 0.5 ? b * 1.25 : b * 0.75 alpha: a];
74
+ return nil ;
75
+ }
76
+
77
+ - (NSString *)getTextForHost
78
+ {
79
+ if (self->_bridge .bundleURL == nil || self->_bridge .bundleURL .fileURL ) {
80
+ return @" React Native" ;
81
+ }
82
+
83
+ return [NSString stringWithFormat: @" %@ :%@ " , self ->_bridge.bundleURL.host, self ->_bridge.bundleURL.port];
84
+ }
85
+
67
86
- (void )showMessage : (NSString *)message color : (UIColor *)color backgroundColor : (UIColor *)backgroundColor
68
87
{
69
88
if (!RCTDevLoadingViewGetEnabled ()) {
@@ -78,18 +97,25 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
78
97
if (@available (iOS 11.0 , *)) {
79
98
UIWindow *window = RCTSharedApplication ().keyWindow ;
80
99
self->_window =
81
- [[UIWindow alloc ] initWithFrame: CGRectMake (0 , 0 , screenSize.width, window.safeAreaInsets.top + 30 )];
82
- self->_label = [[UILabel alloc ] initWithFrame: CGRectMake (0 , window.safeAreaInsets.top, screenSize.width, 30 )];
100
+ [[UIWindow alloc ] initWithFrame: CGRectMake (0 , 0 , screenSize.width, window.safeAreaInsets.top + 52 )];
101
+ self->_label = [[UILabel alloc ] initWithFrame: CGRectMake (0 , window.safeAreaInsets.top, screenSize.width, 22 )];
102
+ self->_host =
103
+ [[UILabel alloc ] initWithFrame: CGRectMake (0 , window.safeAreaInsets.top + 20 , screenSize.width, 22 )];
104
+ self->_host .font = [UIFont monospacedDigitSystemFontOfSize: 10.0 weight: UIFontWeightRegular];
105
+ self->_host .textAlignment = NSTextAlignmentCenter;
106
+
107
+ [self ->_window addSubview: self ->_label];
108
+ [self ->_window addSubview: self ->_host];
109
+
83
110
} else {
84
111
self->_window = [[UIWindow alloc ] initWithFrame: CGRectMake (0 , 0 , screenSize.width, 22 )];
85
112
self->_label = [[UILabel alloc ] initWithFrame: self ->_window.bounds];
113
+
114
+ [self ->_window addSubview: self ->_label];
115
+ // TODO: Add host to iOS < 11.0
86
116
}
87
- [self ->_window addSubview: self ->_label];
88
- #if TARGET_OS_TV
89
- self->_window .windowLevel = UIWindowLevelNormal + 1 ;
90
- #else
117
+
91
118
self->_window .windowLevel = UIWindowLevelStatusBar + 1 ;
92
- #endif
93
119
// set a root VC so rotation is supported
94
120
self->_window .rootViewController = [UIViewController new ];
95
121
@@ -99,6 +125,12 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
99
125
100
126
self->_label .text = message;
101
127
self->_label .textColor = color;
128
+
129
+ if (self->_host != nil ) {
130
+ self->_host .text = [self getTextForHost ];
131
+ self->_host .textColor = [self dimColor: color];
132
+ }
133
+
102
134
self->_window .backgroundColor = backgroundColor;
103
135
self->_window .hidden = NO ;
104
136
0 commit comments