Skip to content

Commit c9f19ab

Browse files
committed
slightly more logical order
1 parent 979000f commit c9f19ab

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

packages/react-native/React/CoreModules/RCTDevLoadingView.mm

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,30 +112,32 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
112112

113113
self->_showDate = [NSDate date];
114114

115-
UIWindow *mainWindow = RCTKeyWindow();
116-
if (!self->_window) {
117-
self->_window = [[UIWindow alloc] initWithWindowScene:mainWindow.windowScene];
118-
self->_window.windowLevel = UIWindowLevelStatusBar + 1;
119-
self->_window.rootViewController = [UIViewController new];
115+
if (!self->label) {
116+
self->_label = [[UILabel alloc] init];
117+
self->_label.translatesAutoresizingMaskIntoConstraints = NO;
118+
self->_label.font = [UIFont monospacedDigitSystemFontOfSize:12.0 weight:UIFontWeightRegular];
119+
self->_label.textAlignment = NSTextAlignmentCenter;
120+
}
121+
self->_label.textColor = color;
122+
self->_label.text = message;
120123

124+
if (!self->container) {
121125
self->_container = [[UIView alloc] init];
122126
self->_container.translatesAutoresizingMaskIntoConstraints = NO;
123127
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
124128
[self->_container addGestureRecognizer:tapGesture];
125129
self->_container.userInteractionEnabled = YES;
126-
127-
self->_label = [[UILabel alloc] init];
128-
self->_label.translatesAutoresizingMaskIntoConstraints = NO;
129-
self->_label.font = [UIFont monospacedDigitSystemFontOfSize:12.0 weight:UIFontWeightRegular];
130-
self->_label.textAlignment = NSTextAlignmentCenter;
131-
132-
[self->_window.rootViewController.view addSubview:self->_container];
133130
[self->_container addSubview:self->_label];
134131
}
135-
136132
self->_container.backgroundColor = backgroundColor;
137-
self->_label.textColor = color;
138-
self->_label.text = message;
133+
134+
UIWindow *mainWindow = RCTKeyWindow();
135+
if (!self->_window) {
136+
self->_window = [[UIWindow alloc] initWithWindowScene:mainWindow.windowScene];
137+
self->_window.windowLevel = UIWindowLevelStatusBar + 1;
138+
self->_window.rootViewController = [UIViewController new];
139+
[self->_window.rootViewController.view addSubview:self->_container];
140+
}
139141

140142
CGFloat topSafeAreaHeight = mainWindow.safeAreaInsets.top;
141143
CGFloat height = topSafeAreaHeight + 25;

0 commit comments

Comments
 (0)