From f607eabb7aeb15d2477e9dd425cfb2fbc7d9db6c Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 28 Jun 2018 14:41:18 -0400 Subject: [PATCH] Fix audio message layout. --- .../Cells/OWSAudioMessageView.m | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m index 02988d157..8ed929ed5 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m @@ -209,11 +209,6 @@ NS_ASSUME_NONNULL_BEGIN [self addArrangedSubview:self.audioPlayPauseButton]; [self.audioPlayPauseButton setContentHuggingHigh]; - UIStackView *labelsView = [UIStackView new]; - labelsView.axis = UILayoutConstraintAxisVertical; - labelsView.spacing = [OWSAudioMessageView labelVSpacing]; - [self addArrangedSubview:labelsView]; - NSString *filename = self.attachmentStream.sourceFilename; if (!filename) { filename = [[self.attachmentStream filePath] lastPathComponent]; @@ -233,12 +228,10 @@ NS_ASSUME_NONNULL_BEGIN topLabel.textColor = [textColor colorWithAlphaComponent:0.85f]; topLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; topLabel.font = [OWSAudioMessageView labelFont]; - [labelsView addArrangedSubview:topLabel]; AudioProgressView *audioProgressView = [AudioProgressView new]; self.audioProgressView = audioProgressView; [self updateAudioProgressView]; - [labelsView addArrangedSubview:audioProgressView]; [audioProgressView autoSetDimension:ALDimensionHeight toSize:[OWSAudioMessageView audioProgressViewHeight]]; UILabel *bottomLabel = [UILabel new]; @@ -247,8 +240,24 @@ NS_ASSUME_NONNULL_BEGIN bottomLabel.textColor = [textColor colorWithAlphaComponent:0.85f]; bottomLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; bottomLabel.font = [OWSAudioMessageView labelFont]; + + UIStackView *labelsView = [UIStackView new]; + labelsView.axis = UILayoutConstraintAxisVertical; + labelsView.spacing = [OWSAudioMessageView labelVSpacing]; + [labelsView addArrangedSubview:topLabel]; + [labelsView addArrangedSubview:audioProgressView]; [labelsView addArrangedSubview:bottomLabel]; + // Ensure the "audio progress" and "play button" are v-center-aligned using a container. + UIView *labelsContainerView = [UIView containerView]; + [self addArrangedSubview:labelsContainerView]; + [labelsContainerView addSubview:labelsView]; + [labelsView autoPinWidthToSuperview]; + [labelsView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; + [labelsView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; + + [audioProgressView autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.audioPlayPauseButton]; + [self updateContents]; }