Commit af3e9c30 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Renaming TableViewImageCell.titleLabel to TableViewImageCell.textLabel

Some of the code were using TableViewImageCell.textLabel, without compiler
errors, since UITableView.textLabel exists. To avoid any errors, titleLabel
is renamed into textLabel.

Bug introduced:
crrev.com/c/1478795

Change-Id: I5c07d31565d7c23a212a44103371a311ef327e66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1503575Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638352}
parent e6cf69a4
......@@ -15,7 +15,7 @@
// The image in the cell. If nil, won't be added to the view hierarchy.
@property(nonatomic, readwrite, strong) UIImage* image;
// The title label in the cell.
// The text label in the cell.
@property(nonatomic, readwrite, copy) NSString* title;
// UIColor for the cell's textLabel. ChromeTableViewStyler's |cellTitleColor|
// takes precedence over black color, but not over |textColor|.
......@@ -34,13 +34,14 @@
@end
// TableViewImageCell contains a favicon, a title, and an optional chevron.
// TableViewImageCell contains a favicon, a text, an optional detail text and an
// optional chevron.
@interface TableViewImageCell : TableViewCell
// The cell favicon imageView.
@property(nonatomic, readonly, strong) UIImageView* imageView;
// The cell title.
@property(nonatomic, readonly, strong) UILabel* titleLabel;
// The cell text.
@property(nonatomic, readonly, strong) UILabel* textLabel;
// The cell detail text.
@property(nonatomic, readonly, strong) UILabel* detailTextLabel;
......
......@@ -42,17 +42,17 @@
cell.imageView.hidden = YES;
}
cell.titleLabel.text = self.title;
cell.textLabel.text = self.title;
cell.detailTextLabel.text = self.detailText;
UIColor* cellBackgroundColor = styler.cellBackgroundColor
? styler.cellBackgroundColor
: styler.tableViewBackgroundColor;
cell.imageView.backgroundColor = cellBackgroundColor;
cell.titleLabel.backgroundColor = cellBackgroundColor;
cell.textLabel.backgroundColor = cellBackgroundColor;
if (self.textColor) {
cell.titleLabel.textColor = self.textColor;
cell.textLabel.textColor = self.textColor;
} else if (styler.cellTitleColor) {
cell.titleLabel.textColor = styler.cellTitleColor;
cell.textLabel.textColor = styler.cellTitleColor;
} else {
cell.textLabel.textColor = UIColor.blackColor;
}
......@@ -72,6 +72,7 @@
// These properties overrides the ones from UITableViewCell, so this @synthesize
// cannot be removed.
@synthesize textLabel = _textLabel;
@synthesize detailTextLabel = _detailTextLabel;
@synthesize imageView = _imageView;
......@@ -87,10 +88,10 @@
forAxis:UILayoutConstraintAxisHorizontal];
// Set font size using dynamic type.
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_titleLabel.adjustsFontForContentSizeCategory = YES;
[_titleLabel
_textLabel = [[UILabel alloc] init];
_textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_textLabel.adjustsFontForContentSizeCategory = YES;
[_textLabel
setContentCompressionResistancePriority:UILayoutPriorityDefaultLow
forAxis:
UILayoutConstraintAxisHorizontal];
......@@ -101,7 +102,7 @@
_detailTextLabel.numberOfLines = 0;
UIStackView* verticalStack = [[UIStackView alloc]
initWithArrangedSubviews:@[ _titleLabel, _detailTextLabel ]];
initWithArrangedSubviews:@[ _textLabel, _detailTextLabel ]];
verticalStack.translatesAutoresizingMaskIntoConstraints = NO;
verticalStack.axis = UILayoutConstraintAxisVertical;
verticalStack.spacing = 0;
......@@ -185,10 +186,10 @@
- (NSString*)accessibilityLabel {
if (self.detailTextLabel.text) {
return [NSString stringWithFormat:@"%@, %@", self.titleLabel.text,
return [NSString stringWithFormat:@"%@, %@", self.textLabel.text,
self.detailTextLabel.text];
}
return self.titleLabel.text;
return self.textLabel.text;
}
@end
......@@ -39,7 +39,7 @@ TEST_F(TableViewImageItemTest, ItemProperties) {
EXPECT_FALSE(imageCell.imageView.image);
[item configureCell:cell withStyler:[[ChromeTableViewStyler alloc] init]];
EXPECT_NSEQ(text, imageCell.titleLabel.text);
EXPECT_NSEQ(text, imageCell.textLabel.text);
EXPECT_NSEQ(detailText, imageCell.detailTextLabel.text);
EXPECT_FALSE(imageCell.imageView.isHidden);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment