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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm

Issue 2691593002: Connect ContentSuggestionsMediator to the ContentService (Closed)
Patch Set: Address comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_article_i tem.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_article_i tem.h"
6 6
7 #import "ios/chrome/browser/ui/uikit_ui_util.h" 7 #import "ios/chrome/browser/ui/uikit_ui_util.h"
8 8
9 #if !defined(__has_feature) || !__has_feature(objc_arc) 9 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support." 10 #error "This file requires ARC support."
11 #endif 11 #endif
12 12
13 namespace { 13 namespace {
14 const CGFloat kImageSize = 100; 14 const CGFloat kImageSize = 100;
15 const CGFloat kStandardSpacing = 8; 15 const CGFloat kStandardSpacing = 8;
16 } 16 }
17 17
18 @interface ContentSuggestionsArticleItem () 18 @interface ContentSuggestionsArticleItem ()
19 19
20 @property(nonatomic, copy) NSString* title; 20 @property(nonatomic, copy) NSString* title;
21 @property(nonatomic, copy) NSString* subtitle; 21 @property(nonatomic, copy) NSString* subtitle;
22 22
23 @end 23 @end
24 24
25 #pragma mark - ContentSuggestionsArticleItem
26
25 @implementation ContentSuggestionsArticleItem 27 @implementation ContentSuggestionsArticleItem
26 28
27 @synthesize title = _title; 29 @synthesize title = _title;
28 @synthesize subtitle = _subtitle; 30 @synthesize subtitle = _subtitle;
29 @synthesize image = _image; 31 @synthesize image = _image;
30 @synthesize articleURL = _articleURL; 32 @synthesize articleURL = _articleURL;
31 33
32 - (instancetype)initWithType:(NSInteger)type 34 - (instancetype)initWithType:(NSInteger)type
33 title:(NSString*)title 35 title:(NSString*)title
34 subtitle:(NSString*)subtitle 36 subtitle:(NSString*)subtitle
(...skipping 12 matching lines...) Expand all
47 49
48 - (void)configureCell:(ContentSuggestionsArticleCell*)cell { 50 - (void)configureCell:(ContentSuggestionsArticleCell*)cell {
49 [super configureCell:cell]; 51 [super configureCell:cell];
50 cell.titleLabel.text = _title; 52 cell.titleLabel.text = _title;
51 cell.subtitleLabel.text = _subtitle; 53 cell.subtitleLabel.text = _subtitle;
52 cell.imageView.image = _image; 54 cell.imageView.image = _image;
53 } 55 }
54 56
55 @end 57 @end
56 58
59 #pragma mark - ContentSuggestionsArticleCell
60
57 @implementation ContentSuggestionsArticleCell 61 @implementation ContentSuggestionsArticleCell
58 62
59 @synthesize titleLabel = _titleLabel; 63 @synthesize titleLabel = _titleLabel;
60 @synthesize subtitleLabel = _subtitleLabel; 64 @synthesize subtitleLabel = _subtitleLabel;
61 @synthesize imageView = _imageView; 65 @synthesize imageView = _imageView;
62 66
63 - (instancetype)initWithFrame:(CGRect)frame { 67 - (instancetype)initWithFrame:(CGRect)frame {
64 self = [super initWithFrame:frame]; 68 self = [super initWithFrame:frame];
65 if (self) { 69 if (self) {
66 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 70 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // changes, for instance on screen rotation. 120 // changes, for instance on screen rotation.
117 CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds); 121 CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds);
118 self.subtitleLabel.preferredMaxLayoutWidth = parentWidth - kImageSize - 3 * 8; 122 self.subtitleLabel.preferredMaxLayoutWidth = parentWidth - kImageSize - 3 * 8;
119 123
120 // Re-layout with the new preferred width to allow the label to adjust its 124 // Re-layout with the new preferred width to allow the label to adjust its
121 // height. 125 // height.
122 [super layoutSubviews]; 126 [super layoutSubviews];
123 } 127 }
124 128
125 @end 129 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698