| 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/settings/cells/card_multiline_item.h" | 5 #import "ios/chrome/browser/ui/settings/cells/card_multiline_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_components_ios/src/components/Typography/src/M
aterialTypography.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 namespace { | 14 namespace { |
| 15 // Padding used on the leading and trailing edges of the cell. | 15 // Padding used on the leading and trailing edges of the cell. |
| 16 const CGFloat kHorizontalPadding = 16; | 16 const CGFloat kHorizontalPadding = 16; |
| 17 | 17 |
| 18 // Padding used on the top and bottom edges of the cell. | 18 // Padding used on the top and bottom edges of the cell. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 46 | 46 |
| 47 - (instancetype)initWithFrame:(CGRect)frame { | 47 - (instancetype)initWithFrame:(CGRect)frame { |
| 48 self = [super initWithFrame:frame]; | 48 self = [super initWithFrame:frame]; |
| 49 if (self) { | 49 if (self) { |
| 50 UIView* contentView = self.contentView; | 50 UIView* contentView = self.contentView; |
| 51 | 51 |
| 52 _textLabel = [[UILabel alloc] init]; | 52 _textLabel = [[UILabel alloc] init]; |
| 53 _textLabel.translatesAutoresizingMaskIntoConstraints = NO; | 53 _textLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| 54 [contentView addSubview:_textLabel]; | 54 [contentView addSubview:_textLabel]; |
| 55 | 55 |
| 56 _textLabel.font = | 56 _textLabel.font = [MDCTypography body1Font]; |
| 57 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:14]; | |
| 58 _textLabel.textColor = [[MDCPalette greyPalette] tint900]; | 57 _textLabel.textColor = [[MDCPalette greyPalette] tint900]; |
| 59 _textLabel.numberOfLines = 0; | 58 _textLabel.numberOfLines = 0; |
| 60 | 59 |
| 61 // Set up the constraints. | 60 // Set up the constraints. |
| 62 [NSLayoutConstraint activateConstraints:@[ | 61 [NSLayoutConstraint activateConstraints:@[ |
| 63 [_textLabel.leadingAnchor | 62 [_textLabel.leadingAnchor |
| 64 constraintEqualToAnchor:contentView.leadingAnchor | 63 constraintEqualToAnchor:contentView.leadingAnchor |
| 65 constant:kHorizontalPadding], | 64 constant:kHorizontalPadding], |
| 66 [_textLabel.trailingAnchor | 65 [_textLabel.trailingAnchor |
| 67 constraintEqualToAnchor:contentView.trailingAnchor | 66 constraintEqualToAnchor:contentView.trailingAnchor |
| (...skipping 16 matching lines...) Expand all Loading... |
| 84 // changes, for instance on screen rotation. | 83 // changes, for instance on screen rotation. |
| 85 CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds); | 84 CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds); |
| 86 self.textLabel.preferredMaxLayoutWidth = parentWidth - 2 * kHorizontalPadding; | 85 self.textLabel.preferredMaxLayoutWidth = parentWidth - 2 * kHorizontalPadding; |
| 87 | 86 |
| 88 // Re-layout with the new preferred width to allow the label to adjust its | 87 // Re-layout with the new preferred width to allow the label to adjust its |
| 89 // height. | 88 // height. |
| 90 [super layoutSubviews]; | 89 [super layoutSubviews]; |
| 91 } | 90 } |
| 92 | 91 |
| 93 @end | 92 @end |
| OLD | NEW |