CR: unread badge updates w/ dynamic text change

also renames for clarity

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 8ca62a8d44
commit 8e56175099

@ -62,6 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
[self setTranslatesAutoresizingMaskIntoConstraints:NO]; [self setTranslatesAutoresizingMaskIntoConstraints:NO];
self.layoutMargins = UIEdgeInsetsMake(0, self.cellHMargin, 0, self.cellHMargin); self.layoutMargins = UIEdgeInsetsMake(0, self.cellHMargin, 0, self.cellHMargin);
self.contentView.layoutMargins = UIEdgeInsetsZero;
self.contentView.preservesSuperviewLayoutMargins = YES; self.contentView.preservesSuperviewLayoutMargins = YES;
self.backgroundColor = [UIColor whiteColor]; self.backgroundColor = [UIColor whiteColor];
@ -115,7 +116,6 @@ NS_ASSUME_NONNULL_BEGIN
[self.snippetLabel setCompressionResistanceHorizontalLow]; [self.snippetLabel setCompressionResistanceHorizontalLow];
self.unreadLabel = [UILabel new]; self.unreadLabel = [UILabel new];
self.unreadLabel.font = self.dateTimeFont;
self.unreadLabel.textColor = [UIColor whiteColor]; self.unreadLabel.textColor = [UIColor whiteColor];
self.unreadLabel.lineBreakMode = NSLineBreakByTruncatingTail; self.unreadLabel.lineBreakMode = NSLineBreakByTruncatingTail;
self.unreadLabel.textAlignment = NSTextAlignmentCenter; self.unreadLabel.textAlignment = NSTextAlignmentCenter;
@ -177,10 +177,10 @@ NS_ASSUME_NONNULL_BEGIN
if (hasUnreadMessages) { if (hasUnreadMessages) {
self.dateTimeLabel.textColor = [UIColor ows_blackColor]; self.dateTimeLabel.textColor = [UIColor ows_blackColor];
self.dateTimeLabel.font = self.dateTimeFont.ows_mediumWeight; self.dateTimeLabel.font = self.unreadFont.ows_mediumWeight;
} else { } else {
self.dateTimeLabel.textColor = [UIColor lightGrayColor]; self.dateTimeLabel.textColor = [UIColor lightGrayColor];
self.dateTimeLabel.font = self.dateTimeFont; self.dateTimeLabel.font = self.unreadFont;
} }
NSUInteger unreadCount = [[OWSMessageUtils sharedManager] unreadMessagesInThread:thread]; NSUInteger unreadCount = [[OWSMessageUtils sharedManager] unreadMessagesInThread:thread];
@ -190,7 +190,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.contentView addSubview:self.unreadBadge]; [self.contentView addSubview:self.unreadBadge];
self.unreadLabel.text = [OWSFormat formatInt:(int)unreadCount]; self.unreadLabel.text = [OWSFormat formatInt:(int)unreadCount];
self.unreadLabel.font = self.unreadFont;
const int unreadBadgeHeight = (int)ceil(self.unreadLabel.font.lineHeight * 1.5f); const int unreadBadgeHeight = (int)ceil(self.unreadLabel.font.lineHeight * 1.5f);
self.unreadBadge.layer.cornerRadius = unreadBadgeHeight / 2; self.unreadBadge.layer.cornerRadius = unreadBadgeHeight / 2;
@ -328,7 +328,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Constants #pragma mark - Constants
- (UIFont *)dateTimeFont - (UIFont *)unreadFont
{ {
return [UIFont ows_dynamicTypeCaption1Font].ows_mediumWeight; return [UIFont ows_dynamicTypeCaption1Font].ows_mediumWeight;
} }

Loading…
Cancel
Save