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; ...@@ -178,9 +178,6 @@ const CGFloat kAnimationDuration = 0.3;
title:(NSString*)title title:(NSString*)title
publisherName:(NSString*)publisherName publisherName:(NSString*)publisherName
publicationDate:(NSString*)publicationDate { publicationDate:(NSString*)publicationDate {
if (IsUIRefreshPhase1Enabled()) {
return [[self class] imageSize] + [[self class] standardSpacing];
} else {
UILabel* titleLabel = [[UILabel alloc] init]; UILabel* titleLabel = [[UILabel alloc] init];
[self configureTitleLabel:titleLabel]; [self configureTitleLabel:titleLabel];
titleLabel.text = title; titleLabel.text = title;
...@@ -193,6 +190,18 @@ const CGFloat kAnimationDuration = 0.3; ...@@ -193,6 +190,18 @@ const CGFloat kAnimationDuration = 0.3;
CGSize sizeForLabels = CGSize sizeForLabels =
CGSizeMake(width - [self labelMarginWithImage:hasImage], 500); CGSizeMake(width - [self labelMarginWithImage:hasImage], 500);
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]; CGFloat labelHeight = 3 * [[self class] standardSpacing];
labelHeight += [titleLabel sizeThatFits:sizeForLabels].height; labelHeight += [titleLabel sizeThatFits:sizeForLabels].height;
CGFloat additionalInfoHeight = CGFloat additionalInfoHeight =
...@@ -215,6 +224,16 @@ const CGFloat kAnimationDuration = 0.3; ...@@ -215,6 +224,16 @@ const CGFloat kAnimationDuration = 0.3;
#pragma mark - UIView #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 // Implements -layoutSubviews as per instructions in documentation for
// +[MDCCollectionViewCell cr_preferredHeightForWidth:forItem:]. // +[MDCCollectionViewCell cr_preferredHeightForWidth:forItem:].
- (void)layoutSubviews { - (void)layoutSubviews {
...@@ -247,9 +266,10 @@ const CGFloat kAnimationDuration = 0.3; ...@@ -247,9 +266,10 @@ const CGFloat kAnimationDuration = 0.3;
if (IsUIRefreshPhase1Enabled()) { if (IsUIRefreshPhase1Enabled()) {
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[_imageContainer.bottomAnchor [_imageContainer.bottomAnchor
constraintLessThanOrEqualToAnchor:self.contentView.bottomAnchor], constraintLessThanOrEqualToAnchor:_faviconView.bottomAnchor],
[_faviconView.bottomAnchor [_faviconView.topAnchor
constraintEqualToAnchor:_imageContainer.bottomAnchor], constraintGreaterThanOrEqualToAnchor:self.titleLabel.bottomAnchor
constant:[[self class] smallSpacing]]
]]; ]];
} else { } else {
[NSLayoutConstraint activateConstraints:@[ [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