From 35dc34855153860dd8277bbba89f39ce6a42f36a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 28 Jun 2018 13:26:17 -0400 Subject: [PATCH] Move conversation style. --- Signal.xcodeproj/project.pbxproj | 12 ++-- .../Cells/OWSMessageBubbleView.m | 4 +- .../Cells/OWSQuotedMessageView.m | 4 +- .../ViewControllers/DebugUI/DebugUIMessages.m | 22 +++--- .../utils}/ConversationStyle.swift | 55 ++++++++++++++ .../utils/OWSMessagesBubbleColors.swift | 71 ------------------- 6 files changed, 74 insertions(+), 94 deletions(-) rename {Signal/src/ViewControllers/ConversationView => SignalMessaging/utils}/ConversationStyle.swift (66%) delete mode 100644 SignalMessaging/utils/OWSMessagesBubbleColors.swift diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 58c1cb82c..63f522f4e 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -77,7 +77,6 @@ 344F248A20069F0600CFB4F4 /* ViewControllerUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 344F248820069F0600CFB4F4 /* ViewControllerUtils.h */; settings = {ATTRIBUTES = (Public, ); }; }; 344F248B20069F0600CFB4F4 /* ViewControllerUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 344F248920069F0600CFB4F4 /* ViewControllerUtils.m */; }; 344F248D2007CCD600CFB4F4 /* DisplayableText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 344F248C2007CCD600CFB4F4 /* DisplayableText.swift */; }; - 344F248F2007D7F200CFB4F4 /* OWSMessagesBubbleColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 344F248E2007D7F200CFB4F4 /* OWSMessagesBubbleColors.swift */; }; 344F2499200FD03300CFB4F4 /* SharingThreadPickerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 344F2495200FD03200CFB4F4 /* SharingThreadPickerViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 344F249A200FD03300CFB4F4 /* MessageApprovalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 344F2496200FD03200CFB4F4 /* MessageApprovalViewController.swift */; }; 344F249B200FD03300CFB4F4 /* SharingThreadPickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 344F2497200FD03200CFB4F4 /* SharingThreadPickerViewController.m */; }; @@ -143,6 +142,7 @@ 34641E1B2088DA4100E2EDE5 /* ScreenLockViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34641E192088DA3F00E2EDE5 /* ScreenLockViewController.m */; }; 34641E1C2088DA4100E2EDE5 /* ScreenLockViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34641E1A2088DA4000E2EDE5 /* ScreenLockViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34641E1F2088DA6D00E2EDE5 /* SAEScreenLockViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34641E1E2088DA6D00E2EDE5 /* SAEScreenLockViewController.m */; }; + 3466087220E550F400AFFE73 /* ConversationStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3466087120E550F300AFFE73 /* ConversationStyle.swift */; }; 34661FB820C1C0D60056EDD6 /* message_sent.aiff in Resources */ = {isa = PBXBuildFile; fileRef = 34661FB720C1C0D60056EDD6 /* message_sent.aiff */; }; 346B66311F4E29B200E5122F /* CropScaleImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346B66301F4E29B200E5122F /* CropScaleImageViewController.swift */; }; 347850311FD7494A007B8332 /* dripicons-v2.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5B1E787A9800DF2FB9 /* dripicons-v2.ttf */; }; @@ -223,7 +223,6 @@ 34D8C0271ED3673300188D7C /* DebugUIMessages.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D8C0241ED3673300188D7C /* DebugUIMessages.m */; }; 34D8C0281ED3673300188D7C /* DebugUITableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D8C0261ED3673300188D7C /* DebugUITableViewController.m */; }; 34D8C02B1ED3685800188D7C /* DebugUIContacts.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D8C02A1ED3685800188D7C /* DebugUIContacts.m */; }; - 34D920E220DD39EA00D51158 /* ConversationStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D920E120DD39E900D51158 /* ConversationStyle.swift */; }; 34D920E720E179C200D51158 /* OWSMessageFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D920E620E179C200D51158 /* OWSMessageFooterView.m */; }; 34D99C931F2937CC00D284D6 /* OWSAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D99C911F2937CC00D284D6 /* OWSAnalytics.swift */; }; 34DB0BED2011548B007B313F /* OWSDatabaseConverterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 34DB0BEC2011548B007B313F /* OWSDatabaseConverterTest.m */; }; @@ -681,7 +680,6 @@ 344F248820069F0600CFB4F4 /* ViewControllerUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewControllerUtils.h; path = SignalMessaging/contacts/ViewControllerUtils.h; sourceTree = SOURCE_ROOT; }; 344F248920069F0600CFB4F4 /* ViewControllerUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ViewControllerUtils.m; path = SignalMessaging/contacts/ViewControllerUtils.m; sourceTree = SOURCE_ROOT; }; 344F248C2007CCD600CFB4F4 /* DisplayableText.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisplayableText.swift; sourceTree = ""; }; - 344F248E2007D7F200CFB4F4 /* OWSMessagesBubbleColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWSMessagesBubbleColors.swift; sourceTree = ""; }; 344F2495200FD03200CFB4F4 /* SharingThreadPickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharingThreadPickerViewController.h; path = SignalMessaging/attachments/SharingThreadPickerViewController.h; sourceTree = SOURCE_ROOT; }; 344F2496200FD03200CFB4F4 /* MessageApprovalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MessageApprovalViewController.swift; path = SignalMessaging/attachments/MessageApprovalViewController.swift; sourceTree = SOURCE_ROOT; }; 344F2497200FD03200CFB4F4 /* SharingThreadPickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SharingThreadPickerViewController.m; path = SignalMessaging/attachments/SharingThreadPickerViewController.m; sourceTree = SOURCE_ROOT; }; @@ -753,6 +751,7 @@ 34641E1A2088DA4000E2EDE5 /* ScreenLockViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScreenLockViewController.h; path = SignalMessaging/ViewControllers/ScreenLockViewController.h; sourceTree = SOURCE_ROOT; }; 34641E1D2088DA6C00E2EDE5 /* SAEScreenLockViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAEScreenLockViewController.h; sourceTree = ""; }; 34641E1E2088DA6D00E2EDE5 /* SAEScreenLockViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SAEScreenLockViewController.m; sourceTree = ""; }; + 3466087120E550F300AFFE73 /* ConversationStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConversationStyle.swift; sourceTree = ""; }; 34661FB720C1C0D60056EDD6 /* message_sent.aiff */ = {isa = PBXFileReference; lastKnownFileType = audio.aiff; name = message_sent.aiff; path = Signal/AudioFiles/message_sent.aiff; sourceTree = SOURCE_ROOT; }; 346B66301F4E29B200E5122F /* CropScaleImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CropScaleImageViewController.swift; sourceTree = ""; }; 347850561FD86544007B8332 /* SAEFailedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAEFailedViewController.swift; sourceTree = ""; }; @@ -879,7 +878,6 @@ 34D8C0291ED3685800188D7C /* DebugUIContacts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugUIContacts.h; sourceTree = ""; }; 34D8C02A1ED3685800188D7C /* DebugUIContacts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DebugUIContacts.m; sourceTree = ""; }; 34D913491F62D4A500722898 /* SignalAttachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignalAttachment.swift; sourceTree = ""; }; - 34D920E120DD39E900D51158 /* ConversationStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConversationStyle.swift; sourceTree = ""; }; 34D920E520E179C100D51158 /* OWSMessageFooterView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageFooterView.h; sourceTree = ""; }; 34D920E620E179C200D51158 /* OWSMessageFooterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSMessageFooterView.m; sourceTree = ""; }; 34D99C8A1F27B13B00D284D6 /* OWSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSViewController.h; sourceTree = ""; }; @@ -1431,6 +1429,7 @@ 343D3D991E9283F100165CA4 /* BlockListUIUtils.h */, 343D3D9A1E9283F100165CA4 /* BlockListUIUtils.m */, 451777C71FD61554001225FF /* ConversationSearcher.swift */, + 3466087120E550F300AFFE73 /* ConversationStyle.swift */, 34480B4D1FD0A7A300BC14EF /* DebugLogger.h */, 34480B4E1FD0A7A300BC14EF /* DebugLogger.m */, 348F2EAD1F0D21BC00D4ECE0 /* DeviceSleepManager.swift */, @@ -1449,7 +1448,6 @@ 45666EC81D994C0D008FE134 /* OWSGroupAvatarBuilder.m */, 34480B481FD0A60200BC14EF /* OWSMath.h */, 3461293B1FD1D46900532771 /* OWSMath.m */, - 344F248E2007D7F200CFB4F4 /* OWSMessagesBubbleColors.swift */, 346129371FD1B47200532771 /* OWSPreferences.h */, 346129381FD1B47200532771 /* OWSPreferences.m */, 34641E172088D7E900E2EDE5 /* OWSScreenLock.swift */, @@ -1504,7 +1502,6 @@ 34D1F06A1F8678AA0066283D /* ConversationInputToolbar.m */, 343A65971FC4CFE7000477A1 /* ConversationScrollButton.h */, 343A65961FC4CFE6000477A1 /* ConversationScrollButton.m */, - 34D920E120DD39E900D51158 /* ConversationStyle.swift */, 34D1F06D1F8678AA0066283D /* ConversationViewController.h */, 34D1F06E1F8678AA0066283D /* ConversationViewController.m */, 34D1F06F1F8678AA0066283D /* ConversationViewItem.h */, @@ -3109,6 +3106,7 @@ 346129FB1FD5F31400532771 /* OWS101ExistingUsersBlockOnIdentityChange.m in Sources */, 344F248D2007CCD600CFB4F4 /* DisplayableText.swift in Sources */, 450998651FD8A34D00D89EB3 /* DeviceSleepManager.swift in Sources */, + 3466087220E550F400AFFE73 /* ConversationStyle.swift in Sources */, 3478506B1FD9B78A007B8332 /* NoopCallMessageHandler.swift in Sources */, 452D1AF320810B6F00A67F7F /* String+OWS.swift in Sources */, 451F8A3D1FD713CA005CB9DA /* ThreadViewHelper.m in Sources */, @@ -3133,7 +3131,6 @@ 4565ED06200EA29900C46DBB /* VideoPlayerView.swift in Sources */, 3461295B1FD1D74C00532771 /* Environment.m in Sources */, 346129D51FD20ADC00532771 /* UIViewController+OWS.m in Sources */, - 344F248F2007D7F200CFB4F4 /* OWSMessagesBubbleColors.swift in Sources */, 451F8A431FD714FE005CB9DA /* AvatarImageView.swift in Sources */, 346129C91FD2072E00532771 /* NSString+OWS.m in Sources */, 346129CB1FD2072E00532771 /* Promise+retainUntilComplete.swift in Sources */, @@ -3311,7 +3308,6 @@ 34D1F0C01F8EC1760066283D /* MessageRecipientStatusUtils.swift in Sources */, 45F659731E1BD99C00444429 /* CallKitCallUIAdaptee.swift in Sources */, 34277A5E20751BDC006049F2 /* OWSQuotedMessageView.m in Sources */, - 34D920E220DD39EA00D51158 /* ConversationStyle.swift in Sources */, 458DE9D61DEE3FD00071BB03 /* PeerConnectionClient.swift in Sources */, 45DDA6242090CEB500DE97F8 /* ConversationHeaderView.swift in Sources */, 45F32C242057297A00A300D5 /* MessageDetailViewController.swift in Sources */, diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 0bfe0440c..be32cb912 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -457,7 +457,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]); TSMessage *message = (TSMessage *)self.viewItem.interaction; - return [OWSMessagesBubbleColors bubbleColorWithMessage:message]; + return [ConversationStyle bubbleColorWithMessage:message]; } - (BOOL)hasBodyMediaWithThumbnail @@ -1183,7 +1183,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]); TSMessage *message = (TSMessage *)self.viewItem.interaction; - return [OWSMessagesBubbleColors bubbleTextColorWithMessage:message]; + return [ConversationStyle bubbleTextColorWithMessage:message]; } - (BOOL)isMediaBeingSent diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index f34a207d7..621f9f4e4 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -104,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN - (UIColor *)highlightColor { BOOL isQuotingSelf = [NSObject isNullableObject:self.quotedMessage.authorId equalTo:TSAccountManager.localNumber]; - return (isQuotingSelf ? OWSMessagesBubbleColors.bubbleColorOutgoingSent : [UIColor colorWithRGBHex:0xB5B5B5]); + return (isQuotingSelf ? ConversationStyle.bubbleColorOutgoingSent : [UIColor colorWithRGBHex:0xB5B5B5]); } #pragma mark - @@ -120,7 +120,7 @@ NS_ASSUME_NONNULL_BEGIN self.clipsToBounds = YES; self.boundsStrokeView = [OWSBubbleShapeView new]; - self.boundsStrokeView.strokeColor = OWSMessagesBubbleColors.bubbleColorIncoming; + self.boundsStrokeView.strokeColor = ConversationStyle.bubbleColorIncoming; self.boundsStrokeView.strokeThickness = 1.f; [self addSubview:self.boundsStrokeView]; [self.boundsStrokeView autoPinToSuperviewEdges]; diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m index a9fed819f..06a9f12dc 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m @@ -1326,7 +1326,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingUnsent] + backgroundColor:[ConversationStyle bubbleColorOutgoingUnsent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateFailed @@ -1334,7 +1334,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingUnsent] + backgroundColor:[ConversationStyle bubbleColorOutgoingUnsent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSending @@ -1342,7 +1342,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingUnsent] + backgroundColor:[ConversationStyle bubbleColorOutgoingUnsent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSent @@ -1351,7 +1351,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sending' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSending] + backgroundColor:[ConversationStyle bubbleColorOutgoingSending] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateFailed @@ -1359,7 +1359,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sending' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSending] + backgroundColor:[ConversationStyle bubbleColorOutgoingSending] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSending @@ -1367,7 +1367,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sending' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSending] + backgroundColor:[ConversationStyle bubbleColorOutgoingSending] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSent @@ -1376,7 +1376,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSent] + backgroundColor:[ConversationStyle bubbleColorOutgoingSent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateFailed @@ -1384,7 +1384,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSent] + backgroundColor:[ConversationStyle bubbleColorOutgoingSent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSending @@ -1392,7 +1392,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSent] + backgroundColor:[ConversationStyle bubbleColorOutgoingSent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSent @@ -1560,7 +1560,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeIncomingPngAction:thread actionLabel:@"Fake Incoming 'Incoming' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorIncoming] + backgroundColor:[ConversationStyle bubbleColorIncoming] textColor:[UIColor whiteColor] imageLabel:@"W" isAttachmentDownloaded:YES @@ -1568,7 +1568,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeIncomingPngAction:thread actionLabel:@"Fake Incoming 'Incoming' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleColors bubbleColorIncoming] + backgroundColor:[ConversationStyle bubbleColorIncoming] textColor:[UIColor whiteColor] imageLabel:@"W" isAttachmentDownloaded:NO diff --git a/Signal/src/ViewControllers/ConversationView/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift similarity index 66% rename from Signal/src/ViewControllers/ConversationView/ConversationStyle.swift rename to SignalMessaging/utils/ConversationStyle.swift index 9e22b30ee..a454a4989 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -107,4 +107,59 @@ public class ConversationStyle: NSObject { lastTextLineAxis = CGFloat(round(12 + messageTextFont.capHeight * 0.5)) } + + // MARK: Colors + + // TODO: Remove this! Incoming bubble colors are now dynamic. + @objc + public static let bubbleColorIncoming = UIColor.ows_messageBubbleLightGray + + // TODO: + @objc + public static let bubbleColorOutgoingUnsent = UIColor.ows_red + + // TODO: + @objc + public static let bubbleColorOutgoingSending = UIColor.ows_light35 + + @objc + public static let bubbleColorOutgoingSent = UIColor.ows_light10 + + @objc + public static func bubbleColor(message: TSMessage) -> UIColor { + if message is TSIncomingMessage { + return ConversationStyle.bubbleColorIncoming + } else if let outgoingMessage = message as? TSOutgoingMessage { + switch outgoingMessage.messageState { + case .failed: + return ConversationStyle.bubbleColorOutgoingUnsent + case .sending: + return ConversationStyle.bubbleColorOutgoingSending + default: + return ConversationStyle.bubbleColorOutgoingSent + } + } else { + owsFail("Unexpected message type: \(message)") + return UIColor.ows_materialBlue + } + } + + @objc + public static func bubbleTextColor(message: TSMessage) -> UIColor { + if message is TSIncomingMessage { + return UIColor.ows_white + } 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 { + owsFail("Unexpected message type: \(message)") + return UIColor.ows_materialBlue + } + } } diff --git a/SignalMessaging/utils/OWSMessagesBubbleColors.swift b/SignalMessaging/utils/OWSMessagesBubbleColors.swift deleted file mode 100644 index 89feaae58..000000000 --- a/SignalMessaging/utils/OWSMessagesBubbleColors.swift +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -import Foundation -import SignalServiceKit - -// TODO: Possibly pull this into Conversation Style. -@objc -public class OWSMessagesBubbleColors: NSObject { - - override private init() { - super.init() - } - - @objc - public static let shared = OWSMessagesBubbleColors() - - // TODO: Remove this! Incoming bubble colors are now dynamic. - @objc - public static let bubbleColorIncoming = UIColor.ows_messageBubbleLightGray - - // TODO: - @objc - public static let bubbleColorOutgoingUnsent = UIColor.ows_red - - // TODO: - @objc - public static let bubbleColorOutgoingSending = UIColor.ows_light35 - - @objc - public static let bubbleColorOutgoingSent = UIColor.ows_light10 - - @objc - public static func bubbleColor(message: TSMessage) -> UIColor { - if message is TSIncomingMessage { - return OWSMessagesBubbleColors.bubbleColorIncoming - } else if let outgoingMessage = message as? TSOutgoingMessage { - switch outgoingMessage.messageState { - case .failed: - return OWSMessagesBubbleColors.bubbleColorOutgoingUnsent - case .sending: - return OWSMessagesBubbleColors.bubbleColorOutgoingSending - default: - return OWSMessagesBubbleColors.bubbleColorOutgoingSent - } - } else { - owsFail("Unexpected message type: \(message)") - return UIColor.ows_materialBlue - } - } - - @objc - public static func bubbleTextColor(message: TSMessage) -> UIColor { - if message is TSIncomingMessage { - return UIColor.ows_white - } 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 { - owsFail("Unexpected message type: \(message)") - return UIColor.ows_materialBlue - } - } -}