From 88c5fc1af8223402817aaa63d0921cbc22139839 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 20 Jul 2018 16:34:28 -0400 Subject: [PATCH] Fix message footer alignment. --- .../Cells/OWSContactOffersCell.m | 1 + .../Cells/OWSMessageFooterView.m | 36 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m index 7f773f7db..f552d7a18 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m @@ -43,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN self.layoutMargins = UIEdgeInsetsZero; self.contentView.layoutMargins = UIEdgeInsetsZero; + self.layoutConstraints = @[]; self.titleLabel = [UILabel new]; self.titleLabel.textColor = [UIColor ows_light60Color]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m index 04884c67c..dba52699d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m @@ -38,7 +38,6 @@ NS_ASSUME_NONNULL_BEGIN self.layoutMargins = UIEdgeInsetsZero; self.axis = UILayoutConstraintAxisHorizontal; - self.spacing = self.hSpacing; self.alignment = UIStackViewAlignmentCenter; self.distribution = UIStackViewDistributionEqualSpacing; @@ -47,6 +46,7 @@ NS_ASSUME_NONNULL_BEGIN leftStackView.spacing = self.hSpacing; leftStackView.alignment = UIStackViewAlignmentCenter; [self addArrangedSubview:leftStackView]; + [leftStackView setContentHuggingHigh]; self.timestampLabel = [UILabel new]; [leftStackView addArrangedSubview:self.timestampLabel]; @@ -56,7 +56,6 @@ NS_ASSUME_NONNULL_BEGIN [leftStackView addArrangedSubview:self.messageTimerView]; self.statusIndicatorImageView = [UIImageView new]; - [self.statusIndicatorImageView setContentHuggingHigh]; [self addArrangedSubview:self.statusIndicatorImageView]; self.userInteractionEnabled = NO; @@ -143,21 +142,36 @@ NS_ASSUME_NONNULL_BEGIN } if (statusIndicatorImage) { - OWSAssert(statusIndicatorImage.size.width <= self.maxImageWidth); - self.statusIndicatorImageView.image = - [statusIndicatorImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; - self.statusIndicatorImageView.tintColor = textColor; - self.statusIndicatorImageView.hidden = NO; + [self showStatusIndicatorWithIcon:statusIndicatorImage textColor:textColor]; } else { - self.statusIndicatorImageView.image = nil; - self.statusIndicatorImageView.hidden = YES; + [self hideStatusIndicator]; } } else { - self.statusIndicatorImageView.image = nil; - self.statusIndicatorImageView.hidden = YES; + [self hideStatusIndicator]; } } +- (void)showStatusIndicatorWithIcon:(UIImage *)icon textColor:(UIColor *)textColor +{ + OWSAssert(icon.size.width <= self.maxImageWidth); + self.statusIndicatorImageView.image = [icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.statusIndicatorImageView.tintColor = textColor; + [self.statusIndicatorImageView setContentHuggingHigh]; + self.spacing = self.hSpacing; +} + +- (void)hideStatusIndicator +{ + // If there's no status indicator, we want the other + // footer contents to "cling to the leading edge". + // Instead of hiding the status indicator view, + // we clear its contents and let it stretch to fill + // the available space. + self.statusIndicatorImageView.image = nil; + [self.statusIndicatorImageView setContentHuggingLow]; + self.spacing = 0; +} + - (void)animateSpinningIcon { CABasicAnimation *animation;