Skip to content

Commit 979000f

Browse files
committed
reuse container and label, too
1 parent 9ea9def commit 979000f

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,26 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:(
117117
self->_window = [[UIWindow alloc] initWithWindowScene:mainWindow.windowScene];
118118
self->_window.windowLevel = UIWindowLevelStatusBar + 1;
119119
self->_window.rootViewController = [UIViewController new];
120+
121+
self->_container = [[UIView alloc] init];
122+
self->_container.translatesAutoresizingMaskIntoConstraints = NO;
123+
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
124+
[self->_container addGestureRecognizer:tapGesture];
125+
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];
133+
[self->_container addSubview:self->_label];
120134
}
121135

122-
self->_container = [[UIView alloc] init];
123136
self->_container.backgroundColor = backgroundColor;
124-
self->_container.translatesAutoresizingMaskIntoConstraints = NO;
125-
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
126-
[self->_container addGestureRecognizer:tapGesture];
127-
self->_container.userInteractionEnabled = YES;
128-
129-
self->_label = [[UILabel alloc] init];
130-
self->_label.translatesAutoresizingMaskIntoConstraints = NO;
131-
self->_label.font = [UIFont monospacedDigitSystemFontOfSize:12.0 weight:UIFontWeightRegular];
132-
self->_label.textAlignment = NSTextAlignmentCenter;
133137
self->_label.textColor = color;
134138
self->_label.text = message;
135139

136-
[self->_window.rootViewController.view addSubview:self->_container];
137-
[self->_container addSubview:self->_label];
138-
139140
CGFloat topSafeAreaHeight = mainWindow.safeAreaInsets.top;
140141
CGFloat height = topSafeAreaHeight + 25;
141142
self->_window.frame = CGRectMake(0, 0, mainWindow.frame.size.width, height);

0 commit comments

Comments
 (0)