From 5a99cd347f245d949ee31cdb34312e7a72fb7f8b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 27 Sep 2018 11:38:48 -0400 Subject: [PATCH] Pull out OWSConversationColor to its own file. --- Signal.xcodeproj/project.pbxproj | 32 +- .../ColorPickerViewController.swift | 8 +- .../OWSConversationSettingsViewController.m | 2 +- SignalMessaging/SignalMessaging.h | 1 + .../appearance/OWSConversationColor.h | 83 ++++ .../appearance/OWSConversationColor.m | 380 ++++++++++++++++++ .../{categories => appearance}/Theme.h | 0 .../{categories => appearance}/Theme.m | 0 SignalMessaging/categories/UIColor+OWS.h | 76 ---- SignalMessaging/categories/UIColor+OWS.m | 372 ----------------- SignalMessaging/utils/ConversationStyle.swift | 2 +- .../utils/OWSContactAvatarBuilder.m | 4 +- SignalMessaging/utils/OWSGroupAvatarBuilder.m | 3 +- 13 files changed, 498 insertions(+), 465 deletions(-) create mode 100644 SignalMessaging/appearance/OWSConversationColor.h create mode 100644 SignalMessaging/appearance/OWSConversationColor.m rename SignalMessaging/{categories => appearance}/Theme.h (100%) rename SignalMessaging/{categories => appearance}/Theme.m (100%) diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index b19558679..915cfa2ab 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -129,6 +129,10 @@ 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 */; }; + 346941A1215D2EE400B5BFAD /* Theme.h in Headers */ = {isa = PBXBuildFile; fileRef = 3469419D215D2EE400B5BFAD /* Theme.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 346941A2215D2EE400B5BFAD /* OWSConversationColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 3469419E215D2EE400B5BFAD /* OWSConversationColor.m */; }; + 346941A3215D2EE400B5BFAD /* Theme.m in Sources */ = {isa = PBXBuildFile; fileRef = 3469419F215D2EE400B5BFAD /* Theme.m */; }; + 346941A4215D2EE400B5BFAD /* OWSConversationColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 346941A0215D2EE400B5BFAD /* OWSConversationColor.h */; settings = {ATTRIBUTES = (Public, ); }; }; 346B66311F4E29B200E5122F /* CropScaleImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346B66301F4E29B200E5122F /* CropScaleImageViewController.swift */; }; 347850311FD7494A007B8332 /* dripicons-v2.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5B1E787A9800DF2FB9 /* dripicons-v2.ttf */; }; 347850321FD7494A007B8332 /* ElegantIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5D1E787BD800DF2FB9 /* ElegantIcons.ttf */; }; @@ -227,8 +231,6 @@ 34C6B0AB1FA0E46F00D35993 /* test-mp3.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0A71FA0E46F00D35993 /* test-mp3.mp3 */; }; 34C6B0AC1FA0E46F00D35993 /* test-mp4.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0A81FA0E46F00D35993 /* test-mp4.mp4 */; }; 34C6B0AE1FA0E4AA00D35993 /* test-jpg.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0AD1FA0E4AA00D35993 /* test-jpg.jpg */; }; - 34C82E5120F8E1F300E9688D /* Theme.h in Headers */ = {isa = PBXBuildFile; fileRef = 34C82E4F20F8E1F000E9688D /* Theme.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 34C82E5220F8E1F300E9688D /* Theme.m in Sources */ = {isa = PBXBuildFile; fileRef = 34C82E5020F8E1F100E9688D /* Theme.m */; }; 34CA631B2097806F00E526A0 /* OWSContactShareView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CA631A2097806E00E526A0 /* OWSContactShareView.m */; }; 34CE88E71F2FB9A10098030F /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88E61F2FB9A10098030F /* ProfileViewController.m */; }; 34CF0787203E6B78005C4D61 /* busy_tone_ansi.caf in Resources */ = {isa = PBXBuildFile; fileRef = 34CF0783203E6B77005C4D61 /* busy_tone_ansi.caf */; }; @@ -759,6 +761,10 @@ 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; }; + 3469419D215D2EE400B5BFAD /* Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Theme.h; sourceTree = ""; }; + 3469419E215D2EE400B5BFAD /* OWSConversationColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSConversationColor.m; sourceTree = ""; }; + 3469419F215D2EE400B5BFAD /* Theme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Theme.m; sourceTree = ""; }; + 346941A0215D2EE400B5BFAD /* OWSConversationColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSConversationColor.h; sourceTree = ""; }; 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 = ""; }; 3478505A1FD999D5007B8332 /* et */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = et; path = translations/et.lproj/Localizable.strings; sourceTree = ""; }; @@ -875,8 +881,6 @@ 34C6B0A71FA0E46F00D35993 /* test-mp3.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "test-mp3.mp3"; sourceTree = ""; }; 34C6B0A81FA0E46F00D35993 /* test-mp4.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "test-mp4.mp4"; sourceTree = ""; }; 34C6B0AD1FA0E4AA00D35993 /* test-jpg.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "test-jpg.jpg"; sourceTree = ""; }; - 34C82E4F20F8E1F000E9688D /* Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Theme.h; sourceTree = ""; }; - 34C82E5020F8E1F100E9688D /* Theme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Theme.m; sourceTree = ""; }; 34CA1C261F7156F300E51C51 /* MessageDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageDetailViewController.swift; sourceTree = ""; }; 34CA63192097806E00E526A0 /* OWSContactShareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactShareView.h; sourceTree = ""; }; 34CA631A2097806E00E526A0 /* OWSContactShareView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactShareView.m; sourceTree = ""; }; @@ -1541,8 +1545,6 @@ 346129C01FD2072C00532771 /* NSString+OWS.h */, 346129C21FD2072D00532771 /* NSString+OWS.m */, 452D1AF220810B6F00A67F7F /* String+OWS.swift */, - 34C82E4F20F8E1F000E9688D /* Theme.h */, - 34C82E5020F8E1F100E9688D /* Theme.m */, 34480B5D1FD0A98800BC14EF /* UIColor+OWS.h */, 34480B5E1FD0A98800BC14EF /* UIColor+OWS.m */, 45BB93371E688E14001E3939 /* UIDevice+featureSupport.swift */, @@ -1688,6 +1690,17 @@ path = Views; sourceTree = ""; }; + 3469419C215D2EE400B5BFAD /* appearance */ = { + isa = PBXGroup; + children = ( + 346941A0215D2EE400B5BFAD /* OWSConversationColor.h */, + 3469419E215D2EE400B5BFAD /* OWSConversationColor.m */, + 3469419D215D2EE400B5BFAD /* Theme.h */, + 3469419F215D2EE400B5BFAD /* Theme.m */, + ); + path = appearance; + sourceTree = ""; + }; 34843B29214FE295004DED45 /* mocks */ = { isa = PBXGroup; children = ( @@ -1981,6 +1994,7 @@ 453518931FC63DBF00210559 /* SignalMessaging */ = { isa = PBXGroup; children = ( + 3469419C215D2EE400B5BFAD /* appearance */, 454A96571FD600B4008D2A0E /* attachments */, 34480B5C1FD0A98800BC14EF /* categories */, 346129A11FD1F09100532771 /* contacts */, @@ -2489,7 +2503,6 @@ 346129711FD1D74C00532771 /* SignalKeyingStorage.h in Headers */, 34AC0A20211B39EA00997B47 /* ThreadViewHelper.h in Headers */, 34AC09DE211B39B100997B47 /* OWSNavigationController.h in Headers */, - 34C82E5120F8E1F300E9688D /* Theme.h in Headers */, 34612A011FD5F31400532771 /* OWS104CreateRecipientIdentities.h in Headers */, 450998691FD8C10200D89EB3 /* AttachmentSharing.h in Headers */, 346129C71FD2072E00532771 /* NSString+OWS.h in Headers */, @@ -2507,11 +2520,13 @@ 34AC09F1211B39B100997B47 /* LockInteractionController.h in Headers */, 346129B41FD1F7E800532771 /* OWSProfileManager.h in Headers */, 342950892124CB0A0000B063 /* OWSSearchBar.h in Headers */, + 346941A1215D2EE400B5BFAD /* Theme.h in Headers */, 346129FA1FD5F31400532771 /* OWS100RemoveTSRecipientsMigration.h in Headers */, 346129E21FD5C0BE00532771 /* VersionMigrations.h in Headers */, 34AC09E8211B39B100997B47 /* NewNonContactConversationViewController.h in Headers */, 34480B611FD0A98800BC14EF /* UIColor+OWS.h in Headers */, 453518961FC63DBF00210559 /* SignalMessaging.h in Headers */, + 346941A4215D2EE400B5BFAD /* OWSConversationColor.h in Headers */, 3461295A1FD1D74C00532771 /* Environment.h in Headers */, 450C801020AD1AE400F3A091 /* OWSWindowManager.h in Headers */, 34D58730208E2C4200D2255A /* OWS109OutgoingMessageState.h in Headers */, @@ -3132,6 +3147,7 @@ 45194F951FD7216600333B2C /* TSUnreadIndicatorInteraction.m in Sources */, 34AC09E1211B39B100997B47 /* SelectThreadViewController.m in Sources */, 34AC09EF211B39B100997B47 /* ViewControllerUtils.m in Sources */, + 346941A2215D2EE400B5BFAD /* OWSConversationColor.m in Sources */, 34AC0A17211B39EA00997B47 /* VideoPlayerView.swift in Sources */, 34AC09EE211B39B100997B47 /* EditContactShareNameViewController.swift in Sources */, 346129F71FD5F31400532771 /* OWS105AttachmentFilePaths.m in Sources */, @@ -3194,11 +3210,11 @@ 450C800F20AD1AB900F3A091 /* OWSWindowManager.m in Sources */, 454A965A1FD6017E008D2A0E /* SignalAttachment.swift in Sources */, 45BC829D1FD9C4B400011CF3 /* ShareViewDelegate.swift in Sources */, - 34C82E5220F8E1F300E9688D /* Theme.m in Sources */, 3461295B1FD1D74C00532771 /* Environment.m in Sources */, 346129D51FD20ADC00532771 /* UIViewController+OWS.m in Sources */, 346129C91FD2072E00532771 /* NSString+OWS.m in Sources */, 347850691FD9B78A007B8332 /* AppSetup.m in Sources */, + 346941A3215D2EE400B5BFAD /* Theme.m in Sources */, 34AC0A14211B39EA00997B47 /* ContactCellView.m in Sources */, 34AC0A15211B39EA00997B47 /* ContactsViewHelper.m in Sources */, 346129FF1FD5F31400532771 /* OWS103EnableVideoCalling.m in Sources */, diff --git a/Signal/src/ViewControllers/ColorPickerViewController.swift b/Signal/src/ViewControllers/ColorPickerViewController.swift index 6f06784a0..79340f3f4 100644 --- a/Signal/src/ViewControllers/ColorPickerViewController.swift +++ b/Signal/src/ViewControllers/ColorPickerViewController.swift @@ -54,7 +54,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke required init(thread: TSThread) { self.thread = thread self.pickerView = UIPickerView() - self.colorNames = UIColor.ows_conversationColorNames + self.colorNames = OWSConversationColor.conversationColorNames super.init(nibName: nil, bundle: nil) @@ -110,9 +110,9 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke owsFailDebug("color was unexpectedly nil") return ColorView(color: .white) } - guard let colors = UIColor.ows_conversationColor(colorName: colorName) else { + guard let colors = OWSConversationColor.conversationColor(colorName: colorName) else { owsFailDebug("unknown color name") - return ColorView(color: UIColor.ows_defaultConversationColor().themeColor) + return ColorView(color: OWSConversationColor.default().themeColor) } return ColorView(color: colors.themeColor) } @@ -123,7 +123,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke let index = pickerView.selectedRow(inComponent: 0) guard let colorName = colorNames[safe: index] else { owsFailDebug("index was unexpectedly nil") - return UIColor.ows_defaultConversationColorName() + return OWSConversationColor.defaultConversationColorName() } return colorName } diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 9377b8960..97bbf69cf 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -289,7 +289,7 @@ const CGFloat kIconViewLength = 24; itemWithCustomCellBlock:^{ NSString *colorName = self.thread.conversationColorName; UIColor *currentColor = - [UIColor ows_conversationColorOrDefaultForColorName:colorName].themeColor; + [OWSConversationColor conversationColorOrDefaultForColorName:colorName].themeColor; NSString *title = NSLocalizedString(@"CONVERSATION_SETTINGS_CONVERSATION_COLOR", @"Label for table cell which leads to picking a new conversation color"); return [weakSelf disclosureCellWithName:title iconColor:currentColor]; diff --git a/SignalMessaging/SignalMessaging.h b/SignalMessaging/SignalMessaging.h index 4d722d4e0..119718eb5 100644 --- a/SignalMessaging/SignalMessaging.h +++ b/SignalMessaging/SignalMessaging.h @@ -29,6 +29,7 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[]; #import #import #import +#import #import #import #import diff --git a/SignalMessaging/appearance/OWSConversationColor.h b/SignalMessaging/appearance/OWSConversationColor.h new file mode 100644 index 000000000..66f0cf9bd --- /dev/null +++ b/SignalMessaging/appearance/OWSConversationColor.h @@ -0,0 +1,83 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface OWSConversationColor : NSObject + +@property (nonatomic, readonly) UIColor *primaryColor; +@property (nonatomic, readonly) UIColor *shadeColor; +@property (nonatomic, readonly) UIColor *tintColor; + +@property (nonatomic, readonly) UIColor *themeColor; + ++ (OWSConversationColor *)conversationColorWithPrimaryColor:(UIColor *)primaryColor + shadeColor:(UIColor *)shadeColor + tintColor:(UIColor *)tintColor; + +#pragma mark - Conversation Colors + +@property (class, readonly, nonatomic) UIColor *ows_crimsonColor; +@property (class, readonly, nonatomic) UIColor *ows_vermilionColor; +@property (class, readonly, nonatomic) UIColor *ows_burlapColor; +@property (class, readonly, nonatomic) UIColor *ows_forestColor; +@property (class, readonly, nonatomic) UIColor *ows_wintergreenColor; +@property (class, readonly, nonatomic) UIColor *ows_tealColor; +@property (class, readonly, nonatomic) UIColor *ows_blueColor; +@property (class, readonly, nonatomic) UIColor *ows_indigoColor; +@property (class, readonly, nonatomic) UIColor *ows_violetColor; +@property (class, readonly, nonatomic) UIColor *ows_plumColor; +@property (class, readonly, nonatomic) UIColor *ows_taupeColor; +@property (class, readonly, nonatomic) UIColor *ows_steelColor; + +#pragma mark - Conversation Colors (Tint) + +@property (class, readonly, nonatomic) UIColor *ows_crimsonTintColor; +@property (class, readonly, nonatomic) UIColor *ows_vermilionTintColor; +@property (class, readonly, nonatomic) UIColor *ows_burlapTintColor; +@property (class, readonly, nonatomic) UIColor *ows_forestTintColor; +@property (class, readonly, nonatomic) UIColor *ows_wintergreenTintColor; +@property (class, readonly, nonatomic) UIColor *ows_tealTintColor; +@property (class, readonly, nonatomic) UIColor *ows_blueTintColor; +@property (class, readonly, nonatomic) UIColor *ows_indigoTintColor; +@property (class, readonly, nonatomic) UIColor *ows_violetTintColor; +@property (class, readonly, nonatomic) UIColor *ows_plumTintColor; +@property (class, readonly, nonatomic) UIColor *ows_taupeTintColor; +@property (class, readonly, nonatomic) UIColor *ows_steelTintColor; + +#pragma mark - Conversation Colors (Shade) + +@property (class, readonly, nonatomic) UIColor *ows_crimsonShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_vermilionShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_burlapShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_forestShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_wintergreenShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_tealShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_blueShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_indigoShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_violetShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_plumShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_taupeShadeColor; +@property (class, readonly, nonatomic) UIColor *ows_steelShadeColor; + +#pragma mark - Conversation Colors + ++ (nullable OWSConversationColor *)conversationColorForColorName:(NSString *)colorName + NS_SWIFT_NAME(conversationColor(colorName:)); + +// If the conversation color name is valid, return its colors. +// Otherwise return the "default" conversation colors. ++ (OWSConversationColor *)conversationColorOrDefaultForColorName:(NSString *)conversationColorName + NS_SWIFT_NAME(conversationColorOrDefault(colorName:)); + +@property (class, readonly, nonatomic) NSArray *conversationColorNames; + ++ (NSString *)defaultConversationColorName; ++ (OWSConversationColor *)defaultConversationColor; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/appearance/OWSConversationColor.m b/SignalMessaging/appearance/OWSConversationColor.m new file mode 100644 index 000000000..d5692fcbc --- /dev/null +++ b/SignalMessaging/appearance/OWSConversationColor.m @@ -0,0 +1,380 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import "OWSConversationColor.h" +#import "Theme.h" +#import "UIColor+OWS.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface OWSConversationColor () + +@property (nonatomic) UIColor *primaryColor; +@property (nonatomic) UIColor *shadeColor; +@property (nonatomic) UIColor *tintColor; + +@end + +#pragma mark - + +@implementation OWSConversationColor + ++ (OWSConversationColor *)conversationColorWithPrimaryColor:(UIColor *)primaryColor + shadeColor:(UIColor *)shadeColor + tintColor:(UIColor *)tintColor +{ + OWSConversationColor *instance = [OWSConversationColor new]; + instance.primaryColor = primaryColor; + instance.shadeColor = shadeColor; + instance.tintColor = tintColor; + return instance; +} + +- (UIColor *)themeColor +{ + return Theme.isDarkThemeEnabled ? self.shadeColor : self.primaryColor; +} + +#pragma mark - Conversation Colors + ++ (UIColor *)ows_crimsonColor +{ + return [UIColor colorWithRGBHex:0xCC163D]; +} + ++ (UIColor *)ows_vermilionColor +{ + return [UIColor colorWithRGBHex:0xC73800]; +} + ++ (UIColor *)ows_burlapColor +{ + return [UIColor colorWithRGBHex:0x746C53]; +} + ++ (UIColor *)ows_forestColor +{ + return [UIColor colorWithRGBHex:0x3B7845]; +} + ++ (UIColor *)ows_wintergreenColor +{ + return [UIColor colorWithRGBHex:0x1C8260]; +} + ++ (UIColor *)ows_tealColor +{ + return [UIColor colorWithRGBHex:0x067589]; +} + ++ (UIColor *)ows_blueColor +{ + return [UIColor colorWithRGBHex:0x336BA3]; +} + ++ (UIColor *)ows_indigoColor +{ + return [UIColor colorWithRGBHex:0x5951C8]; +} + ++ (UIColor *)ows_violetColor +{ + return [UIColor colorWithRGBHex:0x862CAF]; +} + ++ (UIColor *)ows_plumColor +{ + return [UIColor colorWithRGBHex:0xA23474]; +} + ++ (UIColor *)ows_taupeColor +{ + return [UIColor colorWithRGBHex:0x895D66]; +} + ++ (UIColor *)ows_steelColor +{ + return [UIColor colorWithRGBHex:0x6B6B78]; +} + +#pragma mark - Conversation Colors (Tint) + ++ (UIColor *)ows_crimsonTintColor +{ + return [UIColor colorWithRGBHex:0xEDA6AE]; +} + ++ (UIColor *)ows_vermilionTintColor +{ + return [UIColor colorWithRGBHex:0xEBA78E]; +} + ++ (UIColor *)ows_burlapTintColor +{ + return [UIColor colorWithRGBHex:0xC4B997]; +} + ++ (UIColor *)ows_forestTintColor +{ + return [UIColor colorWithRGBHex:0x8FCC9A]; +} + ++ (UIColor *)ows_wintergreenTintColor +{ + return [UIColor colorWithRGBHex:0x9BCFBD]; +} + ++ (UIColor *)ows_tealTintColor +{ + return [UIColor colorWithRGBHex:0xA5CAD5]; +} + ++ (UIColor *)ows_blueTintColor +{ + return [UIColor colorWithRGBHex:0xADC8E1]; +} + ++ (UIColor *)ows_indigoTintColor +{ + return [UIColor colorWithRGBHex:0xC2C1E7]; +} + ++ (UIColor *)ows_violetTintColor +{ + return [UIColor colorWithRGBHex:0xCDADDC]; +} + ++ (UIColor *)ows_plumTintColor +{ + return [UIColor colorWithRGBHex:0xDCB2CA]; +} + ++ (UIColor *)ows_taupeTintColor +{ + return [UIColor colorWithRGBHex:0xCFB5BB]; +} + ++ (UIColor *)ows_steelTintColor +{ + return [UIColor colorWithRGBHex:0xBEBEC6]; +} + +#pragma mark - Conversation Colors (Shade) + ++ (UIColor *)ows_crimsonShadeColor +{ + return [UIColor colorWithRGBHex:0x8A0F29]; +} + ++ (UIColor *)ows_vermilionShadeColor +{ + return [UIColor colorWithRGBHex:0x872600]; +} + ++ (UIColor *)ows_burlapShadeColor +{ + return [UIColor colorWithRGBHex:0x58513C]; +} + ++ (UIColor *)ows_forestShadeColor +{ + return [UIColor colorWithRGBHex:0x2B5934]; +} + ++ (UIColor *)ows_wintergreenShadeColor +{ + return [UIColor colorWithRGBHex:0x36544A]; +} + ++ (UIColor *)ows_tealShadeColor +{ + return [UIColor colorWithRGBHex:0x055968]; +} + ++ (UIColor *)ows_blueShadeColor +{ + return [UIColor colorWithRGBHex:0x285480]; +} + ++ (UIColor *)ows_indigoShadeColor +{ + return [UIColor colorWithRGBHex:0x4840A0]; +} + ++ (UIColor *)ows_violetShadeColor +{ + return [UIColor colorWithRGBHex:0x6B248A]; +} + ++ (UIColor *)ows_plumShadeColor +{ + return [UIColor colorWithRGBHex:0x881B5B]; +} + ++ (UIColor *)ows_taupeShadeColor +{ + return [UIColor colorWithRGBHex:0x6A4E54]; +} + ++ (UIColor *)ows_steelShadeColor +{ + return [UIColor colorWithRGBHex:0x5A5A63]; +} + ++ (NSDictionary *)conversationColorMap +{ + static NSDictionary *colorMap; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + colorMap = @{ + @"crimson" : self.ows_crimsonColor, + @"vermilion" : self.ows_vermilionColor, + @"burlap" : self.ows_burlapColor, + @"forest" : self.ows_forestColor, + @"wintergreen" : self.ows_wintergreenColor, + @"teal" : self.ows_tealColor, + @"blue" : self.ows_blueColor, + @"indigo" : self.ows_indigoColor, + @"violet" : self.ows_violetColor, + @"plum" : self.ows_plumColor, + @"taupe" : self.ows_taupeColor, + @"steel" : self.ows_steelColor, + }; + }); + + return colorMap; +} + ++ (NSDictionary *)conversationColorMapShade +{ + static NSDictionary *colorMap; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + colorMap = @{ + @"crimson" : self.ows_crimsonShadeColor, + @"vermilion" : self.ows_vermilionShadeColor, + @"burlap" : self.ows_burlapShadeColor, + @"forest" : self.ows_forestShadeColor, + @"wintergreen" : self.ows_wintergreenShadeColor, + @"teal" : self.ows_tealShadeColor, + @"blue" : self.ows_blueShadeColor, + @"indigo" : self.ows_indigoShadeColor, + @"violet" : self.ows_violetShadeColor, + @"plum" : self.ows_plumShadeColor, + @"taupe" : self.ows_taupeShadeColor, + @"steel" : self.ows_steelShadeColor, + }; + OWSAssertDebug([self.conversationColorMap.allKeys isEqualToArray:colorMap.allKeys]); + }); + + return colorMap; +} + ++ (NSDictionary *)conversationColorMapTint +{ + static NSDictionary *colorMap; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + colorMap = @{ + @"crimson" : self.ows_crimsonTintColor, + @"vermilion" : self.ows_vermilionTintColor, + @"burlap" : self.ows_burlapTintColor, + @"forest" : self.ows_forestTintColor, + @"wintergreen" : self.ows_wintergreenTintColor, + @"teal" : self.ows_tealTintColor, + @"blue" : self.ows_blueTintColor, + @"indigo" : self.ows_indigoTintColor, + @"violet" : self.ows_violetTintColor, + @"plum" : self.ows_plumTintColor, + @"taupe" : self.ows_taupeTintColor, + @"steel" : self.ows_steelTintColor, + }; + OWSAssertDebug([self.conversationColorMap.allKeys isEqualToArray:colorMap.allKeys]); + }); + + return colorMap; +} + ++ (NSDictionary *)ows_legacyConversationColorMap +{ + static NSDictionary *colorMap; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + colorMap = @{ + @"red" : @"crimson", + @"deep_orange" : @"crimson", + @"orange" : @"vermilion", + @"amber" : @"vermilion", + @"brown" : @"burlap", + @"yellow" : @"burlap", + @"pink" : @"plum", + @"purple" : @"violet", + @"deep_purple" : @"violet", + @"indigo" : @"indigo", + @"blue" : @"blue", + @"light_blue" : @"blue", + @"cyan" : @"teal", + @"teal" : @"teal", + @"green" : @"forest", + @"light_green" : @"wintergreen", + @"lime" : @"wintergreen", + @"blue_grey" : @"taupe", + @"grey" : @"steel", + }; + }); + + return colorMap; +} + ++ (NSArray *)conversationColorNames +{ + return self.conversationColorMap.allKeys; +} + ++ (nullable OWSConversationColor *)conversationColorForColorName:(NSString *)conversationColorName +{ + NSString *_Nullable mappedColorName = self.ows_legacyConversationColorMap[conversationColorName.lowercaseString]; + if (mappedColorName) { + conversationColorName = mappedColorName; + } else { + OWSAssertDebug(self.conversationColorMap[conversationColorName] != nil); + } + + UIColor *_Nullable primaryColor = self.conversationColorMap[conversationColorName]; + UIColor *_Nullable shadeColor = self.conversationColorMapShade[conversationColorName]; + UIColor *_Nullable tintColor = self.conversationColorMapTint[conversationColorName]; + if (!primaryColor || !shadeColor || !tintColor) { + return nil; + } + OWSAssertDebug(primaryColor); + OWSAssertDebug(shadeColor); + OWSAssertDebug(tintColor); + return + [OWSConversationColor conversationColorWithPrimaryColor:primaryColor shadeColor:shadeColor tintColor:tintColor]; +} + ++ (OWSConversationColor *)conversationColorOrDefaultForColorName:(NSString *)conversationColorName +{ + OWSConversationColor *_Nullable conversationColor = [self conversationColorForColorName:conversationColorName]; + if (conversationColor) { + return conversationColor; + } + return [self defaultConversationColor]; +} + ++ (NSString *)defaultConversationColorName +{ + NSString *conversationColorName = @"steel"; + OWSAssert([self.conversationColorNames containsObject:conversationColorName]); + return conversationColorName; +} + ++ (OWSConversationColor *)defaultConversationColor +{ + return [self conversationColorForColorName:self.defaultConversationColorName]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/categories/Theme.h b/SignalMessaging/appearance/Theme.h similarity index 100% rename from SignalMessaging/categories/Theme.h rename to SignalMessaging/appearance/Theme.h diff --git a/SignalMessaging/categories/Theme.m b/SignalMessaging/appearance/Theme.m similarity index 100% rename from SignalMessaging/categories/Theme.m rename to SignalMessaging/appearance/Theme.m diff --git a/SignalMessaging/categories/UIColor+OWS.h b/SignalMessaging/categories/UIColor+OWS.h index b058d8f6c..febd1fd80 100644 --- a/SignalMessaging/categories/UIColor+OWS.h +++ b/SignalMessaging/categories/UIColor+OWS.h @@ -6,22 +6,6 @@ NS_ASSUME_NONNULL_BEGIN -@interface OWSConversationColor : NSObject - -@property (nonatomic, readonly) UIColor *primaryColor; -@property (nonatomic, readonly) UIColor *shadeColor; -@property (nonatomic, readonly) UIColor *tintColor; - -@property (nonatomic, readonly) UIColor *themeColor; - -+ (OWSConversationColor *)conversationColorWithPrimaryColor:(UIColor *)primaryColor - shadeColor:(UIColor *)shadeColor - tintColor:(UIColor *)tintColor; - -@end - -#pragma mark - - @interface UIColor (OWS) #pragma mark - @@ -64,66 +48,6 @@ NS_ASSUME_NONNULL_BEGIN @property (class, readonly, nonatomic) UIColor *ows_gray95Color; @property (class, readonly, nonatomic) UIColor *ows_blackColor; -#pragma mark - Conversation Colors - -@property (class, readonly, nonatomic) UIColor *ows_crimsonColor; -@property (class, readonly, nonatomic) UIColor *ows_vermilionColor; -@property (class, readonly, nonatomic) UIColor *ows_burlapColor; -@property (class, readonly, nonatomic) UIColor *ows_forestColor; -@property (class, readonly, nonatomic) UIColor *ows_wintergreenColor; -@property (class, readonly, nonatomic) UIColor *ows_tealColor; -@property (class, readonly, nonatomic) UIColor *ows_blueColor; -@property (class, readonly, nonatomic) UIColor *ows_indigoColor; -@property (class, readonly, nonatomic) UIColor *ows_violetColor; -@property (class, readonly, nonatomic) UIColor *ows_plumColor; -@property (class, readonly, nonatomic) UIColor *ows_taupeColor; -@property (class, readonly, nonatomic) UIColor *ows_steelColor; - -#pragma mark - Conversation Colors (Tint) - -@property (class, readonly, nonatomic) UIColor *ows_crimsonTintColor; -@property (class, readonly, nonatomic) UIColor *ows_vermilionTintColor; -@property (class, readonly, nonatomic) UIColor *ows_burlapTintColor; -@property (class, readonly, nonatomic) UIColor *ows_forestTintColor; -@property (class, readonly, nonatomic) UIColor *ows_wintergreenTintColor; -@property (class, readonly, nonatomic) UIColor *ows_tealTintColor; -@property (class, readonly, nonatomic) UIColor *ows_blueTintColor; -@property (class, readonly, nonatomic) UIColor *ows_indigoTintColor; -@property (class, readonly, nonatomic) UIColor *ows_violetTintColor; -@property (class, readonly, nonatomic) UIColor *ows_plumTintColor; -@property (class, readonly, nonatomic) UIColor *ows_taupeTintColor; -@property (class, readonly, nonatomic) UIColor *ows_steelTintColor; - -#pragma mark - Conversation Colors (Shade) - -@property (class, readonly, nonatomic) UIColor *ows_crimsonShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_vermilionShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_burlapShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_forestShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_wintergreenShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_tealShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_blueShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_indigoShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_violetShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_plumShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_taupeShadeColor; -@property (class, readonly, nonatomic) UIColor *ows_steelShadeColor; - -#pragma mark - Conversation Colors - -+ (nullable OWSConversationColor *)ows_conversationColorForColorName:(NSString *)colorName - NS_SWIFT_NAME(ows_conversationColor(colorName:)); - -// If the conversation color name is valid, return its colors. -// Otherwise return the "default" conversation colors. -+ (OWSConversationColor *)ows_conversationColorOrDefaultForColorName:(NSString *)conversationColorName - NS_SWIFT_NAME(ows_conversationColorOrDefault(colorName:)); - -@property (class, readonly, nonatomic) NSArray *ows_conversationColorNames; - -+ (NSString *)ows_defaultConversationColorName; -+ (OWSConversationColor *)ows_defaultConversationColor; - // TODO: Remove @property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor; diff --git a/SignalMessaging/categories/UIColor+OWS.m b/SignalMessaging/categories/UIColor+OWS.m index 5d5557cee..4508ae0dd 100644 --- a/SignalMessaging/categories/UIColor+OWS.m +++ b/SignalMessaging/categories/UIColor+OWS.m @@ -9,39 +9,6 @@ NS_ASSUME_NONNULL_BEGIN - -@interface OWSConversationColor () - -@property (nonatomic) UIColor *primaryColor; -@property (nonatomic) UIColor *shadeColor; -@property (nonatomic) UIColor *tintColor; - -@end - -#pragma mark - - -@implementation OWSConversationColor - -+ (OWSConversationColor *)conversationColorWithPrimaryColor:(UIColor *)primaryColor - shadeColor:(UIColor *)shadeColor - tintColor:(UIColor *)tintColor -{ - OWSConversationColor *instance = [OWSConversationColor new]; - instance.primaryColor = primaryColor; - instance.shadeColor = shadeColor; - instance.tintColor = tintColor; - return instance; -} - -- (UIColor *)themeColor -{ - return Theme.isDarkThemeEnabled ? self.shadeColor : self.primaryColor; -} - -@end - -#pragma mark - - @implementation UIColor (OWS) #pragma mark - @@ -228,345 +195,6 @@ NS_ASSUME_NONNULL_BEGIN return [UIColor colorWithRGBHex:0x000000]; } -#pragma mark - Conversation Colors - -+ (UIColor *)ows_crimsonColor -{ - return [UIColor colorWithRGBHex:0xCC163D]; -} - -+ (UIColor *)ows_vermilionColor -{ - return [UIColor colorWithRGBHex:0xC73800]; -} - -+ (UIColor *)ows_burlapColor -{ - return [UIColor colorWithRGBHex:0x746C53]; -} - -+ (UIColor *)ows_forestColor -{ - return [UIColor colorWithRGBHex:0x3B7845]; -} - -+ (UIColor *)ows_wintergreenColor -{ - return [UIColor colorWithRGBHex:0x1C8260]; -} - -+ (UIColor *)ows_tealColor -{ - return [UIColor colorWithRGBHex:0x067589]; -} - -+ (UIColor *)ows_blueColor -{ - return [UIColor colorWithRGBHex:0x336BA3]; -} - -+ (UIColor *)ows_indigoColor -{ - return [UIColor colorWithRGBHex:0x5951C8]; -} - -+ (UIColor *)ows_violetColor -{ - return [UIColor colorWithRGBHex:0x862CAF]; -} - -+ (UIColor *)ows_plumColor -{ - return [UIColor colorWithRGBHex:0xA23474]; -} - -+ (UIColor *)ows_taupeColor -{ - return [UIColor colorWithRGBHex:0x895D66]; -} - -+ (UIColor *)ows_steelColor -{ - return [UIColor colorWithRGBHex:0x6B6B78]; -} - -#pragma mark - Conversation Colors (Tint) - -+ (UIColor *)ows_crimsonTintColor -{ - return [UIColor colorWithRGBHex:0xEDA6AE]; -} - -+ (UIColor *)ows_vermilionTintColor -{ - return [UIColor colorWithRGBHex:0xEBA78E]; -} - -+ (UIColor *)ows_burlapTintColor -{ - return [UIColor colorWithRGBHex:0xC4B997]; -} - -+ (UIColor *)ows_forestTintColor -{ - return [UIColor colorWithRGBHex:0x8FCC9A]; -} - -+ (UIColor *)ows_wintergreenTintColor -{ - return [UIColor colorWithRGBHex:0x9BCFBD]; -} - -+ (UIColor *)ows_tealTintColor -{ - return [UIColor colorWithRGBHex:0xA5CAD5]; -} - -+ (UIColor *)ows_blueTintColor -{ - return [UIColor colorWithRGBHex:0xADC8E1]; -} - -+ (UIColor *)ows_indigoTintColor -{ - return [UIColor colorWithRGBHex:0xC2C1E7]; -} - -+ (UIColor *)ows_violetTintColor -{ - return [UIColor colorWithRGBHex:0xCDADDC]; -} - -+ (UIColor *)ows_plumTintColor -{ - return [UIColor colorWithRGBHex:0xDCB2CA]; -} - -+ (UIColor *)ows_taupeTintColor -{ - return [UIColor colorWithRGBHex:0xCFB5BB]; -} - -+ (UIColor *)ows_steelTintColor -{ - return [UIColor colorWithRGBHex:0xBEBEC6]; -} - -#pragma mark - Conversation Colors (Shade) - -+ (UIColor *)ows_crimsonShadeColor -{ - return [UIColor colorWithRGBHex:0x8A0F29]; -} - -+ (UIColor *)ows_vermilionShadeColor -{ - return [UIColor colorWithRGBHex:0x872600]; -} - -+ (UIColor *)ows_burlapShadeColor -{ - return [UIColor colorWithRGBHex:0x58513C]; -} - -+ (UIColor *)ows_forestShadeColor -{ - return [UIColor colorWithRGBHex:0x2B5934]; -} - -+ (UIColor *)ows_wintergreenShadeColor -{ - return [UIColor colorWithRGBHex:0x36544A]; -} - -+ (UIColor *)ows_tealShadeColor -{ - return [UIColor colorWithRGBHex:0x055968]; -} - -+ (UIColor *)ows_blueShadeColor -{ - return [UIColor colorWithRGBHex:0x285480]; -} - -+ (UIColor *)ows_indigoShadeColor -{ - return [UIColor colorWithRGBHex:0x4840A0]; -} - -+ (UIColor *)ows_violetShadeColor -{ - return [UIColor colorWithRGBHex:0x6B248A]; -} - -+ (UIColor *)ows_plumShadeColor -{ - return [UIColor colorWithRGBHex:0x881B5B]; -} - -+ (UIColor *)ows_taupeShadeColor -{ - return [UIColor colorWithRGBHex:0x6A4E54]; -} - -+ (UIColor *)ows_steelShadeColor -{ - return [UIColor colorWithRGBHex:0x5A5A63]; -} - -+ (NSDictionary *)ows_conversationColorMap -{ - static NSDictionary *colorMap; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - colorMap = @{ - @"crimson" : self.ows_crimsonColor, - @"vermilion" : self.ows_vermilionColor, - @"burlap" : self.ows_burlapColor, - @"forest" : self.ows_forestColor, - @"wintergreen" : self.ows_wintergreenColor, - @"teal" : self.ows_tealColor, - @"blue" : self.ows_blueColor, - @"indigo" : self.ows_indigoColor, - @"violet" : self.ows_violetColor, - @"plum" : self.ows_plumColor, - @"taupe" : self.ows_taupeColor, - @"steel" : self.ows_steelColor, - }; - }); - - return colorMap; -} - -+ (NSDictionary *)ows_conversationColorMapShade -{ - static NSDictionary *colorMap; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - colorMap = @{ - @"crimson" : self.ows_crimsonShadeColor, - @"vermilion" : self.ows_vermilionShadeColor, - @"burlap" : self.ows_burlapShadeColor, - @"forest" : self.ows_forestShadeColor, - @"wintergreen" : self.ows_wintergreenShadeColor, - @"teal" : self.ows_tealShadeColor, - @"blue" : self.ows_blueShadeColor, - @"indigo" : self.ows_indigoShadeColor, - @"violet" : self.ows_violetShadeColor, - @"plum" : self.ows_plumShadeColor, - @"taupe" : self.ows_taupeShadeColor, - @"steel" : self.ows_steelShadeColor, - }; - OWSAssertDebug([self.ows_conversationColorMap.allKeys isEqualToArray:colorMap.allKeys]); - }); - - return colorMap; -} - -+ (NSDictionary *)ows_conversationColorMapTint -{ - static NSDictionary *colorMap; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - colorMap = @{ - @"crimson" : self.ows_crimsonTintColor, - @"vermilion" : self.ows_vermilionTintColor, - @"burlap" : self.ows_burlapTintColor, - @"forest" : self.ows_forestTintColor, - @"wintergreen" : self.ows_wintergreenTintColor, - @"teal" : self.ows_tealTintColor, - @"blue" : self.ows_blueTintColor, - @"indigo" : self.ows_indigoTintColor, - @"violet" : self.ows_violetTintColor, - @"plum" : self.ows_plumTintColor, - @"taupe" : self.ows_taupeTintColor, - @"steel" : self.ows_steelTintColor, - }; - OWSAssertDebug([self.ows_conversationColorMap.allKeys isEqualToArray:colorMap.allKeys]); - }); - - return colorMap; -} - -+ (NSDictionary *)ows_legacyConversationColorMap -{ - static NSDictionary *colorMap; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - colorMap = @{ - @"red" : @"crimson", - @"deep_orange" : @"crimson", - @"orange" : @"vermilion", - @"amber" : @"vermilion", - @"brown" : @"burlap", - @"yellow" : @"burlap", - @"pink" : @"plum", - @"purple" : @"violet", - @"deep_purple" : @"violet", - @"indigo" : @"indigo", - @"blue" : @"blue", - @"light_blue" : @"blue", - @"cyan" : @"teal", - @"teal" : @"teal", - @"green" : @"forest", - @"light_green" : @"wintergreen", - @"lime" : @"wintergreen", - @"blue_grey" : @"taupe", - @"grey" : @"steel", - }; - }); - - return colorMap; -} - -+ (NSArray *)ows_conversationColorNames -{ - return self.ows_conversationColorMap.allKeys; -} - -+ (nullable OWSConversationColor *)ows_conversationColorForColorName:(NSString *)conversationColorName -{ - NSString *_Nullable mappedColorName = self.ows_legacyConversationColorMap[conversationColorName.lowercaseString]; - if (mappedColorName) { - conversationColorName = mappedColorName; - } else { - OWSAssertDebug(self.ows_conversationColorMap[conversationColorName] != nil); - } - - UIColor *_Nullable primaryColor = self.ows_conversationColorMap[conversationColorName]; - UIColor *_Nullable shadeColor = self.ows_conversationColorMapShade[conversationColorName]; - UIColor *_Nullable tintColor = self.ows_conversationColorMapTint[conversationColorName]; - if (!primaryColor || !shadeColor || !tintColor) { - return nil; - } - OWSAssertDebug(primaryColor); - OWSAssertDebug(shadeColor); - OWSAssertDebug(tintColor); - return - [OWSConversationColor conversationColorWithPrimaryColor:primaryColor shadeColor:shadeColor tintColor:tintColor]; -} - -+ (OWSConversationColor *)ows_conversationColorOrDefaultForColorName:(NSString *)conversationColorName -{ - OWSConversationColor *_Nullable conversationColor = [self ows_conversationColorForColorName:conversationColorName]; - if (conversationColor) { - return conversationColor; - } - return [self ows_defaultConversationColor]; -} - -+ (NSString *)ows_defaultConversationColorName -{ - NSString *conversationColorName = @"steel"; - OWSAssert([self.ows_conversationColorNames containsObject:conversationColorName]); - return conversationColorName; -} - -+ (OWSConversationColor *)ows_defaultConversationColor -{ - return [self ows_conversationColorForColorName:self.ows_defaultConversationColorName]; -} - // TODO: Remove + (UIColor *)ows_darkSkyBlueColor { diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index 5884b2f07..33ebef973 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -137,7 +137,7 @@ public class ConversationStyle: NSObject { private class func conversationColor(thread: TSThread) -> OWSConversationColor { let colorName = thread.conversationColorName - return UIColor.ows_conversationColorOrDefault(colorName: colorName) + return OWSConversationColor.conversationColorOrDefault(colorName: colorName) } @objc diff --git a/SignalMessaging/utils/OWSContactAvatarBuilder.m b/SignalMessaging/utils/OWSContactAvatarBuilder.m index 57230dc6a..8cb45b10b 100644 --- a/SignalMessaging/utils/OWSContactAvatarBuilder.m +++ b/SignalMessaging/utils/OWSContactAvatarBuilder.m @@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssertDebug(localNumber.length > 0); OWSAssertDebug(diameter > 0); - NSString *colorName = [UIColor ows_defaultConversationColorName]; + NSString *colorName = [OWSConversationColor defaultConversationColorName]; return [self initWithSignalId:localNumber colorName:colorName diameter:diameter]; } @@ -129,7 +129,7 @@ NS_ASSUME_NONNULL_BEGIN initials = [[initials substringWithRange:stringRange] mutableCopy]; } - UIColor *color = [UIColor ows_conversationColorOrDefaultForColorName:self.colorName].themeColor; + UIColor *color = [OWSConversationColor conversationColorOrDefaultForColorName:self.colorName].themeColor; OWSAssertDebug(color); UIImage *_Nullable image; diff --git a/SignalMessaging/utils/OWSGroupAvatarBuilder.m b/SignalMessaging/utils/OWSGroupAvatarBuilder.m index 2dd121135..5b74a62ff 100644 --- a/SignalMessaging/utils/OWSGroupAvatarBuilder.m +++ b/SignalMessaging/utils/OWSGroupAvatarBuilder.m @@ -66,7 +66,8 @@ NS_ASSUME_NONNULL_BEGIN return cachedAvatar; } - UIColor *backgroundColor = [UIColor ows_conversationColorOrDefaultForColorName:conversationColorName].themeColor; + UIColor *backgroundColor = + [OWSConversationColor conversationColorOrDefaultForColorName:conversationColorName].themeColor; UIImage *_Nullable image = [OWSGroupAvatarBuilder groupAvatarImageWithBackgroundColor:backgroundColor diameter:diameter]; if (!image) {