From 857cdf43687c4ad0be9d86bd1ad56085da434b51 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 27 Sep 2018 10:52:30 -0400 Subject: [PATCH] Map the legacy conversation color names. --- SignalMessaging/categories/UIColor+OWS.m | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/SignalMessaging/categories/UIColor+OWS.m b/SignalMessaging/categories/UIColor+OWS.m index 9944a12e0..5d5557cee 100644 --- a/SignalMessaging/categories/UIColor+OWS.m +++ b/SignalMessaging/categories/UIColor+OWS.m @@ -488,6 +488,37 @@ NS_ASSUME_NONNULL_BEGIN 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; @@ -495,6 +526,13 @@ NS_ASSUME_NONNULL_BEGIN + (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];