From 23e2d971e46c8241cc5af541ac71cf27b4c90a98 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 1 Jun 2018 10:40:28 -0400 Subject: [PATCH] Handle layout of long group name labels. --- .../ConversationView/Cells/OWSMessageCell.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m index 7e08837e7..3ad7f432a 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m @@ -358,6 +358,11 @@ NS_ASSUME_NONNULL_BEGIN self.footerLabel.hidden = NO; } + // Footer labels can extend past the message bubble, but + // we want to leave spaces for an expiration timer and + // include padding so that they still visually "cling" to the + // appropriate incoming/outgoing edge. + const CGFloat maxFooterLabelWidth = self.contentWidth - 100; if (hasExpirationTimer && attributedText) { [self.viewConstraints addObjectsFromArray:@[ @@ -365,8 +370,11 @@ NS_ASSUME_NONNULL_BEGIN [self.footerLabel autoVCenterInSuperview], (self.isIncoming ? [self.expirationTimerView autoPinLeadingToSuperviewMargin] : [self.expirationTimerView autoPinTrailingToSuperviewMargin]), - (self.isIncoming ? [self.footerLabel autoPinLeadingToTrailingEdgeOfView:self.expirationTimerView offset:0.f] - : [self.footerLabel autoPinTrailingToLeadingEdgeOfView:self.expirationTimerView offset:0.f]), + (self.isIncoming ? [self.footerLabel autoPinLeadingToTrailingEdgeOfView:self.expirationTimerView] + : [self.footerLabel autoPinTrailingToLeadingEdgeOfView:self.expirationTimerView]), + [self.footerLabel autoSetDimension:ALDimensionWidth + toSize:maxFooterLabelWidth + relation:NSLayoutRelationLessThanOrEqual], [self.footerView autoSetDimension:ALDimensionHeight toSize:self.footerHeight], ]]; } else if (hasExpirationTimer) { @@ -382,6 +390,9 @@ NS_ASSUME_NONNULL_BEGIN (self.isIncoming ? [self.footerLabel autoPinLeadingToSuperviewMargin] : [self.footerLabel autoPinTrailingToSuperviewMargin]), [self.footerView autoSetDimension:ALDimensionHeight toSize:self.footerHeight], + [self.footerLabel autoSetDimension:ALDimensionWidth + toSize:maxFooterLabelWidth + relation:NSLayoutRelationLessThanOrEqual], ]]; } else { OWSFail(@"%@ Cell unexpectedly has neither expiration timer nor footer text.", self.logTag);