-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated RedBox screen #22242
Updated RedBox screen #22242
Changes from all commits
737b04f
b203c9d
1e13f37
d8af495
5fa32b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ - (instancetype)initWithFrame:(CGRect)frame | |
#else | ||
self.windowLevel = UIWindowLevelStatusBar - 1; | ||
#endif | ||
self.backgroundColor = [UIColor colorWithRed:0.8 green:0 blue:0 alpha:1]; | ||
self.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1]; | ||
self.hidden = YES; | ||
|
||
UIViewController *rootController = [UIViewController new]; | ||
|
@@ -58,7 +58,7 @@ - (instancetype)initWithFrame:(CGRect)frame | |
const CGFloat buttonHeight = 60; | ||
|
||
CGRect detailsFrame = rootView.bounds; | ||
detailsFrame.size.height -= buttonHeight; | ||
detailsFrame.size.height -= buttonHeight + [self bottomSafeViewHeight]; | ||
|
||
_stackTraceTableView = [[UITableView alloc] initWithFrame:detailsFrame style:UITableViewStylePlain]; | ||
_stackTraceTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
|
@@ -73,10 +73,10 @@ - (instancetype)initWithFrame:(CGRect)frame | |
[rootView addSubview:_stackTraceTableView]; | ||
|
||
#if TARGET_OS_SIMULATOR | ||
NSString *reloadText = @"Reload JS (\u2318R)"; | ||
NSString *dismissText = @"Dismiss (ESC)"; | ||
NSString *copyText = @"Copy (\u2325\u2318C)"; | ||
NSString *extraText = @"Extra Info (\u2318E)"; | ||
NSString *reloadText = @"Reload\n(\u2318R)"; | ||
NSString *dismissText = @"Dismiss\n(ESC)"; | ||
NSString *copyText = @"Copy\n(\u2325\u2318C)"; | ||
NSString *extraText = @"Extra Info\n(\u2318E)"; | ||
#else | ||
NSString *reloadText = @"Reload JS"; | ||
NSString *dismissText = @"Dismiss"; | ||
|
@@ -88,53 +88,85 @@ - (instancetype)initWithFrame:(CGRect)frame | |
dismissButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin; | ||
dismissButton.accessibilityIdentifier = @"redbox-dismiss"; | ||
dismissButton.titleLabel.font = [UIFont systemFontOfSize:13]; | ||
dismissButton.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; | ||
dismissButton.titleLabel.textAlignment = NSTextAlignmentCenter; | ||
dismissButton.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1]; | ||
[dismissButton setTitle:dismissText forState:UIControlStateNormal]; | ||
[dismissButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateNormal]; | ||
[dismissButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted]; | ||
[dismissButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | ||
[dismissButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted]; | ||
[dismissButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
UIButton *reloadButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
reloadButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin; | ||
reloadButton.accessibilityIdentifier = @"redbox-reload"; | ||
reloadButton.titleLabel.font = [UIFont systemFontOfSize:13]; | ||
|
||
reloadButton.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; | ||
reloadButton.titleLabel.textAlignment = NSTextAlignmentCenter; | ||
reloadButton.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1]; | ||
[reloadButton setTitle:reloadText forState:UIControlStateNormal]; | ||
[reloadButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateNormal]; | ||
[reloadButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted]; | ||
[reloadButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | ||
[reloadButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted]; | ||
[reloadButton addTarget:self action:@selector(reload) forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
UIButton *copyButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
copyButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin; | ||
copyButton.accessibilityIdentifier = @"redbox-copy"; | ||
copyButton.titleLabel.font = [UIFont systemFontOfSize:13]; | ||
copyButton.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; | ||
copyButton.titleLabel.textAlignment = NSTextAlignmentCenter; | ||
copyButton.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1]; | ||
[copyButton setTitle:copyText forState:UIControlStateNormal]; | ||
[copyButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateNormal]; | ||
[copyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted]; | ||
[copyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | ||
[copyButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted]; | ||
[copyButton addTarget:self action:@selector(copyStack) forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
UIButton *extraButton = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
extraButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin; | ||
extraButton.accessibilityIdentifier = @"redbox-extra"; | ||
extraButton.titleLabel.font = [UIFont systemFontOfSize:13]; | ||
extraButton.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; | ||
extraButton.titleLabel.textAlignment = NSTextAlignmentCenter; | ||
extraButton.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1]; | ||
[extraButton setTitle:extraText forState:UIControlStateNormal]; | ||
[extraButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateNormal]; | ||
[extraButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted]; | ||
[extraButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; | ||
[extraButton setTitleColor:[UIColor colorWithWhite:1 alpha:0.5] forState:UIControlStateHighlighted]; | ||
[extraButton addTarget:self action:@selector(showExtraDataViewController) forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
CGFloat buttonWidth = self.bounds.size.width / 4; | ||
dismissButton.frame = CGRectMake(0, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight); | ||
reloadButton.frame = CGRectMake(buttonWidth, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight); | ||
copyButton.frame = CGRectMake(buttonWidth * 2, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight); | ||
extraButton.frame = CGRectMake(buttonWidth * 3, self.bounds.size.height - buttonHeight, buttonWidth, buttonHeight); | ||
CGFloat bottomButtonHeight = self.bounds.size.height - buttonHeight - [self bottomSafeViewHeight]; | ||
|
||
dismissButton.frame = CGRectMake(0, bottomButtonHeight, buttonWidth, buttonHeight); | ||
reloadButton.frame = CGRectMake(buttonWidth, bottomButtonHeight, buttonWidth, buttonHeight); | ||
copyButton.frame = CGRectMake(buttonWidth * 2, bottomButtonHeight, buttonWidth, buttonHeight); | ||
extraButton.frame = CGRectMake(buttonWidth * 3, bottomButtonHeight, buttonWidth, buttonHeight); | ||
|
||
UIView *topBorder = [[UIView alloc] initWithFrame:CGRectMake(0, bottomButtonHeight + 1, rootView.frame.size.width, 1)]; | ||
topBorder.backgroundColor = [UIColor colorWithRed:0.70 green:0.70 blue:0.70 alpha:1.0]; | ||
|
||
[rootView addSubview:dismissButton]; | ||
[rootView addSubview:reloadButton]; | ||
[rootView addSubview:copyButton]; | ||
[rootView addSubview:extraButton]; | ||
[rootView addSubview:topBorder]; | ||
|
||
UIView *bottomSafeView = [UIView new]; | ||
bottomSafeView.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1]; | ||
bottomSafeView.frame = CGRectMake(0, self.bounds.size.height - [self bottomSafeViewHeight], self.bounds.size.width, [self bottomSafeViewHeight]); | ||
|
||
[rootView addSubview:bottomSafeView]; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSInteger)bottomSafeViewHeight | ||
{ | ||
if (@available(iOS 11.0, *)) { | ||
return [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kelset this is not ideal as the code is redundant with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah there's no easy way to reuse that function unless we extract it out to a util module. I think this could work: @shergin what's the best way to do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @frantic quick follow up: when I try to use the
I looked up a few issues on stack overflow and I figure out that I need to do this instead:
Hence I came up with this which is pretty abstracted and much better than what I had before. Thanks for the suggestion. 👍
|
||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) | ||
|
||
- (void)dealloc | ||
|
@@ -247,14 +279,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N | |
- (UITableViewCell *)reuseCell:(UITableViewCell *)cell forErrorMessage:(NSString *)message | ||
{ | ||
if (!cell) { | ||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"msg-cell"]; | ||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"msg-cell"]; | ||
cell.textLabel.accessibilityIdentifier = @"redbox-error"; | ||
cell.textLabel.textColor = [UIColor whiteColor]; | ||
cell.textLabel.font = [UIFont boldSystemFontOfSize:16]; | ||
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping; | ||
cell.textLabel.numberOfLines = 0; | ||
cell.detailTextLabel.textColor = [UIColor whiteColor]; | ||
cell.backgroundColor = [UIColor clearColor]; | ||
cell.backgroundColor = [UIColor colorWithRed:0.82 green:0.10 blue:0.15 alpha:1.0]; | ||
cell.selectionStyle = UITableViewCellSelectionStyleNone; | ||
} | ||
|
||
|
@@ -267,11 +299,11 @@ - (UITableViewCell *)reuseCell:(UITableViewCell *)cell forStackFrame:(RCTJSStack | |
{ | ||
if (!cell) { | ||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"]; | ||
cell.textLabel.textColor = [UIColor colorWithWhite:1 alpha:0.9]; | ||
cell.textLabel.textColor = [UIColor whiteColor]; | ||
cell.textLabel.font = [UIFont fontWithName:@"Menlo-Regular" size:14]; | ||
cell.textLabel.lineBreakMode = NSLineBreakByCharWrapping; | ||
cell.textLabel.numberOfLines = 2; | ||
cell.detailTextLabel.textColor = [UIColor colorWithWhite:1 alpha:0.7]; | ||
cell.detailTextLabel.textColor = [UIColor colorWithRed:0.70 green:0.70 blue:0.70 alpha:1.0]; | ||
cell.detailTextLabel.font = [UIFont fontWithName:@"Menlo-Regular" size:11]; | ||
cell.detailTextLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; | ||
cell.backgroundColor = [UIColor clearColor]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > | ||
<item> | ||
<shape android:shape="rectangle" > | ||
<solid android:color="#1A1A1A" /> | ||
</shape> | ||
</item> | ||
|
||
<item android:bottom="-2dp" android:right="-2dp" android:left="-2dp"> | ||
<shape> | ||
<solid android:color="@android:color/transparent" /> | ||
<stroke | ||
android:width="1dp" | ||
android:color="#B3B3B3" /> | ||
</shape> | ||
</item> | ||
</layer-list> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kelset Also ideally all those buttons should be in a func that just takes a param and returns a
UIButton
.This would clean up the code a lot, but I haven’t done Obj-C in a while. Let me know if that makes sense, and if something like would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay for now. Refactoring the buttons is probably outside of the scope of this change