| 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_detail_item
.h" | 5 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item
.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 9 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 10 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 10 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." | 13 #error "This file requires ARC support." |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Padding used on the leading and trailing edges of the cell and between the | 18 // Padding used on the leading and trailing edges of the cell and between the |
| 19 // two labels. | 19 // two labels. |
| 20 const CGFloat kHorizontalPadding = 16; | 20 const CGFloat kHorizontalPadding = 16; |
| 21 | 21 |
| 22 // Minimum proportion of the available width to guarantee to the main and detail | 22 // Minimum proportion of the available width to guarantee to the main and detail |
| 23 // labels. | 23 // labels. |
| 24 const CGFloat kMinTextWidthRatio = 0.75f; | 24 const CGFloat kMinTextWidthRatio = 0.75f; |
| 25 const CGFloat kMinDetailTextWidthRatio = 0.25f; | 25 const CGFloat kMinDetailTextWidthRatio = 0.25f; |
| 26 } | 26 } |
| 27 | 27 |
| 28 @implementation CollectionViewDetailItem | 28 @implementation CollectionViewDetailItem |
| 29 | 29 |
| 30 @synthesize accessoryType = _accessoryType; | |
| 31 @synthesize text = _text; | 30 @synthesize text = _text; |
| 32 @synthesize detailText = _detailText; | 31 @synthesize detailText = _detailText; |
| 33 | 32 |
| 34 - (instancetype)initWithType:(NSInteger)type { | 33 - (instancetype)initWithType:(NSInteger)type { |
| 35 self = [super initWithType:type]; | 34 self = [super initWithType:type]; |
| 36 if (self) { | 35 if (self) { |
| 37 self.cellClass = [CollectionViewDetailCell class]; | 36 self.cellClass = [CollectionViewDetailCell class]; |
| 38 } | 37 } |
| 39 return self; | 38 return self; |
| 40 } | 39 } |
| 41 | 40 |
| 42 #pragma mark CollectionViewItem | 41 #pragma mark CollectionViewItem |
| 43 | 42 |
| 44 - (void)configureCell:(CollectionViewDetailCell*)cell { | 43 - (void)configureCell:(CollectionViewDetailCell*)cell { |
| 45 [super configureCell:cell]; | 44 [super configureCell:cell]; |
| 46 cell.accessoryType = self.accessoryType; | |
| 47 cell.textLabel.text = self.text; | 45 cell.textLabel.text = self.text; |
| 48 cell.detailTextLabel.text = self.detailText; | 46 cell.detailTextLabel.text = self.detailText; |
| 49 } | 47 } |
| 50 | 48 |
| 51 @end | 49 @end |
| 52 | 50 |
| 53 @implementation CollectionViewDetailCell { | 51 @implementation CollectionViewDetailCell { |
| 54 NSLayoutConstraint* _textLabelWidthConstraint; | 52 NSLayoutConstraint* _textLabelWidthConstraint; |
| 55 NSLayoutConstraint* _detailTextLabelWidthConstraint; | 53 NSLayoutConstraint* _detailTextLabelWidthConstraint; |
| 56 } | 54 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 158 |
| 161 - (NSString*)accessibilityLabel { | 159 - (NSString*)accessibilityLabel { |
| 162 return self.textLabel.text; | 160 return self.textLabel.text; |
| 163 } | 161 } |
| 164 | 162 |
| 165 - (NSString*)accessibilityValue { | 163 - (NSString*)accessibilityValue { |
| 166 return self.detailTextLabel.text; | 164 return self.detailTextLabel.text; |
| 167 } | 165 } |
| 168 | 166 |
| 169 @end | 167 @end |
| OLD | NEW |