diff --git a/Signal/src/ViewControllers/ColorPickerViewController.swift b/Signal/src/ViewControllers/ColorPickerViewController.swift index b0d6738b9..6af04991a 100644 --- a/Signal/src/ViewControllers/ColorPickerViewController.swift +++ b/Signal/src/ViewControllers/ColorPickerViewController.swift @@ -110,7 +110,8 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke owsFailDebug("color was unexpectedly nil") return ColorView(color: .white) } - guard let color = UIColor.ows_conversationThemeColor(colorName: colorName) else { + guard let color = UIColor.ows_conversationColor(colorName: colorName, + mode: Theme.isDarkThemeEnabled ? .shade : .default) 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 2fb00ed2b..4e03947a7 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -288,7 +288,11 @@ const CGFloat kIconViewLength = 24; [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ NSString *colorName = self.thread.conversationColorName; - UIColor *currentColor = [UIColor ows_conversationThemeColorForColorName:colorName]; + UIColor *currentColor = [UIColor + ows_conversationColorForColorName:colorName + mode:(Theme.isDarkThemeEnabled + ? ConversationColorMode_Shade + : ConversationColorMode_Default)]; 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 7dc8b1480..78ec2fcaf 100644 --- a/SignalMessaging/categories/UIColor+OWS.h +++ b/SignalMessaging/categories/UIColor+OWS.h @@ -7,6 +7,12 @@ NS_ASSUME_NONNULL_BEGIN +typedef NS_ENUM(NSUInteger, ConversationColorMode) { + ConversationColorMode_Default, + ConversationColorMode_Shade, + ConversationColorMode_Tint, +}; + @interface UIColor (OWS) #pragma mark - @@ -96,8 +102,9 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Conversation Colors -+ (nullable UIColor *)ows_conversationThemeColorForColorName:(NSString *)colorName - NS_SWIFT_NAME(ows_conversationThemeColor(colorName:)); ++ (nullable UIColor *)ows_conversationColorForColorName:(NSString *)colorName + mode:(ConversationColorMode)mode + NS_SWIFT_NAME(ows_conversationColor(colorName:mode:)); @property (class, readonly, nonatomic) NSArray *ows_conversationColorNames; diff --git a/SignalMessaging/categories/UIColor+OWS.m b/SignalMessaging/categories/UIColor+OWS.m index d5ef009c3..9ff0a247a 100644 --- a/SignalMessaging/categories/UIColor+OWS.m +++ b/SignalMessaging/categories/UIColor+OWS.m @@ -459,12 +459,18 @@ NS_ASSUME_NONNULL_BEGIN return self.ows_conversationColorMap.allKeys; } -+ (nullable UIColor *)ows_conversationThemeColorForColorName:(NSString *)colorName ++ (nullable UIColor *)ows_conversationColorForColorName:(NSString *)colorName mode:(ConversationColorMode)mode { OWSAssertDebug(colorName.length > 0); - BOOL isShaded = Theme.isDarkThemeEnabled; - return (isShaded ? self.ows_conversationColorMapShade : self.ows_conversationColorMap)[colorName]; + switch (mode) { + case ConversationColorMode_Default: + return self.ows_conversationColorMap[colorName]; + case ConversationColorMode_Shade: + return self.ows_conversationColorMapShade[colorName]; + case ConversationColorMode_Tint: + return self.ows_conversationColorMapTint[colorName]; + } } + (nullable UIColor *)ows_conversationTintColorForColorName:(NSString *)colorName diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index b88c2feaa..964f6d92c 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -136,7 +136,8 @@ public class ConversationStyle: NSObject { return self.defaultBubbleColorIncoming } - guard let color = UIColor.ows_conversationThemeColor(colorName: colorName) else { + guard let color = UIColor.ows_conversationColor(colorName: colorName, + mode: Theme.isDarkThemeEnabled ? .shade : .default) else { return self.defaultBubbleColorIncoming } diff --git a/SignalMessaging/utils/OWSContactAvatarBuilder.m b/SignalMessaging/utils/OWSContactAvatarBuilder.m index feb328dff..c6037d343 100644 --- a/SignalMessaging/utils/OWSContactAvatarBuilder.m +++ b/SignalMessaging/utils/OWSContactAvatarBuilder.m @@ -124,7 +124,10 @@ NS_ASSUME_NONNULL_BEGIN [initials appendString:@"#"]; } - UIColor *color = [UIColor ows_conversationThemeColorForColorName:self.colorName]; + UIColor *color = + [UIColor ows_conversationColorForColorName:self.colorName + mode:(Theme.isDarkThemeEnabled ? ConversationColorMode_Shade + : ConversationColorMode_Default)]; OWSAssertDebug(color); UIImage *_Nullable image =