Breaks: unread indicators and date headers.
This commit is contained in:
parent
4b60037e35
commit
a4703cec76
|
@ -73,8 +73,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.dateStrokeView autoSetDimension:ALDimensionHeight toSize:1.f];
|
||||
[self.dateHeaderLabel autoPinWidthToSuperview];
|
||||
[self.dateHeaderLabel autoVCenterInSuperview];
|
||||
// TODO: offset.
|
||||
[self.dateStrokeView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:self.dateHeaderLabel withOffset:0.f];
|
||||
[self.dateStrokeView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:self.dateHeaderLabel];
|
||||
|
||||
self.avatarView = [[AvatarImageView alloc] init];
|
||||
[self.avatarView autoSetDimension:ALDimensionWidth toSize:self.avatarSize];
|
||||
|
@ -232,7 +231,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
NSString *timeString = [dateHeaderTimeFormatter stringFromDate:date];
|
||||
|
||||
NSAttributedString *attributedText = [NSAttributedString new];
|
||||
attributedText = [attributedText rtlSafeAppend:dateString
|
||||
attributedText = [attributedText rtlSafeAppend:dateString.uppercaseString
|
||||
attributes:@{
|
||||
NSFontAttributeName : self.dateHeaderDateFont,
|
||||
NSForegroundColorAttributeName : [UIColor lightGrayColor],
|
||||
|
|
|
@ -17,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@property (nonatomic, nullable) TSUnreadIndicatorInteraction *interaction;
|
||||
|
||||
@property (nonatomic) UILabel *titleLabel;
|
||||
@property (nonatomic) UILabel *subtitleLabel;
|
||||
@property (nonatomic) UIView *strokeView;
|
||||
@property (nonatomic) NSArray<NSLayoutConstraint *> *layoutConstraints;
|
||||
|
||||
|
@ -54,6 +55,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
|
||||
self.subtitleLabel = [UILabel new];
|
||||
// TODO: color.
|
||||
self.subtitleLabel.textColor = [UIColor lightGrayColor];
|
||||
// The subtitle may wrap to a second line.
|
||||
self.subtitleLabel.numberOfLines = 0;
|
||||
self.subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
self.subtitleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.contentView addSubview:self.subtitleLabel];
|
||||
|
||||
[self configureFonts];
|
||||
}
|
||||
|
||||
|
@ -62,7 +72,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
// Update cell to reflect changes in dynamic text.
|
||||
//
|
||||
// TODO: Font size.
|
||||
self.titleLabel.font = UIFont.ows_dynamicTypeCaption1Font.ows_bold;
|
||||
self.titleLabel.font = UIFont.ows_dynamicTypeCaption1Font.ows_mediumWeight;
|
||||
self.subtitleLabel.font = UIFont.ows_dynamicTypeCaption1Font;
|
||||
}
|
||||
|
||||
+ (NSString *)cellReuseIdentifier
|
||||
|
@ -81,6 +92,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
TSUnreadIndicatorInteraction *interaction = (TSUnreadIndicatorInteraction *)self.viewItem.interaction;
|
||||
|
||||
self.titleLabel.text = [self titleForInteraction:interaction];
|
||||
self.subtitleLabel.text = [self subtitleForInteraction:interaction];
|
||||
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
|
@ -90,11 +102,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
[self.titleLabel autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterLeading],
|
||||
[self.titleLabel autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterTrailing],
|
||||
|
||||
// TODO: offset.
|
||||
[self.strokeView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:self.titleLabel withOffset:0.f],
|
||||
[self.strokeView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:self.titleLabel],
|
||||
[self.strokeView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterLeading],
|
||||
[self.strokeView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterTrailing],
|
||||
[self.strokeView autoSetDimension:ALDimensionHeight toSize:1.f],
|
||||
|
||||
[self.subtitleLabel autoPinEdge:ALEdgeTop
|
||||
toEdge:ALEdgeBottom
|
||||
ofView:self.titleLabel
|
||||
withOffset:self.subtitleVSpacing],
|
||||
[self.subtitleLabel autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterLeading],
|
||||
[self.subtitleLabel autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterTrailing],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -104,6 +122,28 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
.uppercaseString;
|
||||
}
|
||||
|
||||
- (NSString *)subtitleForInteraction:(TSUnreadIndicatorInteraction *)interaction
|
||||
{
|
||||
if (!interaction.hasMoreUnseenMessages) {
|
||||
return nil;
|
||||
}
|
||||
return (interaction.missingUnseenSafetyNumberChangeCount > 0
|
||||
? NSLocalizedString(@"MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES",
|
||||
@"Messages that indicates that there are more unseen messages.")
|
||||
: NSLocalizedString(@"MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES_AND_SAFETY_NUMBER_CHANGES",
|
||||
@"Messages that indicates that there are more unseen messages including safety number changes."));
|
||||
}
|
||||
|
||||
- (CGFloat)subtitleHMargin
|
||||
{
|
||||
return 20.f;
|
||||
}
|
||||
|
||||
- (CGFloat)subtitleVSpacing
|
||||
{
|
||||
return 3.f;
|
||||
}
|
||||
|
||||
- (CGSize)cellSizeWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
{
|
||||
OWSAssert(self.conversationStyle);
|
||||
|
@ -117,6 +157,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
CGSize result
|
||||
= CGSizeMake(self.conversationStyle.fullWidthContentWidth, self.titleLabel.font.lineHeight + vOffset * 2);
|
||||
|
||||
TSUnreadIndicatorInteraction *interaction = (TSUnreadIndicatorInteraction *)self.viewItem.interaction;
|
||||
self.subtitleLabel.text = [self subtitleForInteraction:interaction];
|
||||
if (self.subtitleLabel.text.length > 0) {
|
||||
result.height += self.subtitleVSpacing;
|
||||
result.height += ceil(
|
||||
[self.subtitleLabel sizeThatFits:CGSizeMake(self.conversationStyle.fullWidthContentWidth, CGFLOAT_MAX)]
|
||||
.height);
|
||||
}
|
||||
|
||||
return CGSizeCeil(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -1260,10 +1260,10 @@
|
|||
"MESSAGES_VIEW_UNREAD_INDICATOR" = "New Messages";
|
||||
|
||||
/* Messages that indicates that there are more unseen messages including safety number changes that be revealed by tapping the 'load earlier messages' button. Embeds {{the name of the 'load earlier messages' button}}. */
|
||||
"MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES_AND_SAFETY_NUMBER_CHANGES_FORMAT" = "There are more unread messages (including safety number changes) above. Tap \"%@\" to see them.";
|
||||
"MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES_AND_SAFETY_NUMBER_CHANGES" = "There are more unread messages (including safety number changes).";
|
||||
|
||||
/* Messages that indicates that there are more unseen messages that be revealed by tapping the 'load earlier messages' button. Embeds {{the name of the 'load earlier messages' button}} */
|
||||
"MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES_FORMAT" = "There are more unread messages above. Tap \"%@\" to see them.";
|
||||
"MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES" = "There are more unread messages.";
|
||||
|
||||
/* notification title */
|
||||
"MISSED_CALL" = "Missed call";
|
||||
|
|
Loading…
Reference in New Issue