@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
/ / * footerView ( below message )
@ property ( nonatomic ) OWSMessageBubbleView * messageBubbleView ;
@ property ( nonatomic ) UIView * dateHeaderView ;
@ property ( nonatomic ) UIView * dateStrokeView ;
@ property ( nonatomic ) UILabel * dateHeaderLabel ;
@ property ( nonatomic ) AvatarImageView * avatarView ;
@ -55,22 +57,28 @@ NS_ASSUME_NONNULL_BEGIN
self . messageBubbleView = [ OWSMessageBubbleView new ] ;
[ self . contentView addSubview : self . messageBubbleView ] ;
self . dateHeaderView = [ UIView new ] ;
self . dateStrokeView = [ UIView new ] ;
self . dateStrokeView . backgroundColor = [ UIColor lightGrayColor ] ;
[ self . dateHeaderView addSubview : self . dateStrokeView ] ;
self . dateHeaderLabel = [ UILabel new ] ;
self . dateHeaderLabel . font = self . dateHeaderDateFont ;
self . dateHeaderLabel . textAlignment = NSTextAlignmentCenter ;
self . dateHeaderLabel . textColor = [ UIColor lightGrayColor ] ;
[ self . contentView addSubview : self . dateHeaderLabel ] ;
[ self . dateHeaderView addSubview : self . dateHeaderLabel ] ;
[ self . dateStrokeView autoPinWidthToSuperview ] ;
[ self . dateStrokeView autoSetDimension : ALDimensionHeight toSize : 1. f ] ;
[ self . dateHeaderLabel autoPinWidthToSuperview ] ;
[ self . dateHeaderLabel autoVCenterInSuperview ] ;
[ self . dateStrokeView autoPinEdge : ALEdgeBottom toEdge : ALEdgeTop ofView : self . dateHeaderLabel ] ;
self . avatarView = [ [ AvatarImageView alloc ] init ] ;
[ self . contentView addSubview : self . avatarView ] ;
[ self . avatarView autoSetDimension : ALDimensionWidth toSize : self . avatarSize ] ;
[ self . avatarView autoSetDimension : ALDimensionHeight toSize : self . avatarSize ] ;
/ / Hide these views by default .
self . dateHeaderLabel . hidden = YES ;
self . avatarView . hidden = YES ;
[ self . messageBubbleView autoPinEdge : ALEdgeTop toEdge : ALEdgeBottom ofView : self . dateHeaderLabel ] ;
[ self . messageBubbleView autoPinBottomToSuperviewMarginWithInset : 0 ] ;
self . contentView . userInteractionEnabled = YES ;
@ -180,8 +188,6 @@ NS_ASSUME_NONNULL_BEGIN
ofView : self . avatarView
withOffset : avatarBottomMargin ] ,
] ] ;
[ self . messageBubbleView logFrameLaterWithLabel : @ "messageBubbleView "] ;
[ self . avatarView logFrameLaterWithLabel : @ "avatarView "] ;
}
}
@ -225,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 ] ,
@ -244,20 +250,19 @@ NS_ASSUME_NONNULL_BEGIN
referenceView : self ] ;
self . dateHeaderLabel . attributedText = attributedText ;
self . dateHeaderLabel . hidden = NO ;
[ self . contentView addSubview : self . dateHeaderView ] ;
[ self . viewConstraints addObjectsFromArray : @ [
/ / TODO : Are data headers symmetric or are they asymmetric ? gutters are asymmetric ?
[ self . dateHeaderLabel autoPinLeadingToSuperviewMarginWithInset : self . conversationStyle . gutterLeading ] ,
[ self . dateHeaderLabel autoPinTrailingToSuperviewMarginWithInset : self . conversationStyle . gutterTrailing ] ,
[ self . dateHeaderLabel autoPinEdgeToSuperviewEdge : ALEdgeTop ] ,
[ self . dateHeaderLabel autoSetDimension : ALDimensionHeight toSize : self . dateHeaderHeight ] ,
[ self . dateHeaderView autoPinLeadingToSuperviewMarginWithInset : self . conversationStyle . gutterLeading ] ,
[ self . dateHeaderView autoPinTrailingToSuperviewMarginWithInset : self . conversationStyle . gutterTrailing ] ,
[ self . dateHeaderView autoPinEdgeToSuperviewEdge : ALEdgeTop ] ,
[ self . dateHeaderView autoSetDimension : ALDimensionHeight toSize : self . dateHeaderHeight ] ,
[ self . messageBubbleView autoPinEdge : ALEdgeTop toEdge : ALEdgeBottom ofView : self . dateHeaderView ] ,
] ] ;
} else {
self . dateHeaderLabel . hidden = YES ;
[ self . viewConstraints addObjectsFromArray : @ [
[ self . dateHeaderLabel autoSetDimension : ALDimensionHeight toSize : 0 ] ,
[ self . dateHeaderLabel autoPinEdgeToSuperviewEdge : ALEdgeTop ] ,
[ self . messageBubbleView autoPinEdgeToSuperviewEdge : ALEdgeTop ] ,
] ] ;
}
}
@ -298,7 +303,7 @@ NS_ASSUME_NONNULL_BEGIN
diameter : self . avatarSize
contactsManager : contactsManager ] ;
self . avatarView . image = [ avatarBuilder build ] ;
self . avatarView . hidden = NO ;
[ self . contentView addSubview : self . avatarView ] ;
[ [ NSNotificationCenter defaultCenter ] addObserver : self
selector : @ selector ( otherUsersProfileDidChange : )
@ -365,11 +370,16 @@ NS_ASSUME_NONNULL_BEGIN
return cellSize ;
}
- ( CGFloat ) dateHeaderVSpacing
{
return 24. f ;
}
- ( CGFloat ) dateHeaderHeight
{
if ( self . viewItem . shouldShowDate ) {
/ / Add 5 pt spacing above and below the date header .
return ( CGFloat ) ceil ( MAX ( self . dateHeaderDateFont . lineHeight , self . dateHeaderTimeFont . lineHeight ) + 10. f ) ;
CGFloat textHeight = MAX ( self . dateHeaderDateFont . capHeight , self . dateHeaderTimeFont . capHeight ) ;
return ( CGFloat ) ceil ( textHeight + self . dateHeaderVSpacing * 2 ) ;
} else {
return 0. f ;
}
@ -387,10 +397,10 @@ NS_ASSUME_NONNULL_BEGIN
[ self . messageBubbleView prepareForReuse ] ;
[ self . messageBubbleView unloadContent ] ;
self . dateHeaderLabel . text = nil ;
self . dateHeaderLabel . hidden = YES ;
[ self . dateHeaderView removeFromSuperview ] ;
self . avatarView . image = nil ;
self . avatarView . hidden = YES ;
[ self . avatarView removeFromSuperview ] ;
[ self hideMenuControllerIfNecessary ] ;