Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Unified Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm

Issue 2734763003: Default background for not suggested article images (Closed)
Patch Set: Fix tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm
index 2ee2912b75f08daaea65b9ca5ca31bf525d00060..ecc4581bbc02e9e79fdadc5d8c45679f8fd3d5c2 100644
--- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm
+++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm
@@ -56,16 +56,16 @@ const CGFloat kStandardSpacing = 8;
_subtitle = [subtitle copy];
_articleURL = url;
_delegate = delegate;
+ _image = [self emptyImageBackground];
}
return self;
}
- (void)configureCell:(ContentSuggestionsArticleCell*)cell {
[super configureCell:cell];
- if (!self.image && !self.imageFetched) {
+ if (!self.imageFetched) {
self.imageFetched = YES;
- // Fetch the image. During the fetch the cell's image should still be set to
- // nil.
+ // Fetch the image. During the fetch the cell's image should still be set.
[self.delegate loadImageForArticleItem:self];
}
cell.titleLabel.text = self.title;
@@ -74,6 +74,21 @@ const CGFloat kStandardSpacing = 8;
[cell setPublisherName:self.publisher date:self.publishDate];
}
+#pragma mark - Private
+
+- (UIImage*)emptyImageBackground {
+ // TODO(crbug.com/698171): Remove this function once we have real background
+ // image.
+ UIColor* color = [UIColor lightGrayColor];
+ CGRect rect = CGRectMake(0, 0, 1, 1);
+ UIGraphicsBeginImageContext(rect.size);
+ [color setFill];
+ UIRectFill(rect);
+ UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
+ UIGraphicsEndImageContext();
+ return image;
+}
+
@end
#pragma mark - ContentSuggestionsArticleCell
@@ -156,9 +171,9 @@ const CGFloat kStandardSpacing = 8;
CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds);
self.titleLabel.preferredMaxLayoutWidth =
- parentWidth - self.imageView.bounds.size.width - 3 * kStandardSpacing;
+ parentWidth - kImageSize - 3 * kStandardSpacing;
self.subtitleLabel.preferredMaxLayoutWidth =
- parentWidth - self.imageView.bounds.size.width - 3 * kStandardSpacing;
+ parentWidth - kImageSize - 3 * kStandardSpacing;
// Re-layout with the new preferred width to allow the label to adjust its
// height.
« no previous file with comments | « no previous file | ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698