Commit 4633a457 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Handle larger fonts in content suggestions cell.

Bug: 833941
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Iecd425473551185e2c0ff381480a7bddd46cb108
Reviewed-on: https://chromium-review.googlesource.com/1034219Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554733}
parent cfcfba66
......@@ -178,9 +178,6 @@ const CGFloat kAnimationDuration = 0.3;
title:(NSString*)title
publisherName:(NSString*)publisherName
publicationDate:(NSString*)publicationDate {
if (IsUIRefreshPhase1Enabled()) {
return [[self class] imageSize] + [[self class] standardSpacing];
} else {
UILabel* titleLabel = [[UILabel alloc] init];
[self configureTitleLabel:titleLabel];
titleLabel.text = title;
......@@ -193,15 +190,27 @@ const CGFloat kAnimationDuration = 0.3;
CGSize sizeForLabels =
CGSizeMake(width - [self labelMarginWithImage:hasImage], 500);
CGFloat labelHeight = 3 * [[self class] standardSpacing];
labelHeight += [titleLabel sizeThatFits:sizeForLabels].height;
CGFloat additionalInfoHeight =
[additionalInfoLabel sizeThatFits:sizeForLabels].height;
labelHeight += MAX(additionalInfoHeight, kFaviconSize);
CGFloat minimalHeight = hasImage ? [[self class] imageSize] : 0;
minimalHeight += 2 * [[self class] standardSpacing];
return MAX(minimalHeight, labelHeight);
if (IsUIRefreshPhase1Enabled()) {
CGFloat minimalHeight =
[[self class] imageSize] + [[self class] standardSpacing];
CGFloat labelHeight = [[self class] standardSpacing];
labelHeight += [titleLabel sizeThatFits:sizeForLabels].height;
labelHeight += [[self class] smallSpacing];
CGFloat additionalInfoHeight =
[additionalInfoLabel sizeThatFits:sizeForLabels].height;
labelHeight += MAX(additionalInfoHeight, kFaviconSize);
return MAX(minimalHeight, labelHeight);
} else {
CGFloat labelHeight = 3 * [[self class] standardSpacing];
labelHeight += [titleLabel sizeThatFits:sizeForLabels].height;
CGFloat additionalInfoHeight =
[additionalInfoLabel sizeThatFits:sizeForLabels].height;
labelHeight += MAX(additionalInfoHeight, kFaviconSize);
CGFloat minimalHeight = hasImage ? [[self class] imageSize] : 0;
minimalHeight += 2 * [[self class] standardSpacing];
return MAX(minimalHeight, labelHeight);
}
}
......@@ -215,6 +224,16 @@ const CGFloat kAnimationDuration = 0.3;
#pragma mark - UIView
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
if (IsUIRefreshPhase1Enabled() &&
self.traitCollection.preferredContentSizeCategory !=
previousTraitCollection.preferredContentSizeCategory) {
[[self class] configureTitleLabel:_titleLabel];
_additionalInformationLabel.font = [[self class] additionalInformationFont];
}
}
// Implements -layoutSubviews as per instructions in documentation for
// +[MDCCollectionViewCell cr_preferredHeightForWidth:forItem:].
- (void)layoutSubviews {
......@@ -247,9 +266,10 @@ const CGFloat kAnimationDuration = 0.3;
if (IsUIRefreshPhase1Enabled()) {
[NSLayoutConstraint activateConstraints:@[
[_imageContainer.bottomAnchor
constraintLessThanOrEqualToAnchor:self.contentView.bottomAnchor],
[_faviconView.bottomAnchor
constraintEqualToAnchor:_imageContainer.bottomAnchor],
constraintLessThanOrEqualToAnchor:_faviconView.bottomAnchor],
[_faviconView.topAnchor
constraintGreaterThanOrEqualToAnchor:self.titleLabel.bottomAnchor
constant:[[self class] smallSpacing]]
]];
} else {
[NSLayoutConstraint activateConstraints:@[
......
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