OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_item.h" | 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_item.h" |
6 | 6 |
7 #import "ios/chrome/browser/ui/suggestions/suggestions_item_actions.h" | 7 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_item_acti
ons.h" |
8 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 8 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
9 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 9 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
10 | 10 |
11 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
12 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
13 #endif | 13 #endif |
14 | 14 |
15 @interface SuggestionsItem () | 15 @interface ContentSuggestionsItem () |
16 | 16 |
17 @property(nonatomic, copy) NSString* title; | 17 @property(nonatomic, copy) NSString* title; |
18 @property(nonatomic, copy) NSString* subtitle; | 18 @property(nonatomic, copy) NSString* subtitle; |
19 | 19 |
20 @end | 20 @end |
21 | 21 |
22 @implementation SuggestionsItem | 22 @implementation ContentSuggestionsItem |
23 | 23 |
24 @synthesize title = _title; | 24 @synthesize title = _title; |
25 @synthesize subtitle = _subtitle; | 25 @synthesize subtitle = _subtitle; |
26 | 26 |
27 - (instancetype)initWithType:(NSInteger)type | 27 - (instancetype)initWithType:(NSInteger)type |
28 title:(NSString*)title | 28 title:(NSString*)title |
29 subtitle:(NSString*)subtitle { | 29 subtitle:(NSString*)subtitle { |
30 self = [super initWithType:type]; | 30 self = [super initWithType:type]; |
31 if (self) { | 31 if (self) { |
32 self.cellClass = [SuggestionsCell class]; | 32 self.cellClass = [ContentSuggestionsCell class]; |
33 _title = [title copy]; | 33 _title = [title copy]; |
34 _subtitle = [subtitle copy]; | 34 _subtitle = [subtitle copy]; |
35 } | 35 } |
36 return self; | 36 return self; |
37 } | 37 } |
38 | 38 |
39 #pragma mark - CollectionViewItem | 39 #pragma mark - CollectionViewItem |
40 | 40 |
41 - (void)configureCell:(SuggestionsCell*)cell { | 41 - (void)configureCell:(ContentSuggestionsCell*)cell { |
42 [super configureCell:cell]; | 42 [super configureCell:cell]; |
43 [cell.titleButton setTitle:self.title forState:UIControlStateNormal]; | 43 [cell.titleButton setTitle:self.title forState:UIControlStateNormal]; |
44 cell.detailTextLabel.text = self.subtitle; | 44 cell.detailTextLabel.text = self.subtitle; |
45 } | 45 } |
46 | 46 |
47 @end | 47 @end |
48 | 48 |
49 #pragma mark - SuggestionsCell | 49 #pragma mark - ContentSuggestionsCell |
50 | 50 |
51 @implementation SuggestionsCell | 51 @implementation ContentSuggestionsCell |
52 | 52 |
53 @synthesize titleButton = _titleButton; | 53 @synthesize titleButton = _titleButton; |
54 @synthesize detailTextLabel = _detailTextLabel; | 54 @synthesize detailTextLabel = _detailTextLabel; |
55 | 55 |
56 - (instancetype)initWithFrame:(CGRect)frame { | 56 - (instancetype)initWithFrame:(CGRect)frame { |
57 self = [super initWithFrame:frame]; | 57 self = [super initWithFrame:frame]; |
58 if (self) { | 58 if (self) { |
59 id<MDCTypographyFontLoading> fontLoader = [MDCTypography fontLoader]; | 59 id<MDCTypographyFontLoading> fontLoader = [MDCTypography fontLoader]; |
60 _titleButton = [UIButton buttonWithType:UIButtonTypeSystem]; | 60 _titleButton = [UIButton buttonWithType:UIButtonTypeSystem]; |
61 _titleButton.titleLabel.font = [fontLoader mediumFontOfSize:16]; | 61 _titleButton.titleLabel.font = [fontLoader mediumFontOfSize:16]; |
(...skipping 26 matching lines...) Expand all Loading... |
88 [self.contentView.bottomAnchor | 88 [self.contentView.bottomAnchor |
89 constraintEqualToAnchor:labelsStack.bottomAnchor] | 89 constraintEqualToAnchor:labelsStack.bottomAnchor] |
90 ]]; | 90 ]]; |
91 | 91 |
92 self.backgroundColor = [UIColor whiteColor]; | 92 self.backgroundColor = [UIColor whiteColor]; |
93 } | 93 } |
94 return self; | 94 return self; |
95 } | 95 } |
96 | 96 |
97 @end | 97 @end |
OLD | NEW |