From c0578b31fe05d31df920a380614869fe6e84f5b1 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 10 Apr 2018 15:54:32 -0400 Subject: [PATCH] Clean up ahead of CR. --- .../ViewControllers/HomeView/HomeViewCell.m | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index ce114e472..fbdefd232 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -135,14 +135,6 @@ const NSUInteger kHomeViewAvatarHSpacing = 12; [self.unreadBadge setContentHuggingHigh]; [self.unreadBadge setCompressionResistanceHigh]; - // TODO: Will this localize? It assumes that the worst case - // unread count (99) will fit horizontally into some multiple - // N of the font's line height. - const int unreadBadgeSize = (int)ceil(self.unreadLabel.font.lineHeight * 1.5f); - self.unreadBadge.layer.cornerRadius = unreadBadgeSize / 2; - [self.unreadBadge autoSetDimension:ALDimensionWidth toSize:unreadBadgeSize]; - [self.unreadBadge autoSetDimension:ALDimensionHeight toSize:unreadBadgeSize]; - [self.unreadBadge addSubview:self.unreadLabel]; [self.unreadLabel autoVCenterInSuperview]; [self.unreadLabel autoPinWidthToSuperview]; @@ -206,12 +198,21 @@ const NSUInteger kHomeViewAvatarHSpacing = 12; NSUInteger unreadCount = [[OWSMessageUtils sharedManager] unreadMessagesInThread:thread]; if (unreadCount > 0) { + self.unreadBadge.hidden = NO; self.unreadLabel.font = [UIFont ows_dynamicTypeCaption1Font]; self.unreadLabel.text = [OWSFormat formatInt:MIN(99, (int)unreadCount)]; + // TODO: Will this localize? It assumes that the worst case + // unread count (99) will fit horizontally into some multiple + // N of the font's line height. + const int unreadBadgeSize = (int)ceil(self.unreadLabel.font.lineHeight * 1.5f); + self.unreadBadge.layer.cornerRadius = unreadBadgeSize / 2; + [self.viewConstraints addObjectsFromArray:@[ - [self.unreadBadge autoPinLeadingToTrailingEdgeOfView:self.payloadView offset:4.f], + [self.unreadBadge autoSetDimension:ALDimensionWidth toSize:unreadBadgeSize], + [self.unreadBadge autoSetDimension:ALDimensionHeight toSize:unreadBadgeSize], + [self.unreadBadge autoPinLeadingToTrailingEdgeOfView:self.payloadView offset:4.f], ]]; } else { self.unreadBadge.hidden = YES;