Commit 76df7f9c authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Change settings cell appearance

This CL changes the height of the cells, making sure that they have 48pt
when they only have one line of text, 58 when they have two lines.
It also unifies the different font for the subtitles to Footnote.

Bug: 922511
Change-Id: I669e6de5ae8e85fed9f8da1458dd48e986c57126
Reviewed-on: https://chromium-review.googlesource.com/c/1474755Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633705}
parent dbcff222
......@@ -101,7 +101,7 @@
_detailTextLabel = [[UILabel alloc] init];
_detailTextLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
_detailTextLabel.adjustsFontForContentSizeCategory = YES;
_detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
_detailTextLabel.numberOfLines = 0;
......
......@@ -131,7 +131,7 @@ const CGFloat kHorizontalErrorIconFixedSize = 25;
_detailTextLabel = [[UILabel alloc] init];
_detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
_detailTextLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
_detailTextLabel.adjustsFontForContentSizeCategory = YES;
_detailTextLabel.textColor = UIColorFromRGB(kSettingsCellsDetailTextColor);
[contentView addSubview:_detailTextLabel];
......@@ -169,10 +169,10 @@ const CGFloat kHorizontalErrorIconFixedSize = 25;
constraintEqualToAnchor:contentView.centerYAnchor],
[_imageView.topAnchor
constraintGreaterThanOrEqualToAnchor:contentView.topAnchor
constant:kTableViewLargeVerticalSpacing],
constant:kTableViewVerticalSpacing],
[_imageView.bottomAnchor
constraintLessThanOrEqualToAnchor:contentView.bottomAnchor
constant:-kTableViewLargeVerticalSpacing],
constant:-kTableViewVerticalSpacing],
[_textLabel.topAnchor
constraintEqualToAnchor:verticalCenteringView.topAnchor],
[_textLabel.bottomAnchor
......@@ -185,10 +185,12 @@ const CGFloat kHorizontalErrorIconFixedSize = 25;
constraintEqualToAnchor:contentView.centerYAnchor],
[verticalCenteringView.topAnchor
constraintGreaterThanOrEqualToAnchor:contentView.topAnchor
constant:kTableViewVerticalSpacing],
constant:
kTableViewTwoLabelsCellVerticalSpacing],
[verticalCenteringView.bottomAnchor
constraintLessThanOrEqualToAnchor:contentView.bottomAnchor
constant:kTableViewVerticalSpacing],
constant:
kTableViewTwoLabelsCellVerticalSpacing],
// Set trailing anchors.
[_errorIcon.trailingAnchor
......
......@@ -214,9 +214,9 @@ const CGFloat kEditIconLength = 18;
constraintEqualToAnchor:_editIconView.heightAnchor],
]];
AddOptionalVerticalPadding(contentView, _textLabel,
kTableViewLargeVerticalSpacing);
kTableViewOneLabelCellVerticalSpacing);
AddOptionalVerticalPadding(contentView, _textField,
kTableViewLargeVerticalSpacing);
kTableViewOneLabelCellVerticalSpacing);
[self updateForAccessibilityContentSizeCategory:
UIContentSizeCategoryIsAccessibilityCategory(
......
......@@ -20,12 +20,6 @@ const CGFloat kCompressionResistanceAdditionalPriority = 1;
@implementation AutofillDataItem
@synthesize deletable = _deletable;
@synthesize GUID = _GUID;
@synthesize text = _text;
@synthesize leadingDetailText = _leadingDetailText;
@synthesize trailingDetailText = _trailingDetailText;
- (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type];
if (self) {
......@@ -46,6 +40,12 @@ const CGFloat kCompressionResistanceAdditionalPriority = 1;
@end
#pragma mark - AutofillDataCell
@interface AutofillDataCell ()
@property(nonatomic, strong) UIStackView* mainLabelsContainer;
@end
@implementation AutofillDataCell
@synthesize textLabel = _textLabel;
......@@ -67,12 +67,13 @@ const CGFloat kCompressionResistanceAdditionalPriority = 1;
UIView* contentView = self.contentView;
_textLabel = [[UILabel alloc] init];
_textLabel.translatesAutoresizingMaskIntoConstraints = NO;
[contentView addSubview:_textLabel];
_leadingDetailTextLabel = [[UILabel alloc] init];
_leadingDetailTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
[contentView addSubview:_leadingDetailTextLabel];
_mainLabelsContainer = [[UIStackView alloc]
initWithArrangedSubviews:@[ _textLabel, _leadingDetailTextLabel ]];
_mainLabelsContainer.translatesAutoresizingMaskIntoConstraints = NO;
_mainLabelsContainer.axis = UILayoutConstraintAxisVertical;
[contentView addSubview:_mainLabelsContainer];
_trailingDetailTextLabel = [[UILabel alloc] init];
_trailingDetailTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
......@@ -94,7 +95,7 @@ const CGFloat kCompressionResistanceAdditionalPriority = 1;
_leadingDetailTextLabel.numberOfLines = 0;
_leadingDetailTextLabel.lineBreakMode = NSLineBreakByWordWrapping;
_leadingDetailTextLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
_leadingDetailTextLabel.adjustsFontForContentSizeCategory = YES;
_leadingDetailTextLabel.textColor =
UIColorFromRGB(kSettingsCellsDetailTextColor);
......@@ -111,16 +112,12 @@ const CGFloat kCompressionResistanceAdditionalPriority = 1;
[NSLayoutConstraint activateConstraints:@[
// Set horizontal anchors.
[_textLabel.leadingAnchor
[_mainLabelsContainer.leadingAnchor
constraintEqualToAnchor:contentView.leadingAnchor
constant:kTableViewHorizontalSpacing],
[_textLabel.trailingAnchor
[_mainLabelsContainer.trailingAnchor
constraintLessThanOrEqualToAnchor:_trailingDetailTextLabel.leadingAnchor
constant:-kTableViewHorizontalSpacing],
[_leadingDetailTextLabel.leadingAnchor
constraintEqualToAnchor:_textLabel.leadingAnchor],
[_leadingDetailTextLabel.trailingAnchor
constraintEqualToAnchor:_textLabel.trailingAnchor],
[_trailingDetailTextLabel.trailingAnchor
constraintEqualToAnchor:contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
......@@ -131,16 +128,18 @@ const CGFloat kCompressionResistanceAdditionalPriority = 1;
multiplier:kDetailTextWidthMultiplier],
// Set vertical anchors.
[_leadingDetailTextLabel.topAnchor
constraintEqualToAnchor:_textLabel.bottomAnchor],
[_mainLabelsContainer.centerYAnchor
constraintEqualToAnchor:contentView.centerYAnchor],
[_trailingDetailTextLabel.centerYAnchor
constraintEqualToAnchor:contentView.centerYAnchor],
]];
AddOptionalVerticalPadding(contentView, _textLabel, _leadingDetailTextLabel,
kTableViewLargeVerticalSpacing);
AddOptionalVerticalPadding(contentView, _mainLabelsContainer
,
kTableViewTwoLabelsCellVerticalSpacing);
AddOptionalVerticalPadding(contentView, _trailingDetailTextLabel,
kTableViewLargeVerticalSpacing);
kTableViewOneLabelCellVerticalSpacing);
}
#pragma mark - UITableViewCell
......
......@@ -77,7 +77,7 @@
constraintEqualToAnchor:_textLabel.firstBaselineAnchor],
]];
AddOptionalVerticalPadding(contentView, _textLabel,
kTableViewLargeVerticalSpacing);
kTableViewOneLabelCellVerticalSpacing);
}
return self;
}
......
......@@ -4,15 +4,12 @@
#import "ios/chrome/browser/ui/settings/cells/passphrase_error_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Padding used on the leading and trailing edges of the cell.
const CGFloat kHorizontalPadding = 16;
} // namespace
@implementation PassphraseErrorItem
@synthesize text = _text;
......@@ -65,17 +62,22 @@ const CGFloat kHorizontalPadding = 16;
[NSLayoutConstraint activateConstraints:@[
[_errorImageView.leadingAnchor
constraintEqualToAnchor:contentView.leadingAnchor
constant:kHorizontalPadding],
constant:kTableViewHorizontalSpacing],
[_textLabel.leadingAnchor
constraintEqualToAnchor:_errorImageView.trailingAnchor
constant:kHorizontalPadding],
constant:kTableViewHorizontalSpacing],
[_textLabel.trailingAnchor
constraintEqualToAnchor:contentView.trailingAnchor
constant:-kHorizontalPadding],
constant:-kTableViewHorizontalSpacing],
[_errorImageView.centerYAnchor
constraintEqualToAnchor:contentView.centerYAnchor],
[_textLabel.centerYAnchor
constraintEqualToAnchor:contentView.centerYAnchor],
[_textLabel.topAnchor
constraintEqualToAnchor:contentView.topAnchor
constant:kTableViewOneLabelCellVerticalSpacing],
[_textLabel.bottomAnchor
constraintEqualToAnchor:contentView.bottomAnchor
constant:-kTableViewOneLabelCellVerticalSpacing],
]];
[_errorImageView
......
......@@ -7,6 +7,7 @@
#include <algorithm>
#import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
......@@ -17,16 +18,9 @@
namespace {
// Padding used on the leading and trailing edges of the cell and between the
// two labels.
const CGFloat kHorizontalPadding = 16;
// Padding used between the icon and the text labels.
const CGFloat kIconTrailingPadding = 12;
// Padding used on the top and bottom edges of the cell.
const CGFloat kVerticalPadding = 16;
// Size of the icon image.
const CGFloat kIconImageSize = 28;
......@@ -141,7 +135,7 @@ const CGFloat kMinDetailTextWidthRatio = 0.25f;
// these will be active at a time, defaulting to hidden.
_iconHiddenConstraint = [_labelContainerGuide.leadingAnchor
constraintEqualToAnchor:contentView.leadingAnchor
constant:kHorizontalPadding];
constant:kTableViewHorizontalSpacing];
_iconVisibleConstraint = [_labelContainerGuide.leadingAnchor
constraintEqualToAnchor:_iconImageView.trailingAnchor
constant:kIconTrailingPadding];
......@@ -160,29 +154,30 @@ const CGFloat kMinDetailTextWidthRatio = 0.25f;
];
_accessibilityConstraints = @[
[_textLabel.topAnchor constraintEqualToAnchor:self.contentView.topAnchor
constant:kVerticalPadding],
[_textLabel.topAnchor
constraintEqualToAnchor:self.contentView.topAnchor
constant:kTableViewLargeVerticalSpacing],
[_detailTextLabel.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor
constant:-kVerticalPadding],
constant:-kTableViewLargeVerticalSpacing],
[_textLabel.bottomAnchor
constraintEqualToAnchor:_detailTextLabel.topAnchor
constant:-kVerticalPadding],
constant:-kTableViewLargeVerticalSpacing],
[_textLabel.trailingAnchor
constraintLessThanOrEqualToAnchor:self.contentView.trailingAnchor
constant:-kHorizontalPadding],
constant:-kTableViewHorizontalSpacing],
[_detailTextLabel.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kHorizontalPadding],
constant:kTableViewHorizontalSpacing],
[_detailTextLabel.trailingAnchor
constraintLessThanOrEqualToAnchor:_labelContainerGuide.trailingAnchor
constant:-kHorizontalPadding],
constant:-kTableViewHorizontalSpacing],
];
[NSLayoutConstraint activateConstraints:@[
[_iconImageView.leadingAnchor
constraintEqualToAnchor:contentView.leadingAnchor
constant:kHorizontalPadding],
constant:kTableViewHorizontalSpacing],
[_iconImageView.widthAnchor constraintEqualToConstant:kIconImageSize],
[_iconImageView.heightAnchor constraintEqualToConstant:kIconImageSize],
......@@ -191,14 +186,15 @@ const CGFloat kMinDetailTextWidthRatio = 0.25f;
constraintEqualToAnchor:_labelContainerGuide.leadingAnchor],
[_labelContainerGuide.trailingAnchor
constraintEqualToAnchor:contentView.trailingAnchor
constant:-kHorizontalPadding],
constant:-kTableViewHorizontalSpacing],
[_iconImageView.centerYAnchor
constraintEqualToAnchor:contentView.centerYAnchor],
_iconHiddenConstraint,
]];
AddOptionalVerticalPadding(contentView, _textLabel, kVerticalPadding);
AddOptionalVerticalPadding(contentView, _textLabel,
kTableViewOneLabelCellVerticalSpacing);
[self updateForAccessibilityContentSizeCategory:
UIContentSizeCategoryIsAccessibilityCategory(
......@@ -286,8 +282,8 @@ const CGFloat kMinDetailTextWidthRatio = 0.25f;
}
- (CGFloat)textLabelTargetWidth {
CGFloat availableWidth =
CGRectGetWidth(_labelContainerGuide.layoutFrame) - kHorizontalPadding;
CGFloat availableWidth = CGRectGetWidth(_labelContainerGuide.layoutFrame) -
kTableViewHorizontalSpacing;
CGFloat textLabelWidth = self.textLabel.frame.size.width;
CGFloat detailTextLabelWidth = self.detailTextLabel.frame.size.width;
......@@ -300,8 +296,8 @@ const CGFloat kMinDetailTextWidthRatio = 0.25f;
}
- (CGFloat)detailTextLabelTargetWidth {
CGFloat availableWidth =
CGRectGetWidth(_labelContainerGuide.layoutFrame) - kHorizontalPadding;
CGFloat availableWidth = CGRectGetWidth(_labelContainerGuide.layoutFrame) -
kTableViewHorizontalSpacing;
CGFloat textLabelWidth = self.textLabel.frame.size.width;
CGFloat detailTextLabelWidth = self.detailTextLabel.frame.size.width;
......
......@@ -95,18 +95,20 @@
constraintEqualToAnchor:contentView.centerYAnchor],
[_imageView.topAnchor
constraintGreaterThanOrEqualToAnchor:contentView.topAnchor
constant:kTableViewLargeVerticalSpacing],
constant:kTableViewVerticalSpacing],
[contentView.bottomAnchor
constraintGreaterThanOrEqualToAnchor:_imageView.bottomAnchor
constant:kTableViewLargeVerticalSpacing],
constant:kTableViewVerticalSpacing],
[textStackView.centerYAnchor
constraintEqualToAnchor:contentView.centerYAnchor],
[textStackView.topAnchor
constraintGreaterThanOrEqualToAnchor:contentView.topAnchor
constant:kTableViewLargeVerticalSpacing],
constant:
kTableViewTwoLabelsCellVerticalSpacing],
[contentView.bottomAnchor
constraintGreaterThanOrEqualToAnchor:textStackView.bottomAnchor
constant:kTableViewLargeVerticalSpacing],
constant:
kTableViewTwoLabelsCellVerticalSpacing],
]];
}
......
......@@ -61,7 +61,7 @@
_detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
_detailTextLabel.numberOfLines = 0;
_detailTextLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
_detailTextLabel.adjustsFontForContentSizeCategory = YES;
_detailTextLabel.textColor = UIColorFromRGB(kSettingsCellsDetailTextColor);
[contentView addSubview:_detailTextLabel];
......
......@@ -19,9 +19,6 @@ namespace {
// Padding used between the icon and the text labels.
const CGFloat kIconTrailingPadding = 12;
// Padding used on the top and bottom edges of the cell.
const CGFloat kVerticalPadding = 16;
// Size of the icon image.
const CGFloat kIconImageSize = 28;
} // namespace
......@@ -116,13 +113,13 @@ const CGFloat kIconImageSize = 28;
_accessibilityConstraints = @[
[_switchView.topAnchor
constraintEqualToAnchor:textLayoutGuide.bottomAnchor
constant:kVerticalPadding],
constant:kTableViewLargeVerticalSpacing],
[_switchView.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kTableViewHorizontalSpacing],
[_switchView.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor
constant:-kVerticalPadding],
constant:-kTableViewLargeVerticalSpacing],
[textLayoutGuide.trailingAnchor
constraintLessThanOrEqualToAnchor:self.contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
......@@ -163,7 +160,7 @@ const CGFloat kIconImageSize = 28;
}
AddOptionalVerticalPadding(self.contentView, textLayoutGuide,
kVerticalPadding);
kTableViewOneLabelCellVerticalSpacing);
}
return self;
}
......
......@@ -75,10 +75,15 @@ const CGFloat kVerticalSpacing = 16;
forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:button];
NSLayoutConstraint* heightConstraint = [self.contentView.heightAnchor
constraintGreaterThanOrEqualToConstant:kChromeTableViewCellHeight];
// Don't set the priority to required to avoid clashing with the estimated
// height.
heightConstraint.priority = UILayoutPriorityRequired - 1;
AddSameConstraints(button, self.contentView);
[NSLayoutConstraint activateConstraints:@[
[self.contentView.heightAnchor constraintGreaterThanOrEqualToConstant:
kTableViewHeaderFooterViewHeight],
heightConstraint,
[_textLabel.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor],
[_textLabel.trailingAnchor
......
......@@ -26,7 +26,7 @@ namespace {
// |estimatedSection{Header|Footer}Height|.
const CGFloat kDefaultHeaderFooterHeight = 10;
// Estimated height of the header/footer, used to speed the constraints.
const CGFloat kEstimatedHeaderFooterHeight = 35;
const CGFloat kEstimatedHeaderFooterHeight = 50;
enum SavedBarButtomItemPositionEnum {
kUndefinedBarButtonItemPosition,
......
......@@ -61,7 +61,7 @@
forAxis:UILayoutConstraintAxisVertical];
self.subtitleLabel = [[UILabel alloc] init];
self.subtitleLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
self.subtitleLabel.textColor = [UIColor lightGrayColor];
[self.subtitleLabel
setContentCompressionResistancePriority:UILayoutPriorityRequired
......
......@@ -10,9 +10,18 @@
// The minimum height for a TableViewHeaderFooterView.
extern const CGFloat kTableViewHeaderFooterViewHeight;
// The minimum height for a TableViewCell.
extern const CGFloat kChromeTableViewCellHeight;
// The horizontal spacing between views and the container view of a cell.
extern const CGFloat kTableViewHorizontalSpacing;
// The vertical spacing for a cell containing only one label.
extern const CGFloat kTableViewOneLabelCellVerticalSpacing;
// The vertical spacing for a cell containing one label and one sub label.
extern const CGFloat kTableViewTwoLabelsCellVerticalSpacing;
// The vertical spacing between views and the container view of a cell.
extern const CGFloat kTableViewVerticalSpacing;
......
......@@ -8,8 +8,11 @@
#error "This file requires ARC support."
#endif
const CGFloat kTableViewHeaderFooterViewHeight = 44.0;
const CGFloat kTableViewHeaderFooterViewHeight = 48.0;
const CGFloat kChromeTableViewCellHeight = 48.0;
const CGFloat kTableViewHorizontalSpacing = 16.0;
const CGFloat kTableViewOneLabelCellVerticalSpacing = 14.0;
const CGFloat kTableViewTwoLabelsCellVerticalSpacing = 11.0;
const CGFloat kTableViewVerticalSpacing = 8.0;
const CGFloat kTableViewLargeVerticalSpacing = 16.0;
const CGFloat kTableViewSubViewHorizontalSpacing = 12.0;
......
......@@ -13,10 +13,6 @@
#error "This file requires ARC support."
#endif
namespace {
const CGFloat kMinimalHeight = 48;
} // namespace
#pragma mark - TableViewDetailTextItem
@implementation TableViewDetailTextItem
......@@ -99,20 +95,23 @@ const CGFloat kMinimalHeight = 48;
_detailTextLabel.translatesAutoresizingMaskIntoConstraints = NO;
[containerView addSubview:_detailTextLabel];
CGFloat margin = kTableViewHorizontalSpacing;
NSLayoutConstraint* heightConstraint = [self.contentView.heightAnchor
constraintGreaterThanOrEqualToConstant:kChromeTableViewCellHeight];
// Don't set the priority to required to avoid clashing with the estimated
// height.
heightConstraint.priority = UILayoutPriorityRequired - 1;
[NSLayoutConstraint activateConstraints:@[
// Minimal height.
[self.contentView.heightAnchor
constraintGreaterThanOrEqualToConstant:kMinimalHeight],
heightConstraint,
// Container.
[containerView.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:margin],
constant:kTableViewHorizontalSpacing],
[containerView.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor
constant:-margin],
constant:-kTableViewHorizontalSpacing],
[containerView.centerYAnchor
constraintEqualToAnchor:self.contentView.centerYAnchor],
......@@ -133,7 +132,8 @@ const CGFloat kMinimalHeight = 48;
]];
// Make sure there are top and bottom margins of at least |margin|.
AddOptionalVerticalPadding(self.contentView, containerView, margin);
AddOptionalVerticalPadding(self.contentView, containerView,
kTableViewTwoLabelsCellVerticalSpacing);
}
return self;
}
......
......@@ -13,11 +13,6 @@
#error "This file requires ARC support."
#endif
namespace {
// Vertical spacing between label and the container view of a cell.
const CGFloat kLabelCellVerticalSpacing = 11.0;
} // namespace
@implementation TableViewImageItem
@synthesize image = _image;
......@@ -97,6 +92,12 @@ const CGFloat kLabelCellVerticalSpacing = 11.0;
horizontalStack.alignment = UIStackViewAlignmentCenter;
[self.contentView addSubview:horizontalStack];
NSLayoutConstraint* heightConstraint = [self.contentView.heightAnchor
constraintGreaterThanOrEqualToConstant:kChromeTableViewCellHeight];
// Don't set the priority to required to avoid clashing with the estimated
// height.
heightConstraint.priority = UILayoutPriorityRequired - 1;
[NSLayoutConstraint activateConstraints:@[
// Horizontal Stack constraints.
[horizontalStack.leadingAnchor
......@@ -105,12 +106,15 @@ const CGFloat kLabelCellVerticalSpacing = 11.0;
[horizontalStack.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
[horizontalStack.centerYAnchor
constraintEqualToAnchor:self.contentView.centerYAnchor],
[horizontalStack.topAnchor
constraintEqualToAnchor:self.contentView.topAnchor
constant:kLabelCellVerticalSpacing],
constraintGreaterThanOrEqualToAnchor:self.contentView.topAnchor
constant:kTableViewVerticalSpacing],
[horizontalStack.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor
constant:-kLabelCellVerticalSpacing],
constraintLessThanOrEqualToAnchor:self.contentView.bottomAnchor
constant:-kTableViewVerticalSpacing],
heightConstraint,
]];
}
return self;
......
......@@ -15,11 +15,6 @@
#error "This file requires ARC support."
#endif
namespace {
// Vertical spacing between label and the container view of a cell.
const CGFloat kLabelCellVerticalSpacing = 11.0;
} // namespace
#pragma mark - TableViewTextItem
@implementation TableViewTextItem
......@@ -105,11 +100,12 @@ const CGFloat kLabelCellVerticalSpacing = 11.0;
[_textLabel.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kTableViewHorizontalSpacing],
[_textLabel.topAnchor constraintEqualToAnchor:self.contentView.topAnchor
constant:kLabelCellVerticalSpacing],
[_textLabel.topAnchor
constraintEqualToAnchor:self.contentView.topAnchor
constant:kTableViewOneLabelCellVerticalSpacing],
[_textLabel.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor
constant:-kLabelCellVerticalSpacing],
constant:-kTableViewOneLabelCellVerticalSpacing],
[_textLabel.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing]
......
......@@ -162,13 +162,13 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
// Set font sizes using dynamic type.
_titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_titleLabel.adjustsFontForContentSizeCategory = YES;
_URLLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
_URLLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
_URLLabel.adjustsFontForContentSizeCategory = YES;
_URLLabel.textColor =
UIColorFromRGB(kTableViewSecondaryLabelLightGrayTextColor);
_URLLabel.hidden = YES;
_metadataLabel.font =
[UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
[UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
_metadataLabel.textColor =
UIColorFromRGB(kTableViewSecondaryLabelLightGrayTextColor);
_metadataLabel.adjustsFontForContentSizeCategory = YES;
......@@ -202,6 +202,22 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
[contentView addSubview:_faviconBadgeView];
[contentView addSubview:self.horizontalStack];
NSLayoutConstraint* heightConstraint = [self.contentView.heightAnchor
constraintGreaterThanOrEqualToConstant:kChromeTableViewCellHeight];
// Don't set the priority to required to avoid clashing with the estimated
// height.
heightConstraint.priority = UILayoutPriorityRequired - 1;
NSLayoutConstraint* topConstraint = [self.horizontalStack.topAnchor
constraintGreaterThanOrEqualToAnchor:self.contentView.topAnchor
constant:
kTableViewTwoLabelsCellVerticalSpacing];
NSLayoutConstraint* bottomConstraint = [self.horizontalStack.bottomAnchor
constraintGreaterThanOrEqualToAnchor:self.contentView.bottomAnchor
constant:
-
kTableViewTwoLabelsCellVerticalSpacing];
[NSLayoutConstraint activateConstraints:@[
// The favicon view is a fixed size, is pinned to the leading edge of the
// content view, and is centered vertically.
......@@ -236,12 +252,9 @@ const char kDefaultSupplementalURLTextDelimiter[] = "•";
[self.horizontalStack.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
[self.horizontalStack.topAnchor
constraintEqualToAnchor:self.contentView.topAnchor
constant:kTableViewVerticalSpacing],
[self.horizontalStack.bottomAnchor
constraintEqualToAnchor:self.contentView.bottomAnchor
constant:-kTableViewVerticalSpacing]
[self.horizontalStack.centerYAnchor
constraintEqualToAnchor:self.contentView.centerYAnchor],
topConstraint, bottomConstraint, heightConstraint
]];
}
return self;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment