From fb0c47aa12afca0759e8a3deaa86480c42b5f910 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 25 Apr 2018 11:38:25 -0400 Subject: [PATCH 1/3] Fix dynamic type issues. --- .../ConversationView/Cells/OWSSystemMessageCell.m | 3 +++ .../ConversationView/Cells/OWSUnreadIndicatorCell.m | 8 ++++++++ Signal/src/ViewControllers/HomeView/HomeViewCell.m | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m index 4381b6633..c2e84cfa6 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m @@ -169,6 +169,9 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(interaction); OWSAssert(label); + // Update cell to reflect changes in dynamic text. + self.titleLabel.font = [self titleFont]; + // TODO: Should we move the copy generation into this view? if ([interaction isKindOfClass:[TSErrorMessage class]]) { diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSUnreadIndicatorCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSUnreadIndicatorCell.m index 13ceeb817..ffa23218c 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSUnreadIndicatorCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSUnreadIndicatorCell.m @@ -94,6 +94,10 @@ NS_ASSUME_NONNULL_BEGIN self.titleLabel.text = [self titleForInteraction:interaction]; self.subtitleLabel.text = [self subtitleForInteraction:interaction]; + // Update cell to reflect changes in dynamic text. + self.titleLabel.font = [self titleFont]; + self.subtitleLabel.font = [self subtitleFont]; + self.backgroundColor = [UIColor whiteColor]; [self setNeedsLayout]; @@ -209,6 +213,10 @@ NS_ASSUME_NONNULL_BEGIN TSUnreadIndicatorInteraction *interaction = (TSUnreadIndicatorInteraction *)self.viewItem.interaction; + // Update cell to reflect changes in dynamic text. + self.titleLabel.font = [self titleFont]; + self.subtitleLabel.font = [self subtitleFont]; + // TODO: Should we use viewWidth? CGSize result = CGSizeMake(viewWidth, 0); result.height += self.titleVMargin * 2.f; diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index 785c4cfc5..6e04ed7be 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -94,6 +94,10 @@ NS_ASSUME_NONNULL_BEGIN [self.nameLabel setContentHuggingHorizontalLow]; [self.nameLabel setCompressionResistanceHorizontalLow]; + [self.contentView addBorderWithColor:[UIColor blueColor]]; + [self.nameLabel addRedBorder]; + [self.snippetLabel addRedBorder]; + self.dateTimeLabel = [UILabel new]; [self.dateTimeLabel setContentHuggingHorizontalHigh]; [self.dateTimeLabel setCompressionResistanceHorizontalHigh]; @@ -125,6 +129,14 @@ NS_ASSUME_NONNULL_BEGIN [self.unreadLabel autoCenterInSuperview]; [self.unreadLabel setContentHuggingHigh]; [self.unreadLabel setCompressionResistanceHigh]; + + UIView *payloadBorderView = [UIView new]; + [payloadBorderView addBorderWithColor:[UIColor greenColor]]; + [self.contentView addSubview:payloadBorderView]; + [payloadBorderView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.payloadView]; + [payloadBorderView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.payloadView]; + [payloadBorderView autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.payloadView]; + [payloadBorderView autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:self.payloadView]; } + (NSString *)cellReuseIdentifier From 5a42bf0ffb2ae609d1ae84e326f1b4fc339660b6 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 25 Apr 2018 13:06:25 -0400 Subject: [PATCH 2/3] Fix dynamic type issues in home view cells. --- Signal/src/ViewControllers/HomeView/HomeViewCell.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index 6e04ed7be..c2c5ad36f 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN [self setTranslatesAutoresizingMaskIntoConstraints:NO]; self.layoutMargins = UIEdgeInsetsMake(0, self.cellHMargin, 0, self.cellHMargin); self.contentView.layoutMargins = UIEdgeInsetsZero; - self.contentView.preservesSuperviewLayoutMargins = YES; + self.contentView.preservesSuperviewLayoutMargins = NO; self.backgroundColor = [UIColor whiteColor]; From 251ce29a82ba9b9b5563d50524020a688b0d3f2a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 25 Apr 2018 13:29:10 -0400 Subject: [PATCH 3/3] Fix dynamic type issues in home view cells. --- .../ViewControllers/HomeView/HomeViewCell.m | 20 +++++-------------- .../HomeView/HomeViewController.m | 8 ++++++-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index c2c5ad36f..f726826c6 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN [self setTranslatesAutoresizingMaskIntoConstraints:NO]; self.layoutMargins = UIEdgeInsetsMake(0, self.cellHMargin, 0, self.cellHMargin); self.contentView.layoutMargins = UIEdgeInsetsZero; - self.contentView.preservesSuperviewLayoutMargins = NO; + self.contentView.preservesSuperviewLayoutMargins = YES; self.backgroundColor = [UIColor whiteColor]; @@ -84,8 +84,10 @@ NS_ASSUME_NONNULL_BEGIN [self.payloadView autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:self.avatarHSpacing]; [self.payloadView autoVCenterInSuperview]; // Ensure that the cell's contents never overflow the cell bounds. - [self.payloadView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; - [self.payloadView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; + // + // NOTE: It's critical that we pin to the superview top and bottom _edge_ and not _margin_. + [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; + [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; // We pin the payloadView traillingEdge later, as part of the "Unread Badge" logic. self.nameLabel = [UILabel new]; @@ -94,10 +96,6 @@ NS_ASSUME_NONNULL_BEGIN [self.nameLabel setContentHuggingHorizontalLow]; [self.nameLabel setCompressionResistanceHorizontalLow]; - [self.contentView addBorderWithColor:[UIColor blueColor]]; - [self.nameLabel addRedBorder]; - [self.snippetLabel addRedBorder]; - self.dateTimeLabel = [UILabel new]; [self.dateTimeLabel setContentHuggingHorizontalHigh]; [self.dateTimeLabel setCompressionResistanceHorizontalHigh]; @@ -129,14 +127,6 @@ NS_ASSUME_NONNULL_BEGIN [self.unreadLabel autoCenterInSuperview]; [self.unreadLabel setContentHuggingHigh]; [self.unreadLabel setCompressionResistanceHigh]; - - UIView *payloadBorderView = [UIView new]; - [payloadBorderView addBorderWithColor:[UIColor greenColor]]; - [self.contentView addSubview:payloadBorderView]; - [payloadBorderView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.payloadView]; - [payloadBorderView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.payloadView]; - [payloadBorderView autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.payloadView]; - [payloadBorderView autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:self.payloadView]; } + (NSString *)cellReuseIdentifier diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 9c80b54be..2d3188e9a 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -695,15 +695,19 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations UIStackView *stackView = [UIStackView new]; stackView.axis = UILayoutConstraintAxisHorizontal; stackView.spacing = 5; + // If alignment isn't set, UIStackView uses the height of + // disclosureImageView, even if label has a higher desired height. + stackView.alignment = UIStackViewAlignmentCenter; [stackView addArrangedSubview:label]; [stackView addArrangedSubview:disclosureImageView]; [cell.contentView addSubview:stackView]; [stackView autoCenterInSuperview]; // Constrain to cell margins. - [stackView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; - [stackView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewMargin:ALEdgeLeading relation:NSLayoutRelationGreaterThanOrEqual]; [stackView autoPinEdgeToSuperviewMargin:ALEdgeTrailing relation:NSLayoutRelationGreaterThanOrEqual]; + // NOTE: It's critical that we pin to the superview top and bottom _edge_ and not _margin_. + [stackView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; + [stackView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:0 relation:NSLayoutRelationGreaterThanOrEqual]; return cell; }