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

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

Issue 2761753002: Cleanup ContentSuggestions cells (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 unified diff | Download patch
OLDNEW
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/content_suggestions/content_suggestions_text_item .h" 5 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_but ton_item.h"
6 6
7 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_text_item _actions.h" 7 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_but ton_item_actions.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 ContentSuggestionsTextItem () 15 @interface ContentSuggestionsButtonItem ()
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 ContentSuggestionsTextItem 22 @implementation ContentSuggestionsButtonItem
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 = [ContentSuggestionsTextCell class]; 32 self.cellClass = [ContentSuggestionsButtonCell 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:(ContentSuggestionsTextCell*)cell { 41 - (void)configureCell:(ContentSuggestionsButtonCell*)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 - ContentSuggestionsTextCell 49 #pragma mark - ContentSuggestionsButtonCell
50 50
51 @implementation ContentSuggestionsTextCell 51 @implementation ContentSuggestionsButtonCell
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698