Skip to content

Commit dbdb509

Browse files
Monte9grabbou
authored andcommitted
Updated RedBox screen (facebook#22242)
Summary: [Re: RedBox screen is a bit scary - Discussions and Proposals](react-native-community/discussions-and-proposals#42) Per hramos: > The RedScreen was inspired by Ruby on Rails's error screen > I do see the RedBox screen could be made less jarring while still successfully displaying all the information we need. Hence jamonholmgren came up with the idea that only the header & footer of the RedBox screen could be red. This makes the content a bit more readable as well as makes the screen a little less intimidating. Also frantic made the suggestion that since the bottom buttons are not as important, they don't need to stand out. Hence only the header of the RedBox screen which displays the error is made red. Screenshots: ---------- <div style="flex-direction: row"> <img width="325" alt="orginal" src="https://user-images.githubusercontent.com/7840686/48322916-b4958b80-e5de-11e8-9276-33378d1b41c5.png"> <img width="320" alt="redbox_v2_ios" src="https://user-images.githubusercontent.com/7840686/48665300-cce32b80-ea60-11e8-8e8f-88f74bad30ca.png"> </div> <div style="flex-direction: row"> <img width="300" alt="original_android" src="https://user-images.githubusercontent.com/7840686/48322958-d5f67780-e5de-11e8-891c-1b20bd00e67b.png"> <img width="300" alt="redbox_v2_android" src="https://user-images.githubusercontent.com/7840686/48665312-f13f0800-ea60-11e8-9fb6-47e03c809789.png"> </div> Pull Request resolved: facebook#22242 Reviewed By: hramos Differential Revision: D13564287 Pulled By: cpojer fbshipit-source-id: fcb6ba5e20d863f4b957d20f3787f5b7a365bfdb
1 parent 34a585e commit dbdb509

File tree

7 files changed

+79
-26
lines changed

7 files changed

+79
-26
lines changed

RNTester/RNTester/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>UIStatusBarStyle</key>
6+
<string>UIStatusBarStyleBlackTranslucent</string>
57
<key>CFBundleDevelopmentRegion</key>
68
<string>en</string>
79
<key>CFBundleExecutable</key>

React/Modules/RCTRedBox.m

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ - (instancetype)initWithFrame:(CGRect)frame
4747
#else
4848
self.windowLevel = UIWindowLevelStatusBar - 1;
4949
#endif
50-
self.backgroundColor = [UIColor colorWithRed:0.8 green:0 blue:0 alpha:1];
50+
self.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1];
5151
self.hidden = YES;
5252

5353
UIViewController *rootController = [UIViewController new];
@@ -58,7 +58,7 @@ - (instancetype)initWithFrame:(CGRect)frame
5858
const CGFloat buttonHeight = 60;
5959

6060
CGRect detailsFrame = rootView.bounds;
61-
detailsFrame.size.height -= buttonHeight;
61+
detailsFrame.size.height -= buttonHeight + [self bottomSafeViewHeight];
6262

6363
_stackTraceTableView = [[UITableView alloc] initWithFrame:detailsFrame style:UITableViewStylePlain];
6464
_stackTraceTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
@@ -73,10 +73,10 @@ - (instancetype)initWithFrame:(CGRect)frame
7373
[rootView addSubview:_stackTraceTableView];
7474

7575
#if TARGET_OS_SIMULATOR
76-
NSString *reloadText = @"Reload JS (\u2318R)";
77-
NSString *dismissText = @"Dismiss (ESC)";
78-
NSString *copyText = @"Copy (\u2325\u2318C)";
79-
NSString *extraText = @"Extra Info (\u2318E)";
76+
NSString *reloadText = @"Reload\n(\u2318R)";
77+
NSString *dismissText = @"Dismiss\n(ESC)";
78+
NSString *copyText = @"Copy\n(\u2325\u2318C)";
79+
NSString *extraText = @"Extra Info\n(\u2318E)";
8080
#else
8181
NSString *reloadText = @"Reload JS";
8282
NSString *dismissText = @"Dismiss";
@@ -88,53 +88,85 @@ - (instancetype)initWithFrame:(CGRect)frame
8888
dismissButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin;
8989
dismissButton.accessibilityIdentifier = @"redbox-dismiss";
9090
dismissButton.titleLabel.font = [UIFont systemFontOfSize:13];
91+
dismissButton.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
92+
dismissButton.titleLabel.textAlignment = NSTextAlignmentCenter;
93+
dismissButton.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1];
9194
[dismissButton setTitle:dismissText forState:UIControlStateNormal];
92-
[dismissButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateNormal];
93-
[dismissButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
95+
[dismissButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
96+
[dismissButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted];
9497
[dismissButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
9598

9699
UIButton *reloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
97100
reloadButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin;
98101
reloadButton.accessibilityIdentifier = @"redbox-reload";
99102
reloadButton.titleLabel.font = [UIFont systemFontOfSize:13];
100-
103+
reloadButton.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
104+
reloadButton.titleLabel.textAlignment = NSTextAlignmentCenter;
105+
reloadButton.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1];
101106
[reloadButton setTitle:reloadText forState:UIControlStateNormal];
102-
[reloadButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateNormal];
103-
[reloadButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
107+
[reloadButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
108+
[reloadButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted];
104109
[reloadButton addTarget:self action:@selector(reload) forControlEvents:UIControlEventTouchUpInside];
105110

106111
UIButton *copyButton = [UIButton buttonWithType:UIButtonTypeCustom];
107112
copyButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin;
108113
copyButton.accessibilityIdentifier = @"redbox-copy";
109114
copyButton.titleLabel.font = [UIFont systemFontOfSize:13];
115+
copyButton.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
116+
copyButton.titleLabel.textAlignment = NSTextAlignmentCenter;
117+
copyButton.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1];
110118
[copyButton setTitle:copyText forState:UIControlStateNormal];
111-
[copyButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateNormal];
112-
[copyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
119+
[copyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
120+
[copyButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted];
113121
[copyButton addTarget:self action:@selector(copyStack) forControlEvents:UIControlEventTouchUpInside];
114122

115123
UIButton *extraButton = [UIButton buttonWithType:UIButtonTypeCustom];
116124
extraButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin;
117125
extraButton.accessibilityIdentifier = @"redbox-extra";
118126
extraButton.titleLabel.font = [UIFont systemFontOfSize:13];
127+
extraButton.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
128+
extraButton.titleLabel.textAlignment = NSTextAlignmentCenter;
129+
extraButton.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1];
119130
[extraButton setTitle:extraText forState:UIControlStateNormal];
120-
[extraButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateNormal];
121-
[extraButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
131+
[extraButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
132+
[extraButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted];
122133
[extraButton addTarget:self action:@selector(showExtraDataViewController) forControlEvents:UIControlEventTouchUpInside];
123134

124135
CGFloat buttonWidth = self.bounds.size.width / 4;
125-
dismissButton.frame = CGRectMake(0, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight);
126-
reloadButton.frame = CGRectMake(buttonWidth, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight);
127-
copyButton.frame = CGRectMake(buttonWidth * 2, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight);
128-
extraButton.frame = CGRectMake(buttonWidth * 3, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight);
136+
CGFloat bottomButtonHeight = self.bounds.size.height - buttonHeight - [self bottomSafeViewHeight];
137+
138+
dismissButton.frame = CGRectMake(0, bottomButtonHeight, buttonWidth, buttonHeight);
139+
reloadButton.frame = CGRectMake(buttonWidth, bottomButtonHeight, buttonWidth, buttonHeight);
140+
copyButton.frame = CGRectMake(buttonWidth * 2, bottomButtonHeight, buttonWidth, buttonHeight);
141+
extraButton.frame = CGRectMake(buttonWidth * 3, bottomButtonHeight, buttonWidth, buttonHeight);
142+
143+
UIView *topBorder = [[UIView alloc] initWithFrame:CGRectMake(0, bottomButtonHeight + 1, rootView.frame.size.width, 1)];
144+
topBorder.backgroundColor = [UIColor colorWithRed:0.70 green:0.70 blue:0.70 alpha:1.0];
129145

130146
[rootView addSubview:dismissButton];
131147
[rootView addSubview:reloadButton];
132148
[rootView addSubview:copyButton];
133149
[rootView addSubview:extraButton];
150+
[rootView addSubview:topBorder];
151+
152+
UIView *bottomSafeView = [UIView new];
153+
bottomSafeView.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1];
154+
bottomSafeView.frame = CGRectMake(0, self.bounds.size.height - [self bottomSafeViewHeight], self.bounds.size.width, [self bottomSafeViewHeight]);
155+
156+
[rootView addSubview:bottomSafeView];
134157
}
135158
return self;
136159
}
137160

161+
- (NSInteger)bottomSafeViewHeight
162+
{
163+
if (@available(iOS 11.0, *)) {
164+
return [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;
165+
} else {
166+
return 0;
167+
}
168+
}
169+
138170
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
139171

140172
- (void)dealloc
@@ -247,14 +279,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
247279
- (UITableViewCell *)reuseCell:(UITableViewCell *)cell forErrorMessage:(NSString *)message
248280
{
249281
if (!cell) {
250-
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"msg-cell"];
282+
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"msg-cell"];
251283
cell.textLabel.accessibilityIdentifier = @"redbox-error";
252284
cell.textLabel.textColor = [UIColor whiteColor];
253285
cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
254286
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
255287
cell.textLabel.numberOfLines = 0;
256288
cell.detailTextLabel.textColor = [UIColor whiteColor];
257-
cell.backgroundColor = [UIColor clearColor];
289+
cell.backgroundColor = [UIColor colorWithRed:0.82 green:0.10 blue:0.15 alpha:1.0];
258290
cell.selectionStyle = UITableViewCellSelectionStyleNone;
259291
}
260292

@@ -267,11 +299,11 @@ - (UITableViewCell *)reuseCell:(UITableViewCell *)cell forStackFrame:(RCTJSStack
267299
{
268300
if (!cell) {
269301
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
270-
cell.textLabel.textColor = [UIColor colorWithWhite:1 alpha:0.9];
302+
cell.textLabel.textColor = [UIColor whiteColor];
271303
cell.textLabel.font = [UIFont fontWithName:@"Menlo-Regular" size:14];
272304
cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping;
273305
cell.textLabel.numberOfLines = 2;
274-
cell.detailTextLabel.textColor = [UIColor colorWithWhite:1 alpha:0.7];
306+
cell.detailTextLabel.textColor = [UIColor colorWithRed:0.70 green:0.70 blue:0.70 alpha:1.0];
275307
cell.detailTextLabel.font = [UIFont fontWithName:@"Menlo-Regular" size:11];
276308
cell.detailTextLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
277309
cell.backgroundColor = [UIColor clearColor];
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
3+
<item>
4+
<shape android:shape="rectangle" >
5+
<solid android:color="#1A1A1A" />
6+
</shape>
7+
</item>
8+
9+
<item android:bottom="-2dp" android:right="-2dp" android:left="-2dp">
10+
<shape>
11+
<solid android:color="@android:color/transparent" />
12+
<stroke
13+
android:width="1dp"
14+
android:color="#B3B3B3" />
15+
</shape>
16+
</item>
17+
</layer-list>

ReactAndroid/src/main/res/devsupport/layout/redbox_item_frame.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
android:id="@+id/rn_frame_file"
2020
android:layout_width="match_parent"
2121
android:layout_height="wrap_content"
22-
android:textColor="#E6B8B8"
22+
android:textColor="#B3B3B3"
2323
android:textSize="12sp"
2424
android:fontFamily="monospace"
2525
/>

ReactAndroid/src/main/res/devsupport/layout/redbox_item_title.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
android:textColor="@android:color/white"
88
android:textSize="16sp"
99
android:textStyle="bold"
10+
android:background="#D01926"
1011
/>

ReactAndroid/src/main/res/devsupport/layout/redbox_view.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
55
android:orientation="vertical"
6-
android:background="#E80000"
6+
android:background="#1A1A1A"
77
>
88
<ListView
99
android:id="@+id/rn_redbox_stack"
@@ -53,6 +53,7 @@
5353
android:layout_width="match_parent"
5454
android:layout_height="wrap_content"
5555
android:orientation="horizontal"
56+
android:background="@drawable/redbox_top_border_background"
5657
>
5758
<Button
5859
android:id="@+id/rn_redbox_dismiss_button"

ReactAndroid/src/main/res/devsupport/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<string name="catalyst_dismiss_button" project="catalyst" translatable="false">Dismiss\n(ESC)</string>
2222
<string name="catalyst_reload_button" project="catalyst" translatable="false">Reload\n(R,\u00A0R)</string>
2323
<string name="catalyst_poke_sampling_profiler" project="catalyst" translatable="false">Start/Stop Sampling Profiler</string>
24-
<string name="catalyst_copy_button" project="catalyst" translatable="false">Copy</string>
24+
<string name="catalyst_copy_button" project="catalyst" translatable="false">Copy\n</string>
2525
<string name="catalyst_report_button" project="catalyst" translatable="false">Report</string>
2626
<string name="catalyst_loading_from_url" project="catalyst" translatable="false">Loading from %1$s…</string>
2727
</resources>

0 commit comments

Comments
 (0)