OLD | NEW |
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/suggestions/suggestions_article_item.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 } | 15 } |
16 | 16 |
17 @interface SuggestionsArticleItem () | 17 @interface ContentSuggestionsArticleItem () |
18 | 18 |
19 @property(nonatomic, copy) NSString* title; | 19 @property(nonatomic, copy) NSString* title; |
20 @property(nonatomic, copy) NSString* subtitle; | 20 @property(nonatomic, copy) NSString* subtitle; |
21 @property(nonatomic, strong) UIImage* image; | 21 @property(nonatomic, strong) UIImage* image; |
22 | 22 |
23 @end | 23 @end |
24 | 24 |
25 @implementation SuggestionsArticleItem | 25 @implementation ContentSuggestionsArticleItem |
26 | 26 |
27 @synthesize title = _title; | 27 @synthesize title = _title; |
28 @synthesize subtitle = _subtitle; | 28 @synthesize subtitle = _subtitle; |
29 @synthesize image = _image; | 29 @synthesize image = _image; |
30 | 30 |
31 - (instancetype)initWithType:(NSInteger)type | 31 - (instancetype)initWithType:(NSInteger)type |
32 title:(NSString*)title | 32 title:(NSString*)title |
33 subtitle:(NSString*)subtitle | 33 subtitle:(NSString*)subtitle |
34 image:(UIImage*)image { | 34 image:(UIImage*)image { |
35 self = [super initWithType:type]; | 35 self = [super initWithType:type]; |
36 if (self) { | 36 if (self) { |
37 self.cellClass = [SuggestionsArticleCell class]; | 37 self.cellClass = [ContentSuggestionsArticleCell class]; |
38 _title = [title copy]; | 38 _title = [title copy]; |
39 _subtitle = [subtitle copy]; | 39 _subtitle = [subtitle copy]; |
40 _image = image; | 40 _image = image; |
41 } | 41 } |
42 return self; | 42 return self; |
43 } | 43 } |
44 | 44 |
45 - (void)configureCell:(SuggestionsArticleCell*)cell { | 45 - (void)configureCell:(ContentSuggestionsArticleCell*)cell { |
46 [super configureCell:cell]; | 46 [super configureCell:cell]; |
47 cell.titleLabel.text = _title; | 47 cell.titleLabel.text = _title; |
48 cell.subtitleLabel.text = _subtitle; | 48 cell.subtitleLabel.text = _subtitle; |
49 cell.imageView.image = _image; | 49 cell.imageView.image = _image; |
50 } | 50 } |
51 | 51 |
52 @end | 52 @end |
53 | 53 |
54 @implementation SuggestionsArticleCell | 54 @implementation ContentSuggestionsArticleCell |
55 | 55 |
56 @synthesize titleLabel = _titleLabel; | 56 @synthesize titleLabel = _titleLabel; |
57 @synthesize subtitleLabel = _subtitleLabel; | 57 @synthesize subtitleLabel = _subtitleLabel; |
58 @synthesize imageView = _imageView; | 58 @synthesize imageView = _imageView; |
59 | 59 |
60 - (instancetype)initWithFrame:(CGRect)frame { | 60 - (instancetype)initWithFrame:(CGRect)frame { |
61 self = [super initWithFrame:frame]; | 61 self = [super initWithFrame:frame]; |
62 if (self) { | 62 if (self) { |
63 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | 63 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
64 _subtitleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | 64 _subtitleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // changes, for instance on screen rotation. | 106 // changes, for instance on screen rotation. |
107 CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds); | 107 CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds); |
108 self.subtitleLabel.preferredMaxLayoutWidth = parentWidth - kImageSize - 3 * 8; | 108 self.subtitleLabel.preferredMaxLayoutWidth = parentWidth - kImageSize - 3 * 8; |
109 | 109 |
110 // Re-layout with the new preferred width to allow the label to adjust its | 110 // Re-layout with the new preferred width to allow the label to adjust its |
111 // height. | 111 // height. |
112 [super layoutSubviews]; | 112 [super layoutSubviews]; |
113 } | 113 } |
114 | 114 |
115 @end | 115 @end |
OLD | NEW |