From 4b448ed018f6e727ca9911bdc2a485a30bdf8962 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 9 Jul 2018 09:58:02 -0400 Subject: [PATCH] Retweak colors. --- .../Cells/OWSGenericAttachmentView.h | 3 +- .../Cells/OWSGenericAttachmentView.m | 9 ++-- .../Cells/OWSMessageBubbleView.m | 8 +-- .../Cells/OWSMessageFooterView.m | 9 ++-- .../Cells/OWSQuotedMessageView.m | 19 +++---- Signal/src/views/AttachmentPointerView.swift | 13 +++-- SignalMessaging/utils/ConversationStyle.swift | 50 ++++++++++++++++++- 7 files changed, 81 insertions(+), 30 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.h b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.h index 0ed2cf037..f3cf1bb04 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.h +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.h @@ -4,13 +4,14 @@ NS_ASSUME_NONNULL_BEGIN +@class ConversationStyle; @class TSAttachmentStream; @interface OWSGenericAttachmentView : UIStackView - (instancetype)initWithAttachment:(TSAttachmentStream *)attachmentStream isIncoming:(BOOL)isIncoming; -- (void)createContents; +- (void)createContentsWithConversationStyle:(ConversationStyle *)conversationStyle; - (CGSize)measureSizeWithMaxMessageWidth:(CGFloat)maxMessageWidth; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m index ad0af852e..78907a2ca 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m @@ -4,6 +4,7 @@ #import "OWSGenericAttachmentView.h" #import "OWSBezierPathView.h" +#import "Signal-Swift.h" #import "UIFont+OWS.h" #import "UIView+OWS.h" #import "ViewControllerUtils.h" @@ -84,8 +85,10 @@ NS_ASSUME_NONNULL_BEGIN return 48.f; } -- (void)createContents +- (void)createContentsWithConversationStyle:(ConversationStyle *)conversationStyle { + OWSAssert(conversationStyle); + self.axis = UILayoutConstraintAxisHorizontal; self.alignment = UIStackViewAlignmentCenter; self.spacing = self.hSpacing; @@ -137,7 +140,7 @@ NS_ASSUME_NONNULL_BEGIN UILabel *topLabel = [UILabel new]; self.topLabel = topLabel; topLabel.text = topText; - topLabel.textColor = (self.isIncoming ? [UIColor ows_whiteColor] : [UIColor ows_light90Color]); + topLabel.textColor = [conversationStyle bubbleTextColorWithIsIncoming:self.isIncoming]; topLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; topLabel.font = [OWSGenericAttachmentView topLabelFont]; [labelsView addArrangedSubview:topLabel]; @@ -150,7 +153,7 @@ NS_ASSUME_NONNULL_BEGIN UILabel *bottomLabel = [UILabel new]; self.bottomLabel = bottomLabel; bottomLabel.text = bottomText; - bottomLabel.textColor = (self.isIncoming ? [UIColor colorWithWhite:1.f alpha:0.7f] : [UIColor ows_light60Color]); + bottomLabel.textColor = [conversationStyle bubbleSecondaryTextColorWithIsIncoming:self.isIncoming]; bottomLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; bottomLabel.font = [OWSGenericAttachmentView bottomLabelFont]; [labelsView addArrangedSubview:bottomLabel]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 74618dc74..dfc9d8d7d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -1022,7 +1022,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(self.viewItem.attachmentStream); OWSGenericAttachmentView *attachmentView = [[OWSGenericAttachmentView alloc] initWithAttachment:self.attachmentStream isIncoming:self.isIncoming]; - [attachmentView createContents]; + [attachmentView createContentsWithConversationStyle:self.conversationStyle]; [self addAttachmentUploadViewIfNecessary:attachmentView]; self.loadCellContentBlock = ^{ @@ -1040,7 +1040,9 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(self.attachmentPointer); AttachmentPointerView *downloadView = - [[AttachmentPointerView alloc] initWithAttachmentPointer:self.attachmentPointer isIncoming:self.isIncoming]; + [[AttachmentPointerView alloc] initWithAttachmentPointer:self.attachmentPointer + isIncoming:self.isIncoming + conversationStyle:self.conversationStyle]; UIView *wrapper = [UIView new]; [wrapper addSubview:downloadView]; @@ -1199,7 +1201,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(self.viewItem.attachmentStream); OWSGenericAttachmentView *attachmentView = [[OWSGenericAttachmentView alloc] initWithAttachment:self.attachmentStream isIncoming:self.isIncoming]; - [attachmentView createContents]; + [attachmentView createContentsWithConversationStyle:self.conversationStyle]; result = [attachmentView measureSizeWithMaxMessageWidth:maxMessageWidth]; break; } diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m index a713127d6..f2341a7a8 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m @@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN if (isOverlayingMedia) { textColor = [UIColor whiteColor]; } else { - textColor = [conversationStyle secondaryTextColorWithIsIncoming:isIncoming]; + textColor = [conversationStyle bubbleSecondaryTextColorWithIsIncoming:isIncoming]; } self.timestampLabel.textColor = textColor; @@ -117,11 +117,8 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(statusIndicatorImage.size.width <= self.maxImageWidth); self.statusIndicatorImageView.image = [statusIndicatorImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; - if (messageStatus == MessageReceiptStatusRead) { - self.statusIndicatorImageView.tintColor = [UIColor ows_signalBlueColor]; - } else { - self.statusIndicatorImageView.tintColor = textColor; - } + // TODO: How to indicate read status for transitional colors? + self.statusIndicatorImageView.tintColor = textColor; self.statusIndicatorImageView.hidden = NO; } else { self.statusIndicatorImageView.image = nil; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index 01bd49642..1f65657ab 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -117,7 +117,8 @@ NS_ASSUME_NONNULL_BEGIN - (UIColor *)highlightColor { BOOL isQuotingSelf = [NSObject isNullableObject:self.quotedMessage.authorId equalTo:TSAccountManager.localNumber]; - return (isQuotingSelf ? self.conversationStyle.bubbleColorOutgoingSent : [UIColor colorWithRGBHex:0xB5B5B5]); + return (isQuotingSelf ? self.conversationStyle.bubbleColorOutgoingSent + : [self.conversationStyle quotingSelfHighlightColor]); } #pragma mark - @@ -178,10 +179,7 @@ NS_ASSUME_NONNULL_BEGIN maskLayer.path = bezierPath.CGPath; }]; innerBubbleView.layer.mask = maskLayer; - // TODO: - innerBubbleView.backgroundColor - = (self.isOutgoing ? [self.conversationStyle.primaryColor colorWithAlphaComponent:0.25f] - : [UIColor colorWithWhite:1.f alpha:0.75f]); + innerBubbleView.backgroundColor = [self.conversationStyle quotedReplyBubbleColorWithIsIncoming:!self.isOutgoing]; [self addSubview:innerBubbleView]; [innerBubbleView autoPinLeadingToSuperviewMarginWithInset:self.bubbleHMargin]; [innerBubbleView autoPinTrailingToSuperviewMarginWithInset:self.bubbleHMargin]; @@ -195,8 +193,7 @@ NS_ASSUME_NONNULL_BEGIN [hStackView autoPinToSuperviewEdges]; UIView *stripeView = [UIView new]; - // TODO: - stripeView.backgroundColor = (self.isOutgoing ? [self.conversationStyle primaryColor] : [UIColor whiteColor]); + stripeView.backgroundColor = [self.conversationStyle quotedReplyStripeColorWithIsIncoming:!self.isOutgoing]; [stripeView autoSetDimension:ALDimensionWidth toSize:self.stripeThickness]; [stripeView setContentHuggingHigh]; [stripeView setCompressionResistanceHigh]; @@ -502,12 +499,12 @@ NS_ASSUME_NONNULL_BEGIN - (UIColor *)quotedAuthorColor { - return [UIColor ows_light90Color]; + return [self.conversationStyle quotedReplyAuthorColor]; } - (UIColor *)quotedTextColor { - return [UIColor ows_light90Color]; + return [self.conversationStyle quotedReplyTextColor]; } - (UIFont *)quotedTextFont @@ -517,7 +514,7 @@ NS_ASSUME_NONNULL_BEGIN - (UIColor *)fileTypeTextColor { - return [UIColor colorWithWhite:0.5f alpha:1.f]; + return [self.conversationStyle quotedReplyAttachmentColor]; } - (UIFont *)fileTypeFont @@ -527,7 +524,7 @@ NS_ASSUME_NONNULL_BEGIN - (UIColor *)filenameTextColor { - return [UIColor colorWithWhite:0.5f alpha:1.f]; + return [self.conversationStyle quotedReplyAttachmentColor]; } - (UIFont *)filenameFont diff --git a/Signal/src/views/AttachmentPointerView.swift b/Signal/src/views/AttachmentPointerView.swift index 8811e7a3b..5178049db 100644 --- a/Signal/src/views/AttachmentPointerView.swift +++ b/Signal/src/views/AttachmentPointerView.swift @@ -10,12 +10,14 @@ class AttachmentPointerView: UIStackView { let TAG = "[AttachmentPointerView]" + let isIncoming: Bool + let attachmentPointer: TSAttachmentPointer + let conversationStyle: ConversationStyle + let progressView = OWSProgressView() let nameLabel = UILabel() let statusLabel = UILabel() - let isIncoming: Bool let filename: String - let attachmentPointer: TSAttachmentPointer let genericFilename = NSLocalizedString("ATTACHMENT_DEFAULT_FILENAME", comment: "Generic filename for an attachment with no known name") var progress: CGFloat = 0 { @@ -25,9 +27,10 @@ class AttachmentPointerView: UIStackView { } @objc - required init(attachmentPointer: TSAttachmentPointer, isIncoming: Bool) { - self.isIncoming = isIncoming + required init(attachmentPointer: TSAttachmentPointer, isIncoming: Bool, conversationStyle: ConversationStyle) { self.attachmentPointer = attachmentPointer + self.isIncoming = isIncoming + self.conversationStyle = conversationStyle let attachmentPointerFilename = attachmentPointer.sourceFilename if let filename = attachmentPointerFilename, !filename.isEmpty { @@ -126,7 +129,7 @@ class AttachmentPointerView: UIStackView { } var textColor: UIColor { - return self.isIncoming ? UIColor.ows_white : UIColor.ows_light90 + return conversationStyle.bubbleTextColor(isIncoming: isIncoming) } @objc diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index 668141515..120ebbb4a 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -242,7 +242,55 @@ public class ConversationStyle: NSObject { } @objc - public func secondaryTextColor(isIncoming: Bool) -> UIColor { + public func bubbleSecondaryTextColor(isIncoming: Bool) -> UIColor { return bubbleTextColor(isIncoming: isIncoming).withAlphaComponent(0.7) } + + @objc + public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor { + // TODO: Values + // TODO: Should this reflect "quoting self" v. "quoting other"? + + if isIncoming { + return bubbleColorOutgoingSent.withAlphaComponent(0.7) + } else { + return ConversationStyle.defaultBubbleColorIncoming.withAlphaComponent(0.7) + } + } + + @objc + public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor { + // TODO: Values + // TODO: Should this reflect "quoting self" v. "quoting other"? + + if isIncoming { + return bubbleColorOutgoingSent + } else { + return ConversationStyle.defaultBubbleColorIncoming + } + } + + @objc + public func quotingSelfHighlightColor() -> UIColor { + // TODO: + return UIColor.init(rgbHex: 0xB5B5B5) + } + + @objc + public func quotedReplyAuthorColor() -> UIColor { + // TODO: + return UIColor.ows_light90 + } + + @objc + public func quotedReplyTextColor() -> UIColor { + // TODO: + return UIColor.ows_light90 + } + + @objc + public func quotedReplyAttachmentColor() -> UIColor { + // TODO: + return UIColor(white: 0.5, alpha: 1.0) + } }