| 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]; |
| 25 } | 29 } |
| 26 return self; | 30 return self; |
| 27 } | 31 } |
| 28 | 32 |
| 33 - (UIFont*)textFont { |
| 34 if (!_textFont) { |
| 35 _textFont = [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; |
| 36 } |
| 37 return _textFont; |
| 38 } |
| 39 |
| 40 - (UIColor*)textColor { |
| 41 if (!_textColor) { |
| 42 _textColor = [[MDCPalette greyPalette] tint900]; |
| 43 } |
| 44 return _textColor; |
| 45 } |
| 46 |
| 47 - (UIFont*)detailTextFont { |
| 48 if (!_detailTextFont) { |
| 49 _detailTextFont = |
| 50 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:14]; |
| 51 } |
| 52 return _detailTextFont; |
| 53 } |
| 54 |
| 55 - (UIColor*)detailTextColor { |
| 56 if (!_detailTextColor) { |
| 57 _detailTextColor = [[MDCPalette greyPalette] tint500]; |
| 58 } |
| 59 return _detailTextColor; |
| 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 |