From e5150267c291f65f347c939c2151c1ecc7efb900 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 24 Sep 2018 16:38:58 -0400 Subject: [PATCH] Rework the conversation color constants. --- .../ColorPickerViewController.swift | 3 +- .../OWSConversationSettingsViewController.m | 4 +- SignalMessaging/categories/UIColor+OWS.h | 73 +++-- SignalMessaging/categories/UIColor+OWS.m | 268 ++++++++++++++---- SignalMessaging/utils/ConversationStyle.swift | 3 +- .../utils/OWSContactAvatarBuilder.m | 2 +- 6 files changed, 277 insertions(+), 76 deletions(-) diff --git a/Signal/src/ViewControllers/ColorPickerViewController.swift b/Signal/src/ViewControllers/ColorPickerViewController.swift index dcb6f99a0..b0d6738b9 100644 --- a/Signal/src/ViewControllers/ColorPickerViewController.swift +++ b/Signal/src/ViewControllers/ColorPickerViewController.swift @@ -110,8 +110,7 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke owsFailDebug("color was unexpectedly nil") return ColorView(color: .white) } - guard let color = UIColor.ows_conversationColor(colorName: colorName, - isShaded: Theme.isDarkThemeEnabled) else { + guard let color = UIColor.ows_conversationThemeColor(colorName: colorName) else { owsFailDebug("unknown color name") return ColorView(color: .white) } diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 2715b0dd0..2fb00ed2b 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -288,9 +288,7 @@ const CGFloat kIconViewLength = 24; [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ NSString *colorName = self.thread.conversationColorName; - UIColor *currentColor = - [UIColor ows_conversationColorForColorName:colorName - isShaded:Theme.isDarkThemeEnabled]; + UIColor *currentColor = [UIColor ows_conversationThemeColorForColorName:colorName]; 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/categories/UIColor+OWS.h b/SignalMessaging/categories/UIColor+OWS.h index e1bc79f09..7dc8b1480 100644 --- a/SignalMessaging/categories/UIColor+OWS.h +++ b/SignalMessaging/categories/UIColor+OWS.h @@ -28,14 +28,6 @@ NS_ASSUME_NONNULL_BEGIN + (UIColor *)colorWithRGBHex:(unsigned long)value; -#pragma mark - ConversationColor - -+ (nullable UIColor *)ows_conversationColorForColorName:(NSString *)colorName - isShaded:(BOOL)isShaded - NS_SWIFT_NAME(ows_conversationColor(colorName:isShaded:)); - -@property (class, readonly, nonatomic) NSArray *ows_conversationColorNames; - - (UIColor *)blendWithColor:(UIColor *)otherColor alpha:(CGFloat)alpha; #pragma mark - Color Palette @@ -59,20 +51,63 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Conversation Colors -@property (class, readonly, nonatomic) UIColor *ows_red700Color; -@property (class, readonly, nonatomic) UIColor *ows_pink600Color; -@property (class, readonly, nonatomic) UIColor *ows_purple600Color; -@property (class, readonly, nonatomic) UIColor *ows_indigo600Color; -@property (class, readonly, nonatomic) UIColor *ows_blue700Color; -@property (class, readonly, nonatomic) UIColor *ows_cyan800Color; -@property (class, readonly, nonatomic) UIColor *ows_teal700Color; -@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; +@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 UIColor *)ows_conversationThemeColorForColorName:(NSString *)colorName + NS_SWIFT_NAME(ows_conversationThemeColor(colorName:)); + +@property (class, readonly, nonatomic) NSArray *ows_conversationColorNames; + ++ (nullable UIColor *)ows_conversationTintColorForColorName:(NSString *)colorName; + (NSString *)ows_defaultConversationColorName; +// TODO: Remove +@property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor; + @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/categories/UIColor+OWS.m b/SignalMessaging/categories/UIColor+OWS.m index 4cd87ce14..d5ef009c3 100644 --- a/SignalMessaging/categories/UIColor+OWS.m +++ b/SignalMessaging/categories/UIColor+OWS.m @@ -196,100 +196,259 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Conversation Colors -+ (UIColor *)ows_red700Color ++ (UIColor *)ows_crimsonColor { - return [UIColor colorWithRGBHex:0xd32f2f]; + return [UIColor colorWithRGBHex:0xCC163D]; } -+ (UIColor *)ows_pink600Color ++ (UIColor *)ows_vermilionColor { - return [UIColor colorWithRGBHex:0xd81b60]; + return [UIColor colorWithRGBHex:0xC73800]; } -+ (UIColor *)ows_purple600Color ++ (UIColor *)ows_burlapColor { - return [UIColor colorWithRGBHex:0x8e24aa]; + return [UIColor colorWithRGBHex:0x746C53]; } -+ (UIColor *)ows_indigo600Color ++ (UIColor *)ows_forestColor { - return [UIColor colorWithRGBHex:0x3949ab]; + return [UIColor colorWithRGBHex:0x3B7845]; } -+ (UIColor *)ows_blue700Color ++ (UIColor *)ows_wintergreenColor { - return [UIColor colorWithRGBHex:0x1976d2]; + return [UIColor colorWithRGBHex:0x1C8260]; } -+ (UIColor *)ows_cyan800Color ++ (UIColor *)ows_tealColor { - return [UIColor colorWithRGBHex:0x00838f]; + return [UIColor colorWithRGBHex:0x067589]; } -+ (UIColor *)ows_teal700Color ++ (UIColor *)ows_blueColor { - return [UIColor colorWithRGBHex:0x00796b]; + return [UIColor colorWithRGBHex:0x336BA3]; } -+ (UIColor *)ows_green800Color ++ (UIColor *)ows_indigoColor { - return [UIColor colorWithRGBHex:0x2e7d32]; + return [UIColor colorWithRGBHex:0x5951C8]; } -+ (UIColor *)ows_deepOrange900Color ++ (UIColor *)ows_violetColor { - return [UIColor colorWithRGBHex:0xbf360c]; + return [UIColor colorWithRGBHex:0x862CAF]; } -+ (UIColor *)ows_grey600Color ++ (UIColor *)ows_plumColor { - return [UIColor colorWithRGBHex:0x757575]; + return [UIColor colorWithRGBHex:0xA23474]; } -+ (UIColor *)ows_darkSkyBlueColor ++ (UIColor *)ows_taupeColor { - return [UIColor colorWithRed:32.f / 255.f green:144.f / 255.f blue:234.f / 255.f alpha:1.f]; + 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]; } -+ (NSDictionary *)ows_conversationColorMapLight ++ (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 = @{ - @"red" : self.ows_red700Color, - @"pink" : self.ows_pink600Color, - @"purple" : self.ows_purple600Color, - @"indigo" : self.ows_indigo600Color, - @"blue" : self.ows_blue700Color, - @"cyan" : self.ows_cyan800Color, - @"teal" : self.ows_teal700Color, - @"green" : self.ows_green800Color, - @"deep_orange" : self.ows_deepOrange900Color, - @"grey" : self.ows_grey600Color + @"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_conversationColorMapDark ++ (NSDictionary *)ows_conversationColorMapTint { static NSDictionary *colorMap; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ colorMap = @{ - @"red" : self.ows_red700Color, - @"pink" : self.ows_pink600Color, - @"purple" : self.ows_purple600Color, - @"indigo" : self.ows_indigo600Color, - @"blue" : self.ows_blue700Color, - @"cyan" : self.ows_cyan800Color, - @"teal" : self.ows_teal700Color, - @"green" : self.ows_green800Color, - @"deep_orange" : self.ows_deepOrange900Color, - @"grey" : self.ows_grey600Color + @"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; @@ -297,17 +456,22 @@ NS_ASSUME_NONNULL_BEGIN + (NSArray *)ows_conversationColorNames { - OWSAssertDebug( - [self.ows_conversationColorMapLight.allKeys isEqualToArray:self.ows_conversationColorMapDark.allKeys]); + return self.ows_conversationColorMap.allKeys; +} + ++ (nullable UIColor *)ows_conversationThemeColorForColorName:(NSString *)colorName +{ + OWSAssertDebug(colorName.length > 0); - return self.ows_conversationColorMapLight.allKeys; + BOOL isShaded = Theme.isDarkThemeEnabled; + return (isShaded ? self.ows_conversationColorMapShade : self.ows_conversationColorMap)[colorName]; } -+ (nullable UIColor *)ows_conversationColorForColorName:(NSString *)colorName isShaded:(BOOL)isShaded ++ (nullable UIColor *)ows_conversationTintColorForColorName:(NSString *)colorName { OWSAssertDebug(colorName.length > 0); - return (isShaded ? self.ows_conversationColorMapDark : self.ows_conversationColorMapLight)[colorName]; + return self.ows_conversationColorMapTint[colorName]; } + (NSString *)ows_defaultConversationColorName @@ -315,6 +479,12 @@ NS_ASSUME_NONNULL_BEGIN return @"teal"; } +// TODO: Remove ++ (UIColor *)ows_darkSkyBlueColor +{ + return [UIColor colorWithRed:32.f / 255.f green:144.f / 255.f blue:234.f / 255.f alpha:1.f]; +} + @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index 0de990efa..b88c2feaa 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -136,8 +136,7 @@ public class ConversationStyle: NSObject { return self.defaultBubbleColorIncoming } - guard let color = UIColor.ows_conversationColor(colorName: colorName, - isShaded: Theme.isDarkThemeEnabled) else { + guard let color = UIColor.ows_conversationThemeColor(colorName: colorName) else { return self.defaultBubbleColorIncoming } diff --git a/SignalMessaging/utils/OWSContactAvatarBuilder.m b/SignalMessaging/utils/OWSContactAvatarBuilder.m index 357faf055..feb328dff 100644 --- a/SignalMessaging/utils/OWSContactAvatarBuilder.m +++ b/SignalMessaging/utils/OWSContactAvatarBuilder.m @@ -124,7 +124,7 @@ NS_ASSUME_NONNULL_BEGIN [initials appendString:@"#"]; } - UIColor *color = [UIColor ows_conversationColorForColorName:self.colorName isShaded:Theme.isDarkThemeEnabled]; + UIColor *color = [UIColor ows_conversationThemeColorForColorName:self.colorName]; OWSAssertDebug(color); UIImage *_Nullable image =