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_components_ios/src/components/Typography/src/M
aterialTypography.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; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 self = [super initWithFrame:frame]; | 65 self = [super initWithFrame:frame]; |
66 if (self) { | 66 if (self) { |
67 self.isAccessibilityElement = YES; | 67 self.isAccessibilityElement = YES; |
68 UIView* contentView = self.contentView; | 68 UIView* contentView = self.contentView; |
69 | 69 |
70 _textLabel = [[UILabel alloc] init]; | 70 _textLabel = [[UILabel alloc] init]; |
71 _textLabel.translatesAutoresizingMaskIntoConstraints = NO; | 71 _textLabel.translatesAutoresizingMaskIntoConstraints = NO; |
72 _textLabel.backgroundColor = [UIColor clearColor]; | 72 _textLabel.backgroundColor = [UIColor clearColor]; |
73 [contentView addSubview:_textLabel]; | 73 [contentView addSubview:_textLabel]; |
74 | 74 |
75 _textLabel.font = | 75 _textLabel.font = [[MDCTypography fontLoader] mediumFontOfSize:14]; |
76 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; | |
77 _textLabel.textColor = [[MDCPalette greyPalette] tint900]; | 76 _textLabel.textColor = [[MDCPalette greyPalette] tint900]; |
78 | 77 |
79 _detailTextLabel = [[UILabel alloc] init]; | 78 _detailTextLabel = [[UILabel alloc] init]; |
80 _detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO; | 79 _detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO; |
81 _detailTextLabel.backgroundColor = [UIColor clearColor]; | 80 _detailTextLabel.backgroundColor = [UIColor clearColor]; |
82 [contentView addSubview:_detailTextLabel]; | 81 [contentView addSubview:_detailTextLabel]; |
83 | 82 |
84 _detailTextLabel.font = | 83 _detailTextLabel.font = [[MDCTypography fontLoader] regularFontOfSize:14]; |
85 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:14]; | |
86 _detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; | 84 _detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; |
87 | 85 |
88 // Set up the width constraints. They are activated here and updated in | 86 // Set up the width constraints. They are activated here and updated in |
89 // layoutSubviews. | 87 // layoutSubviews. |
90 _textLabelWidthConstraint = | 88 _textLabelWidthConstraint = |
91 [_textLabel.widthAnchor constraintEqualToConstant:0]; | 89 [_textLabel.widthAnchor constraintEqualToConstant:0]; |
92 _detailTextLabelWidthConstraint = | 90 _detailTextLabelWidthConstraint = |
93 [_detailTextLabel.widthAnchor constraintEqualToConstant:0]; | 91 [_detailTextLabel.widthAnchor constraintEqualToConstant:0]; |
94 | 92 |
95 [NSLayoutConstraint activateConstraints:@[ | 93 [NSLayoutConstraint activateConstraints:@[ |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 163 |
166 - (NSString*)accessibilityLabel { | 164 - (NSString*)accessibilityLabel { |
167 return self.textLabel.text; | 165 return self.textLabel.text; |
168 } | 166 } |
169 | 167 |
170 - (NSString*)accessibilityValue { | 168 - (NSString*)accessibilityValue { |
171 return self.detailTextLabel.text; | 169 return self.detailTextLabel.text; |
172 } | 170 } |
173 | 171 |
174 @end | 172 @end |
OLD | NEW |