|
|
@ -11,9 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@interface OWSMessageFooterView ()
|
|
|
|
@interface OWSMessageFooterView ()
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) UILabel *timestampLabel;
|
|
|
|
@property (nonatomic) UILabel *timestampLabel;
|
|
|
|
@property (nonatomic) UIView *spacerView;
|
|
|
|
@property (nonatomic) UIImageView *statusIndicatorImageView;
|
|
|
|
@property (nonatomic) UILabel *statusLabel;
|
|
|
|
|
|
|
|
@property (nonatomic) UIView *statusIndicatorView;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
@ -41,42 +39,32 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
self.alignment = UIStackViewAlignmentCenter;
|
|
|
|
self.alignment = UIStackViewAlignmentCenter;
|
|
|
|
|
|
|
|
|
|
|
|
self.timestampLabel = [UILabel new];
|
|
|
|
self.timestampLabel = [UILabel new];
|
|
|
|
// TODO: Color
|
|
|
|
|
|
|
|
self.timestampLabel.textColor = [UIColor lightGrayColor];
|
|
|
|
|
|
|
|
[self addArrangedSubview:self.timestampLabel];
|
|
|
|
[self addArrangedSubview:self.timestampLabel];
|
|
|
|
|
|
|
|
|
|
|
|
self.spacerView = [UIView new];
|
|
|
|
self.statusIndicatorImageView = [UIImageView new];
|
|
|
|
[self.spacerView setContentHuggingLow];
|
|
|
|
[self.statusIndicatorImageView setContentHuggingHigh];
|
|
|
|
[self addArrangedSubview:self.spacerView];
|
|
|
|
[self addArrangedSubview:self.statusIndicatorImageView];
|
|
|
|
|
|
|
|
|
|
|
|
self.statusLabel = [UILabel new];
|
|
|
|
|
|
|
|
// TODO: Color
|
|
|
|
|
|
|
|
self.statusLabel.textColor = [UIColor lightGrayColor];
|
|
|
|
|
|
|
|
[self addArrangedSubview:self.statusLabel];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.statusIndicatorView = [UIView new];
|
|
|
|
|
|
|
|
[self.statusIndicatorView autoSetDimension:ALDimensionWidth toSize:self.statusIndicatorSize];
|
|
|
|
|
|
|
|
[self.statusIndicatorView autoSetDimension:ALDimensionHeight toSize:self.statusIndicatorSize];
|
|
|
|
|
|
|
|
self.statusIndicatorView.layer.cornerRadius = self.statusIndicatorSize * 0.5f;
|
|
|
|
|
|
|
|
[self addArrangedSubview:self.statusIndicatorView];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)configureFonts
|
|
|
|
- (void)configureFonts
|
|
|
|
{
|
|
|
|
{
|
|
|
|
self.timestampLabel.font = UIFont.ows_dynamicTypeCaption2Font;
|
|
|
|
self.timestampLabel.font = UIFont.ows_dynamicTypeCaption1Font;
|
|
|
|
self.statusLabel.font = UIFont.ows_dynamicTypeCaption2Font;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)statusIndicatorSize
|
|
|
|
- (CGFloat)hSpacing
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO: Review constant.
|
|
|
|
// TODO: Review constant.
|
|
|
|
return 12.f;
|
|
|
|
return 8.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)hSpacing
|
|
|
|
- (CGFloat)maxImageWidth
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO: Review constant.
|
|
|
|
return 18.f;
|
|
|
|
return 8.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)imageHeight
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 12.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Load
|
|
|
|
#pragma mark - Load
|
|
|
@ -87,19 +75,75 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
[self configureLabelsWithConversationViewItem:viewItem];
|
|
|
|
[self configureLabelsWithConversationViewItem:viewItem];
|
|
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
|
|
|
self.statusIndicatorView.backgroundColor = [UIColor orangeColor];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL isOutgoing = (viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage);
|
|
|
|
// TODO: Constants
|
|
|
|
for (UIView *subview in @[
|
|
|
|
for (UIView *subview in @[
|
|
|
|
self.spacerView,
|
|
|
|
self.timestampLabel,
|
|
|
|
self.statusLabel,
|
|
|
|
self.statusIndicatorImageView,
|
|
|
|
self.statusIndicatorView,
|
|
|
|
|
|
|
|
]) {
|
|
|
|
]) {
|
|
|
|
subview.hidden = !isOutgoing;
|
|
|
|
if (hasShadows) {
|
|
|
|
|
|
|
|
subview.layer.shadowColor = [UIColor blackColor].CGColor;
|
|
|
|
|
|
|
|
subview.layer.shadowOpacity = 0.35f;
|
|
|
|
|
|
|
|
subview.layer.shadowOffset = CGSizeZero;
|
|
|
|
|
|
|
|
subview.layer.shadowRadius = 0.5f;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
subview.layer.shadowColor = nil;
|
|
|
|
|
|
|
|
subview.layer.shadowOpacity = 0.f;
|
|
|
|
|
|
|
|
subview.layer.shadowOffset = CGSizeZero;
|
|
|
|
|
|
|
|
subview.layer.shadowRadius = 0.f;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[self setHasShadows:hasShadows viewItem:viewItem];
|
|
|
|
UIColor *textColor;
|
|
|
|
|
|
|
|
if (hasShadows) {
|
|
|
|
|
|
|
|
textColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
} else if (viewItem.interaction.interactionType == OWSInteractionType_IncomingMessage) {
|
|
|
|
|
|
|
|
textColor = [UIColor colorWithWhite:1.f alpha:0.7f];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
textColor = [UIColor ows_light60Color];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
self.timestampLabel.textColor = textColor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage) {
|
|
|
|
|
|
|
|
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)viewItem.interaction;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIImage *_Nullable statusIndicatorImage = nil;
|
|
|
|
|
|
|
|
MessageReceiptStatus messageStatus =
|
|
|
|
|
|
|
|
[MessageRecipientStatusUtils recipientStatusWithOutgoingMessage:outgoingMessage referenceView:self];
|
|
|
|
|
|
|
|
switch (messageStatus) {
|
|
|
|
|
|
|
|
case MessageReceiptStatusUploading:
|
|
|
|
|
|
|
|
case MessageReceiptStatusSending:
|
|
|
|
|
|
|
|
statusIndicatorImage = [UIImage imageNamed:@"message_status_sending"];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MessageReceiptStatusSent:
|
|
|
|
|
|
|
|
case MessageReceiptStatusSkipped:
|
|
|
|
|
|
|
|
statusIndicatorImage = [UIImage imageNamed:@"message_status_sent"];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MessageReceiptStatusDelivered:
|
|
|
|
|
|
|
|
case MessageReceiptStatusRead:
|
|
|
|
|
|
|
|
statusIndicatorImage = [UIImage imageNamed:@"message_status_delivered"];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MessageReceiptStatusFailed:
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
|
|
|
statusIndicatorImage = [UIImage imageNamed:@"message_status_sending"];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OWSAssert(statusIndicatorImage);
|
|
|
|
|
|
|
|
OWSAssert(statusIndicatorImage.size.width <= self.maxImageWidth);
|
|
|
|
|
|
|
|
self.statusIndicatorImageView.image =
|
|
|
|
|
|
|
|
[statusIndicatorImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
|
|
|
|
|
|
|
if (messageStatus == MessageReceiptStatusRead) {
|
|
|
|
|
|
|
|
// TODO: Tint the icon with the conversation color.
|
|
|
|
|
|
|
|
self.statusIndicatorImageView.tintColor = textColor;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
self.statusIndicatorImageView.tintColor = textColor;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
self.statusIndicatorImageView.hidden = NO;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
self.statusIndicatorImageView.image = nil;
|
|
|
|
|
|
|
|
self.statusIndicatorImageView.hidden = YES;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)configureLabelsWithConversationViewItem:(ConversationViewItem *)viewItem
|
|
|
|
- (void)configureLabelsWithConversationViewItem:(ConversationViewItem *)viewItem
|
|
|
@ -109,7 +153,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
[self configureFonts];
|
|
|
|
[self configureFonts];
|
|
|
|
|
|
|
|
|
|
|
|
self.timestampLabel.text = [DateUtil formatTimestampShort:viewItem.interaction.timestamp];
|
|
|
|
self.timestampLabel.text = [DateUtil formatTimestampShort:viewItem.interaction.timestamp];
|
|
|
|
self.statusLabel.text = [self messageStatusTextForConversationViewItem:viewItem];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (CGSize)measureWithConversationViewItem:(ConversationViewItem *)viewItem
|
|
|
|
- (CGSize)measureWithConversationViewItem:(ConversationViewItem *)viewItem
|
|
|
@ -119,11 +162,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
[self configureLabelsWithConversationViewItem:viewItem];
|
|
|
|
[self configureLabelsWithConversationViewItem:viewItem];
|
|
|
|
|
|
|
|
|
|
|
|
CGSize result = CGSizeZero;
|
|
|
|
CGSize result = CGSizeZero;
|
|
|
|
result.height
|
|
|
|
result.height = MAX(self.timestampLabel.font.lineHeight, self.imageHeight);
|
|
|
|
= MAX(self.timestampLabel.font.lineHeight, MAX(self.statusLabel.font.lineHeight, self.statusIndicatorSize));
|
|
|
|
|
|
|
|
if (viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage) {
|
|
|
|
if (viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage) {
|
|
|
|
result.width = ([self.timestampLabel sizeThatFits:CGSizeZero].width +
|
|
|
|
result.width = ([self.timestampLabel sizeThatFits:CGSizeZero].width + self.maxImageWidth + self.hSpacing);
|
|
|
|
[self.statusLabel sizeThatFits:CGSizeZero].width + self.statusIndicatorSize + self.hSpacing * 3.f);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
result.width = [self.timestampLabel sizeThatFits:CGSizeZero].width;
|
|
|
|
result.width = [self.timestampLabel sizeThatFits:CGSizeZero].width;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -143,42 +184,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
return statusMessage;
|
|
|
|
return statusMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Shadows
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setHasShadows:(BOOL)hasShadows viewItem:(ConversationViewItem *)viewItem
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: Constants
|
|
|
|
|
|
|
|
for (UIView *subview in @[
|
|
|
|
|
|
|
|
self.timestampLabel,
|
|
|
|
|
|
|
|
self.statusLabel,
|
|
|
|
|
|
|
|
self.statusIndicatorView,
|
|
|
|
|
|
|
|
]) {
|
|
|
|
|
|
|
|
if (hasShadows) {
|
|
|
|
|
|
|
|
subview.layer.shadowColor = [UIColor blackColor].CGColor;
|
|
|
|
|
|
|
|
subview.layer.shadowOpacity = 0.35f;
|
|
|
|
|
|
|
|
subview.layer.shadowOffset = CGSizeZero;
|
|
|
|
|
|
|
|
subview.layer.shadowRadius = 0.5f;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
subview.layer.shadowColor = nil;
|
|
|
|
|
|
|
|
subview.layer.shadowOpacity = 0.f;
|
|
|
|
|
|
|
|
subview.layer.shadowOffset = CGSizeZero;
|
|
|
|
|
|
|
|
subview.layer.shadowRadius = 0.f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIColor *textColor;
|
|
|
|
|
|
|
|
if (hasShadows) {
|
|
|
|
|
|
|
|
textColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
} else if (viewItem.interaction.interactionType == OWSInteractionType_IncomingMessage) {
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
|
|
|
textColor = [UIColor lightGrayColor];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
textColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
self.timestampLabel.textColor = textColor;
|
|
|
|
|
|
|
|
self.statusLabel.textColor = textColor;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|