| 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/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 numberOfTextLines = _numberOfTextLines; |
| 22 @synthesize detailTextFont = _detailTextFont; | 23 @synthesize detailTextFont = _detailTextFont; |
| 23 @synthesize detailTextColor = _detailTextColor; | 24 @synthesize detailTextColor = _detailTextColor; |
| 25 @synthesize numberOfDetailTextLines = _numberOfDetailTextLines; |
| 24 | 26 |
| 25 - (instancetype)initWithType:(NSInteger)type { | 27 - (instancetype)initWithType:(NSInteger)type { |
| 26 self = [super initWithType:type]; | 28 self = [super initWithType:type]; |
| 27 if (self) { | 29 if (self) { |
| 28 self.cellClass = [MDCCollectionViewTextCell class]; | 30 self.cellClass = [CollectionViewTextCell class]; |
| 31 _numberOfTextLines = 1; |
| 32 _numberOfDetailTextLines = 1; |
| 29 } | 33 } |
| 30 return self; | 34 return self; |
| 31 } | 35 } |
| 32 | 36 |
| 33 - (UIFont*)textFont { | 37 - (UIFont*)textFont { |
| 34 if (!_textFont) { | 38 if (!_textFont) { |
| 35 _textFont = [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; | 39 _textFont = [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; |
| 36 } | 40 } |
| 37 return _textFont; | 41 return _textFont; |
| 38 } | 42 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 54 | 58 |
| 55 - (UIColor*)detailTextColor { | 59 - (UIColor*)detailTextColor { |
| 56 if (!_detailTextColor) { | 60 if (!_detailTextColor) { |
| 57 _detailTextColor = [[MDCPalette greyPalette] tint500]; | 61 _detailTextColor = [[MDCPalette greyPalette] tint500]; |
| 58 } | 62 } |
| 59 return _detailTextColor; | 63 return _detailTextColor; |
| 60 } | 64 } |
| 61 | 65 |
| 62 #pragma mark CollectionViewItem | 66 #pragma mark CollectionViewItem |
| 63 | 67 |
| 64 - (void)configureCell:(MDCCollectionViewTextCell*)cell { | 68 - (void)configureCell:(CollectionViewTextCell*)cell { |
| 65 [super configureCell:cell]; | 69 [super configureCell:cell]; |
| 66 cell.accessoryType = self.accessoryType; | 70 cell.accessoryType = self.accessoryType; |
| 67 cell.textLabel.text = self.text; | 71 cell.textLabel.text = self.text; |
| 68 cell.detailTextLabel.text = self.detailText; | 72 cell.detailTextLabel.text = self.detailText; |
| 69 cell.imageView.image = self.image; | |
| 70 cell.isAccessibilityElement = YES; | 73 cell.isAccessibilityElement = YES; |
| 71 if (self.detailText.length == 0) { | 74 if (self.detailText.length == 0) { |
| 72 cell.accessibilityLabel = self.text; | 75 cell.accessibilityLabel = self.text; |
| 73 } else { | 76 } else { |
| 74 cell.accessibilityLabel = | 77 cell.accessibilityLabel = |
| 75 [NSString stringWithFormat:@"%@, %@", self.text, self.detailText]; | 78 [NSString stringWithFormat:@"%@, %@", self.text, self.detailText]; |
| 76 } | 79 } |
| 77 | 80 |
| 78 // Styling. | 81 // Styling. |
| 79 cell.textLabel.font = self.textFont; | 82 cell.textLabel.font = self.textFont; |
| 80 cell.textLabel.textColor = self.textColor; | 83 cell.textLabel.textColor = self.textColor; |
| 84 cell.textLabel.numberOfLines = self.numberOfTextLines; |
| 81 cell.detailTextLabel.font = self.detailTextFont; | 85 cell.detailTextLabel.font = self.detailTextFont; |
| 82 cell.detailTextLabel.textColor = self.detailTextColor; | 86 cell.detailTextLabel.textColor = self.detailTextColor; |
| 87 cell.detailTextLabel.numberOfLines = self.numberOfDetailTextLines; |
| 83 } | 88 } |
| 84 | 89 |
| 85 @end | 90 @end |
| OLD | NEW |