diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.h b/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.h index 065e69c90..4c3eb02a8 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.h +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.h @@ -6,6 +6,7 @@ NS_ASSUME_NONNULL_BEGIN +@class ConversationStyle; @class ConversationViewItem; @class TSAttachmentStream; @@ -13,7 +14,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithAttachment:(TSAttachmentStream *)attachmentStream isIncoming:(BOOL)isIncoming - viewItem:(ConversationViewItem *)viewItem; + viewItem:(ConversationViewItem *)viewItem + conversationStyle:(ConversationStyle *)conversationStyle; - (void)createContents; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m index 406193862..029cdb0a4 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m @@ -18,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) TSAttachmentStream *attachmentStream; @property (nonatomic) BOOL isIncoming; @property (nonatomic, weak) ConversationViewItem *viewItem; +@property (nonatomic, readonly) ConversationStyle *conversationStyle; @property (nonatomic, nullable) UIButton *audioPlayPauseButton; @property (nonatomic, nullable) UILabel *audioBottomLabel; @@ -32,6 +33,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithAttachment:(TSAttachmentStream *)attachmentStream isIncoming:(BOOL)isIncoming viewItem:(ConversationViewItem *)viewItem + conversationStyle:(ConversationStyle *)conversationStyle { self = [super init]; @@ -39,6 +41,7 @@ NS_ASSUME_NONNULL_BEGIN _attachmentStream = attachmentStream; _isIncoming = isIncoming; _viewItem = viewItem; + _conversationStyle = conversationStyle; } return self; @@ -118,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN [self.audioProgressView setProgress:(self.audioDurationSeconds > 0 ? self.audioProgressSeconds / self.audioDurationSeconds : 0.f)]; - UIColor *progressColor = (self.isIncoming ? [UIColor ows_light02Color] : [UIColor ows_light60Color]); + UIColor *progressColor = [self.conversationStyle bubbleSecondaryTextColorWithIsIncoming:self.isIncoming]; self.audioProgressView.horizontalBarColor = progressColor; self.audioProgressView.progressColor = progressColor; } @@ -201,7 +204,7 @@ NS_ASSUME_NONNULL_BEGIN } UILabel *topLabel = [UILabel new]; topLabel.text = topText; - topLabel.textColor = (self.isIncoming ? [UIColor ows_whiteColor] : [UIColor ows_light90Color]); + topLabel.textColor = [self.conversationStyle bubbleTextColorWithIsIncoming:self.isIncoming]; topLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; topLabel.font = [OWSAudioMessageView labelFont]; @@ -213,7 +216,7 @@ NS_ASSUME_NONNULL_BEGIN UILabel *bottomLabel = [UILabel new]; self.audioBottomLabel = bottomLabel; [self updateAudioBottomLabel]; - bottomLabel.textColor = (self.isIncoming ? [UIColor colorWithWhite:1.f alpha:0.7f] : [UIColor ows_light60Color]); + bottomLabel.textColor = [self.conversationStyle bubbleSecondaryTextColorWithIsIncoming:self.isIncoming]; bottomLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; bottomLabel.font = [OWSAudioMessageView labelFont]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSCallMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSCallMessageCell.m index be2b5d587..d824c6a4b 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSCallMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSCallMessageCell.m @@ -137,7 +137,10 @@ NS_ASSUME_NONNULL_BEGIN [self applyTitleForCall:call label:self.titleLabel]; if (self.hasFooter) { - [self.footerView configureWithConversationViewItem:self.viewItem isOverlayingMedia:NO]; + [self.footerView configureWithConversationViewItem:self.viewItem + isOverlayingMedia:NO + conversationStyle:self.conversationStyle + isIncoming:call.isIncoming]; self.footerView.hidden = NO; } else { self.footerView.hidden = YES; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m index 7df1139d7..d610189d9 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m @@ -134,6 +134,11 @@ NS_ASSUME_NONNULL_BEGIN [self addSubview:label]; [label autoPinToSuperviewEdges]; [label autoSetDimension:ALDimensionHeight toSize:OWSContactShareButtonsView.buttonHeight]; + + self.userInteractionEnabled = YES; + UITapGestureRecognizer *tap = + [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; + [self addGestureRecognizer:tap]; } - (BOOL)handleTapGesture:(UITapGestureRecognizer *)sender diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.h b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.h index c374c9fcf..b8cab42bc 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.h +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.h @@ -5,10 +5,13 @@ NS_ASSUME_NONNULL_BEGIN @class ContactShareViewModel; +@class ConversationStyle; @interface OWSContactShareView : UIView -- (instancetype)initWithContactShare:(ContactShareViewModel *)contactShare isIncoming:(BOOL)isIncoming; +- (instancetype)initWithContactShare:(ContactShareViewModel *)contactShare + isIncoming:(BOOL)isIncoming + conversationStyle:(ConversationStyle *)conversationStyle; - (void)createContents; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m index 3b51fd810..a51bc035d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m @@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) ContactShareViewModel *contactShare; @property (nonatomic, readonly) BOOL isIncoming; +@property (nonatomic, readonly) ConversationStyle *conversationStyle; @property (nonatomic, readonly) OWSContactsManager *contactsManager; @end @@ -30,12 +31,14 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithContactShare:(ContactShareViewModel *)contactShare isIncoming:(BOOL)isIncoming + conversationStyle:(ConversationStyle *)conversationStyle { self = [super init]; if (self) { _contactShare = contactShare; _isIncoming = isIncoming; + _conversationStyle = conversationStyle; _contactsManager = [Environment current].contactsManager; } @@ -101,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN { self.layoutMargins = UIEdgeInsetsZero; - UIColor *textColor = (self.isIncoming ? [UIColor ows_whiteColor] : [UIColor ows_light90Color]); + UIColor *textColor = [self.conversationStyle bubbleTextColorWithIsIncoming:self.isIncoming]; AvatarImageView *avatarView = [AvatarImageView new]; avatarView.image = @@ -128,8 +131,7 @@ NS_ASSUME_NONNULL_BEGIN if (firstPhoneNumber.length > 0) { UILabel *bottomLabel = [UILabel new]; bottomLabel.text = [PhoneNumber bestEffortLocalizedPhoneNumberWithE164:firstPhoneNumber]; - // TODO: - bottomLabel.textColor = [textColor colorWithAlphaComponent:0.7f]; + bottomLabel.textColor = [self.conversationStyle bubbleSecondaryTextColorWithIsIncoming:self.isIncoming]; bottomLabel.lineBreakMode = NSLineBreakByTruncatingTail; bottomLabel.font = OWSContactShareView.subtitleFont; [labelsView addArrangedSubview:bottomLabel]; 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 6b612d25f..6e794396e 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -454,7 +454,10 @@ NS_ASSUME_NONNULL_BEGIN [bodyMediaView addSubview:gradientView]; [self.viewConstraints addObjectsFromArray:[gradientView autoPinToSuperviewEdges]]; - [self.footerView configureWithConversationViewItem:self.viewItem isOverlayingMedia:YES]; + [self.footerView configureWithConversationViewItem:self.viewItem + isOverlayingMedia:YES + conversationStyle:self.conversationStyle + isIncoming:self.isIncoming]; [bodyMediaView addSubview:self.footerView]; bodyMediaView.layoutMargins = UIEdgeInsetsZero; @@ -465,7 +468,10 @@ NS_ASSUME_NONNULL_BEGIN [self.footerView autoPinBottomToSuperviewMarginWithInset:self.conversationStyle.textInsetBottom], ]]; } else { - [self.footerView configureWithConversationViewItem:self.viewItem isOverlayingMedia:NO]; + [self.footerView configureWithConversationViewItem:self.viewItem + isOverlayingMedia:NO + conversationStyle:self.conversationStyle + isIncoming:self.isIncoming]; [textViews addObject:self.footerView]; } @@ -942,7 +948,8 @@ NS_ASSUME_NONNULL_BEGIN OWSAudioMessageView *audioMessageView = [[OWSAudioMessageView alloc] initWithAttachment:self.attachmentStream isIncoming:self.isIncoming - viewItem:self.viewItem]; + viewItem:self.viewItem + conversationStyle:self.conversationStyle]; self.viewItem.lastAudioMessageView = audioMessageView; [audioMessageView createContents]; [self addAttachmentUploadViewIfNecessary:audioMessageView]; @@ -1016,7 +1023,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 = ^{ @@ -1034,7 +1041,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]; @@ -1057,8 +1066,9 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssert(self.viewItem.contactShare); - OWSContactShareView *contactShareView = - [[OWSContactShareView alloc] initWithContactShare:self.viewItem.contactShare isIncoming:self.isIncoming]; + OWSContactShareView *contactShareView = [[OWSContactShareView alloc] initWithContactShare:self.viewItem.contactShare + isIncoming:self.isIncoming + conversationStyle:self.conversationStyle]; [contactShareView createContents]; // TODO: Should we change appearance if contact avatar is uploading? @@ -1193,7 +1203,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; } @@ -1604,11 +1614,15 @@ NS_ASSUME_NONNULL_BEGIN // Treat this as a "body media" gesture if: // // * There is a "body media" view. - // * The gesture occured within or above the "body media" view. + // * The gesture occured within or above the "body media" view... + // * ...OR if the message doesn't have body text. CGPoint location = [self convertPoint:locationInMessageBubble toView:self.bodyMediaView]; if (location.y <= self.bodyMediaView.height) { return OWSMessageGestureLocation_Media; } + if (!self.viewItem.hasBodyText) { + return OWSMessageGestureLocation_Media; + } } if (self.hasTapForMore) { diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.h b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.h index bc138e7b8..55ef23ff5 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.h +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.h @@ -2,13 +2,17 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // +@class ConversationStyle; @class ConversationViewItem; NS_ASSUME_NONNULL_BEGIN @interface OWSMessageFooterView : UIStackView -- (void)configureWithConversationViewItem:(ConversationViewItem *)viewItem isOverlayingMedia:(BOOL)isOverlayingMedia; +- (void)configureWithConversationViewItem:(ConversationViewItem *)viewItem + isOverlayingMedia:(BOOL)isOverlayingMedia + conversationStyle:(ConversationStyle *)conversationStyle + isIncoming:(BOOL)isIncoming; - (CGSize)measureWithConversationViewItem:(ConversationViewItem *)viewItem; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m index 75f6f6dfb..094616ec0 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m @@ -45,6 +45,8 @@ NS_ASSUME_NONNULL_BEGIN self.statusIndicatorImageView = [UIImageView new]; [self.statusIndicatorImageView setContentHuggingHigh]; [self addArrangedSubview:self.statusIndicatorImageView]; + + self.userInteractionEnabled = NO; } - (void)configureFonts @@ -70,19 +72,21 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Load -- (void)configureWithConversationViewItem:(ConversationViewItem *)viewItem isOverlayingMedia:(BOOL)isOverlayingMedia +- (void)configureWithConversationViewItem:(ConversationViewItem *)viewItem + isOverlayingMedia:(BOOL)isOverlayingMedia + conversationStyle:(ConversationStyle *)conversationStyle + isIncoming:(BOOL)isIncoming { OWSAssert(viewItem); + OWSAssert(conversationStyle); [self configureLabelsWithConversationViewItem:viewItem]; UIColor *textColor; if (isOverlayingMedia) { textColor = [UIColor whiteColor]; - } else if (viewItem.interaction.interactionType == OWSInteractionType_IncomingMessage) { - textColor = [UIColor colorWithWhite:1.f alpha:0.7f]; } else { - textColor = [UIColor ows_light60Color]; + textColor = [conversationStyle bubbleSecondaryTextColorWithIsIncoming:isIncoming]; } self.timestampLabel.textColor = textColor; @@ -115,11 +119,7 @@ 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; - } + 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 3bfe39fb8..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,9 +179,7 @@ NS_ASSUME_NONNULL_BEGIN maskLayer.path = bezierPath.CGPath; }]; innerBubbleView.layer.mask = maskLayer; - 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]; @@ -194,7 +193,7 @@ NS_ASSUME_NONNULL_BEGIN [hStackView autoPinToSuperviewEdges]; UIView *stripeView = [UIView new]; - 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]; @@ -500,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 @@ -515,7 +514,7 @@ NS_ASSUME_NONNULL_BEGIN - (UIColor *)fileTypeTextColor { - return [UIColor colorWithWhite:0.5f alpha:1.f]; + return [self.conversationStyle quotedReplyAttachmentColor]; } - (UIFont *)fileTypeFont @@ -525,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/categories/UIColor+OWS.h b/SignalMessaging/categories/UIColor+OWS.h index 56704f16c..c412210d9 100644 --- a/SignalMessaging/categories/UIColor+OWS.h +++ b/SignalMessaging/categories/UIColor+OWS.h @@ -75,6 +75,7 @@ NS_ASSUME_NONNULL_BEGIN @property (class, readonly, nonatomic) UIColor *ows_green800Color; @property (class, readonly, nonatomic) UIColor *ows_deepOrange900Color; @property (class, readonly, nonatomic) UIColor *ows_grey600Color; +@property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor; @end diff --git a/SignalMessaging/categories/UIColor+OWS.m b/SignalMessaging/categories/UIColor+OWS.m index 37c1e8586..45470a908 100644 --- a/SignalMessaging/categories/UIColor+OWS.m +++ b/SignalMessaging/categories/UIColor+OWS.m @@ -289,6 +289,11 @@ NS_ASSUME_NONNULL_BEGIN return [UIColor colorWithRGBHex:0x757575]; } ++ (UIColor *)ows_darkSkyBlueColor +{ + return [UIColor colorWithRed:32.f / 255.f green:144.f / 255.f blue:234.f / 255.f alpha:1.f]; +} + + (NSDictionary *)ows_conversationColorMap { static NSDictionary *colorMap; diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index 7abd3fcc0..089f1dc33 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -136,16 +136,14 @@ public class ConversationStyle: NSObject { private static let defaultBubbleColorIncoming = UIColor.ows_messageBubbleLightGray - // TODO: @objc - public let bubbleColorOutgoingUnsent = UIColor.ows_red + public let bubbleColorOutgoingUnsent = UIColor.ows_light10 - // TODO: @objc - public let bubbleColorOutgoingSending = UIColor.ows_light35 + public let bubbleColorOutgoingSending = UIColor.ows_fadedBlue @objc - public let bubbleColorOutgoingSent = UIColor.ows_light10 + public let bubbleColorOutgoingSent = UIColor.ows_darkSkyBlue @objc public var primaryColor: UIColor @@ -153,59 +151,108 @@ public class ConversationStyle: NSObject { @objc public func bubbleColor(message: TSMessage) -> UIColor { if message is TSIncomingMessage { - return primaryColor + return ConversationStyle.defaultBubbleColorIncoming } else if let outgoingMessage = message as? TSOutgoingMessage { switch outgoingMessage.messageState { case .failed: - return self.bubbleColorOutgoingUnsent + return bubbleColorOutgoingUnsent case .sending: - return self.bubbleColorOutgoingSending + return bubbleColorOutgoingSending default: - return self.bubbleColorOutgoingSent + return bubbleColorOutgoingSent } } else { owsFail("Unexpected message type: \(message)") - return UIColor.ows_materialBlue + return bubbleColorOutgoingSent } } @objc public func bubbleColor(call: TSCall) -> UIColor { - if call.isIncoming { - return primaryColor + return bubbleColor(isIncoming: call.isIncoming) + } + + @objc + public func bubbleColor(isIncoming: Bool) -> UIColor { + if isIncoming { + return ConversationStyle.defaultBubbleColorIncoming } else { return self.bubbleColorOutgoingSent } } @objc - public static var bubbleTextColorIncoming = UIColor.ows_white + public static var bubbleTextColorIncoming = UIColor.ows_light90 + public static var bubbleTextColorOutgoing = UIColor.ows_white @objc public func bubbleTextColor(message: TSMessage) -> UIColor { if message is TSIncomingMessage { return ConversationStyle.bubbleTextColorIncoming - } else if let outgoingMessage = message as? TSOutgoingMessage { - switch outgoingMessage.messageState { - case .failed: - return UIColor.ows_black - case .sending: - return UIColor.ows_black - default: - return UIColor.ows_black - } + } else if message is TSOutgoingMessage { + return ConversationStyle.bubbleTextColorOutgoing } else { owsFail("Unexpected message type: \(message)") - return UIColor.ows_materialBlue + return ConversationStyle.bubbleTextColorOutgoing } } @objc public func bubbleTextColor(call: TSCall) -> UIColor { - if call.isIncoming { + return bubbleTextColor(isIncoming: call.isIncoming) + } + + @objc + public func bubbleTextColor(isIncoming: Bool) -> UIColor { + if isIncoming { return ConversationStyle.bubbleTextColorIncoming } else { - return UIColor.ows_black + return ConversationStyle.bubbleTextColorOutgoing } } + + @objc + public func bubbleSecondaryTextColor(isIncoming: Bool) -> UIColor { + return bubbleTextColor(isIncoming: isIncoming).withAlphaComponent(0.7) + } + + @objc + public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor { + if isIncoming { + return bubbleColorOutgoingSent.withAlphaComponent(0.25) + } else { + return ConversationStyle.defaultBubbleColorIncoming.withAlphaComponent(0.75) + } + } + + @objc + public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor { + if isIncoming { + return bubbleColorOutgoingSent + } else { + return UIColor.white + } + } + + @objc + public func quotingSelfHighlightColor() -> UIColor { + // TODO: + return UIColor.init(rgbHex: 0xB5B5B5) + } + + @objc + public func quotedReplyAuthorColor() -> UIColor { + return UIColor.ows_light90 + } + + @objc + public func quotedReplyTextColor() -> UIColor { + return UIColor.ows_light90 + } + + @objc + public func quotedReplyAttachmentColor() -> UIColor { + // TODO: + return UIColor(white: 0.5, alpha: 1.0) + } }