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

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

Issue 2699393003: Cleanup ContentSuggestions, removing unused functions (Closed)
Patch Set: Rebase 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 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_item.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_text_item .h"
6 6
7 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_item_acti ons.h" 7 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_text_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 ContentSuggestionsItem () 15 @interface ContentSuggestionsTextItem ()
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 ContentSuggestionsItem 22 @implementation ContentSuggestionsTextItem
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 = [ContentSuggestionsCell class]; 32 self.cellClass = [ContentSuggestionsTextCell 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:(ContentSuggestionsCell*)cell { 41 - (void)configureCell:(ContentSuggestionsTextCell*)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 - ContentSuggestionsCell 49 #pragma mark - ContentSuggestionsTextCell
50 50
51 @implementation ContentSuggestionsCell 51 @implementation ContentSuggestionsTextCell
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];
62 _titleButton.titleLabel.textColor = [[MDCPalette greyPalette] tint900]; 62 _titleButton.titleLabel.textColor = [[MDCPalette greyPalette] tint900];
63 [_titleButton addTarget:nil 63 [_titleButton addTarget:nil
64 action:@selector(addNewItem:) 64 action:@selector(addNewTextItem:)
65 forControlEvents:UIControlEventTouchUpInside]; 65 forControlEvents:UIControlEventTouchUpInside];
66 66
67 _detailTextLabel = [[UILabel alloc] init]; 67 _detailTextLabel = [[UILabel alloc] init];
68 _detailTextLabel.font = [fontLoader mediumFontOfSize:14]; 68 _detailTextLabel.font = [fontLoader mediumFontOfSize:14];
69 _detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; 69 _detailTextLabel.textColor = [[MDCPalette greyPalette] tint500];
70 70
71 UIStackView* labelsStack = [[UIStackView alloc] 71 UIStackView* labelsStack = [[UIStackView alloc]
72 initWithArrangedSubviews:@[ _titleButton, _detailTextLabel ]]; 72 initWithArrangedSubviews:@[ _titleButton, _detailTextLabel ]];
73 labelsStack.axis = UILayoutConstraintAxisVertical; 73 labelsStack.axis = UILayoutConstraintAxisVertical;
74 74
(...skipping 13 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