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/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/third_party/material_components_ios/src/components/Palettes/src/Mat erialPalettes.h" | 7 #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" | 8 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" |
9 | 9 |
10 #if !defined(__has_feature) || !__has_feature(objc_arc) | 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
11 #error "This file requires ARC support." | 11 #error "This file requires ARC support." |
12 #endif | 12 #endif |
13 | 13 |
14 @implementation CollectionViewTextItem | 14 @implementation CollectionViewTextItem |
15 | 15 |
16 @synthesize accessoryType = _accessoryType; | 16 @synthesize accessoryType = _accessoryType; |
17 @synthesize text = _text; | 17 @synthesize text = _text; |
18 @synthesize detailText = _detailText; | 18 @synthesize detailText = _detailText; |
19 @synthesize image = _image; | 19 @synthesize image = _image; |
20 @synthesize textFont = _textFont; | |
21 @synthesize textColor = _textColor; | |
22 @synthesize detailTextFont = _detailTextFont; | |
23 @synthesize detailTextColor = _detailTextColor; | |
20 | 24 |
21 - (instancetype)initWithType:(NSInteger)type { | 25 - (instancetype)initWithType:(NSInteger)type { |
22 self = [super initWithType:type]; | 26 self = [super initWithType:type]; |
23 if (self) { | 27 if (self) { |
24 self.cellClass = [MDCCollectionViewTextCell class]; | 28 self.cellClass = [MDCCollectionViewTextCell class]; |
29 _textFont = [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; | |
30 _textColor = [[MDCPalette greyPalette] tint900]; | |
31 _detailTextFont = | |
32 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:14]; | |
33 _detailTextColor = [[MDCPalette greyPalette] tint500]; | |
25 } | 34 } |
26 return self; | 35 return self; |
27 } | 36 } |
28 | 37 |
38 - (void)setTextFont:(UIFont*)textFont { | |
lpromero
2017/01/13 10:13:26
Could you do something like this:
- (UIFont*)text
Moe
2017/01/13 15:28:19
Done.
| |
39 if (textFont) { | |
40 _textFont = textFont; | |
41 } | |
42 } | |
43 | |
44 - (void)setTextColor:(UIColor*)textColor { | |
45 if (textColor) { | |
46 _textColor = textColor; | |
47 } | |
48 } | |
49 | |
50 - (void)setDetailTextFont:(UIFont*)detailTextFont { | |
51 if (detailTextFont) { | |
52 _detailTextFont = detailTextFont; | |
53 } | |
54 } | |
55 | |
56 - (void)setDetailTextColor:(UIColor*)detailTextColor { | |
57 if (detailTextColor) { | |
58 _detailTextColor = detailTextColor; | |
59 } | |
60 } | |
61 | |
29 #pragma mark CollectionViewItem | 62 #pragma mark CollectionViewItem |
30 | 63 |
31 - (void)configureCell:(MDCCollectionViewTextCell*)cell { | 64 - (void)configureCell:(MDCCollectionViewTextCell*)cell { |
32 [super configureCell:cell]; | 65 [super configureCell:cell]; |
33 cell.accessoryType = self.accessoryType; | 66 cell.accessoryType = self.accessoryType; |
34 cell.textLabel.text = self.text; | 67 cell.textLabel.text = self.text; |
35 cell.detailTextLabel.text = self.detailText; | 68 cell.detailTextLabel.text = self.detailText; |
36 cell.imageView.image = self.image; | 69 cell.imageView.image = self.image; |
37 cell.isAccessibilityElement = YES; | 70 cell.isAccessibilityElement = YES; |
38 if (self.detailText.length == 0) { | 71 if (self.detailText.length == 0) { |
39 cell.accessibilityLabel = self.text; | 72 cell.accessibilityLabel = self.text; |
40 } else { | 73 } else { |
41 cell.accessibilityLabel = | 74 cell.accessibilityLabel = |
42 [NSString stringWithFormat:@"%@, %@", self.text, self.detailText]; | 75 [NSString stringWithFormat:@"%@, %@", self.text, self.detailText]; |
43 } | 76 } |
44 | 77 |
45 // Styling. | 78 // Styling. |
46 cell.textLabel.font = | 79 cell.textLabel.font = self.textFont; |
47 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; | 80 cell.textLabel.textColor = self.textColor; |
48 cell.textLabel.textColor = [[MDCPalette greyPalette] tint900]; | 81 cell.detailTextLabel.font = self.detailTextFont; |
49 | 82 cell.detailTextLabel.textColor = self.detailTextColor; |
50 cell.detailTextLabel.font = | |
51 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:14]; | |
52 cell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; | |
53 } | 83 } |
54 | 84 |
55 @end | 85 @end |
OLD | NEW |