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

Side by Side Diff: ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.mm

Issue 2764783006: Create CollectionViewTextCell (Closed)
Patch Set: Add comment 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/collection_view/cells/collection_view_text_item.h " 5 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_item.h "
6 6
7 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_text_cell.h "
7 #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"
8 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 9 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h"
9 10
10 #if !defined(__has_feature) || !__has_feature(objc_arc) 11 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support." 12 #error "This file requires ARC support."
12 #endif 13 #endif
13 14
14 @implementation CollectionViewTextItem 15 @implementation CollectionViewTextItem
15 16
16 @synthesize accessoryType = _accessoryType; 17 @synthesize accessoryType = _accessoryType;
17 @synthesize text = _text; 18 @synthesize text = _text;
18 @synthesize detailText = _detailText; 19 @synthesize detailText = _detailText;
19 @synthesize image = _image;
20 @synthesize textFont = _textFont; 20 @synthesize textFont = _textFont;
21 @synthesize textColor = _textColor; 21 @synthesize textColor = _textColor;
22 @synthesize detailTextFont = _detailTextFont; 22 @synthesize detailTextFont = _detailTextFont;
23 @synthesize detailTextColor = _detailTextColor; 23 @synthesize detailTextColor = _detailTextColor;
24 24
25 - (instancetype)initWithType:(NSInteger)type { 25 - (instancetype)initWithType:(NSInteger)type {
26 self = [super initWithType:type]; 26 self = [super initWithType:type];
27 if (self) { 27 if (self) {
28 self.cellClass = [MDCCollectionViewTextCell class]; 28 self.cellClass = [CollectionViewTextCell class];
29 } 29 }
30 return self; 30 return self;
31 } 31 }
32 32
33 - (UIFont*)textFont { 33 - (UIFont*)textFont {
34 if (!_textFont) { 34 if (!_textFont) {
35 _textFont = [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; 35 _textFont = [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14];
36 } 36 }
37 return _textFont; 37 return _textFont;
38 } 38 }
(...skipping 15 matching lines...) Expand all
54 54
55 - (UIColor*)detailTextColor { 55 - (UIColor*)detailTextColor {
56 if (!_detailTextColor) { 56 if (!_detailTextColor) {
57 _detailTextColor = [[MDCPalette greyPalette] tint500]; 57 _detailTextColor = [[MDCPalette greyPalette] tint500];
58 } 58 }
59 return _detailTextColor; 59 return _detailTextColor;
60 } 60 }
61 61
62 #pragma mark CollectionViewItem 62 #pragma mark CollectionViewItem
63 63
64 - (void)configureCell:(MDCCollectionViewTextCell*)cell { 64 - (void)configureCell:(CollectionViewTextCell*)cell {
65 [super configureCell:cell]; 65 [super configureCell:cell];
66 cell.accessoryType = self.accessoryType; 66 cell.accessoryType = self.accessoryType;
67 cell.textLabel.text = self.text; 67 cell.textLabel.text = self.text;
68 cell.detailTextLabel.text = self.detailText; 68 cell.detailTextLabel.text = self.detailText;
69 cell.imageView.image = self.image;
70 cell.isAccessibilityElement = YES; 69 cell.isAccessibilityElement = YES;
71 if (self.detailText.length == 0) { 70 if (self.detailText.length == 0) {
72 cell.accessibilityLabel = self.text; 71 cell.accessibilityLabel = self.text;
73 } else { 72 } else {
74 cell.accessibilityLabel = 73 cell.accessibilityLabel =
75 [NSString stringWithFormat:@"%@, %@", self.text, self.detailText]; 74 [NSString stringWithFormat:@"%@, %@", self.text, self.detailText];
76 } 75 }
77 76
78 // Styling. 77 // Styling.
79 cell.textLabel.font = self.textFont; 78 cell.textLabel.font = self.textFont;
80 cell.textLabel.textColor = self.textColor; 79 cell.textLabel.textColor = self.textColor;
81 cell.detailTextLabel.font = self.detailTextFont; 80 cell.detailTextLabel.font = self.detailTextFont;
82 cell.detailTextLabel.textColor = self.detailTextColor; 81 cell.detailTextLabel.textColor = self.detailTextColor;
83 } 82 }
84 83
85 @end 84 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698