Rename OWSConversationColor.

pull/1/head
Matthew Chen 7 years ago
parent 3adc03fa2c
commit b20cd57383

@ -110,9 +110,9 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke
owsFailDebug("color was unexpectedly nil") owsFailDebug("color was unexpectedly nil")
return ColorView(color: .white) return ColorView(color: .white)
} }
guard let colors = UIColor.ows_conversationColors(colorName: colorName) else { guard let colors = UIColor.ows_conversationColor(colorName: colorName) else {
owsFailDebug("unknown color name") owsFailDebug("unknown color name")
return ColorView(color: UIColor.ows_defaultConversationColors().themeColor) return ColorView(color: UIColor.ows_defaultConversationColor().themeColor)
} }
return ColorView(color: colors.themeColor) return ColorView(color: colors.themeColor)
} }

@ -1528,7 +1528,7 @@ NS_ASSUME_NONNULL_BEGIN
[self fakeIncomingPngAction:thread [self fakeIncomingPngAction:thread
actionLabel:@"Fake Incoming 'Incoming' Png" actionLabel:@"Fake Incoming 'Incoming' Png"
imageSize:CGSizeMake(200.f, 200.f) imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle conversationColors].defaultColor backgroundColor:[conversationStyle conversationColor].defaultColor
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
isAttachmentDownloaded:YES isAttachmentDownloaded:YES
@ -1536,7 +1536,7 @@ NS_ASSUME_NONNULL_BEGIN
[self fakeIncomingPngAction:thread [self fakeIncomingPngAction:thread
actionLabel:@"Fake Incoming 'Incoming' Png" actionLabel:@"Fake Incoming 'Incoming' Png"
imageSize:CGSizeMake(200.f, 200.f) imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle conversationColors].shadeColor backgroundColor:[conversationStyle conversationColor].shadeColor
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
isAttachmentDownloaded:YES isAttachmentDownloaded:YES
@ -1544,7 +1544,7 @@ NS_ASSUME_NONNULL_BEGIN
[self fakeIncomingPngAction:thread [self fakeIncomingPngAction:thread
actionLabel:@"Fake Incoming 'Incoming' Png" actionLabel:@"Fake Incoming 'Incoming' Png"
imageSize:CGSizeMake(200.f, 200.f) imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle conversationColors].defaultColor backgroundColor:[conversationStyle conversationColor].defaultColor
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
isAttachmentDownloaded:NO isAttachmentDownloaded:NO
@ -1552,7 +1552,7 @@ NS_ASSUME_NONNULL_BEGIN
[self fakeIncomingPngAction:thread [self fakeIncomingPngAction:thread
actionLabel:@"Fake Incoming 'Incoming' Png" actionLabel:@"Fake Incoming 'Incoming' Png"
imageSize:CGSizeMake(200.f, 200.f) imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle conversationColors].shadeColor backgroundColor:[conversationStyle conversationColor].shadeColor
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
isAttachmentDownloaded:NO isAttachmentDownloaded:NO

@ -289,7 +289,7 @@ const CGFloat kIconViewLength = 24;
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{
NSString *colorName = self.thread.conversationColorName; NSString *colorName = self.thread.conversationColorName;
UIColor *currentColor = UIColor *currentColor =
[UIColor ows_conversationColorsForColorName:colorName].themeColor; [UIColor ows_conversationColorForColorName:colorName].themeColor;
NSString *title = NSLocalizedString(@"CONVERSATION_SETTINGS_CONVERSATION_COLOR", NSString *title = NSLocalizedString(@"CONVERSATION_SETTINGS_CONVERSATION_COLOR",
@"Label for table cell which leads to picking a new conversation color"); @"Label for table cell which leads to picking a new conversation color");
return [weakSelf disclosureCellWithName:title iconColor:currentColor]; return [weakSelf disclosureCellWithName:title iconColor:currentColor];

@ -57,12 +57,4 @@ extern NSString *const ThemeDidChangeNotification;
@end @end
#pragma mark -
@interface OWSConversationColors (Theme)
@property (nonatomic, readonly) UIColor *themeColor;
@end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -162,15 +162,4 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled";
@end @end
#pragma mark -
@implementation OWSConversationColors (Theme)
- (UIColor *)themeColor
{
return Theme.isDarkThemeEnabled ? self.shadeColor : self.defaultColor;
}
@end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -6,15 +6,17 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface OWSConversationColors : NSObject @interface OWSConversationColor : NSObject
@property (nonatomic, readonly) UIColor *defaultColor; @property (nonatomic, readonly) UIColor *defaultColor;
@property (nonatomic, readonly) UIColor *shadeColor; @property (nonatomic, readonly) UIColor *shadeColor;
@property (nonatomic, readonly) UIColor *tintColor; @property (nonatomic, readonly) UIColor *tintColor;
+ (OWSConversationColors *)conversationColorsWithDefaultColor:(UIColor *)defaultColor @property (nonatomic, readonly) UIColor *themeColor;
shadeColor:(UIColor *)shadeColor
tintColor:(UIColor *)tintColor; + (OWSConversationColor *)conversationColorWithDefaultColor:(UIColor *)defaultColor
shadeColor:(UIColor *)shadeColor
tintColor:(UIColor *)tintColor;
@end @end
@ -109,18 +111,18 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Conversation Colors #pragma mark - Conversation Colors
+ (nullable OWSConversationColors *)ows_conversationColorsForColorName:(NSString *)colorName + (nullable OWSConversationColor *)ows_conversationColorForColorName:(NSString *)colorName
NS_SWIFT_NAME(ows_conversationColors(colorName:)); NS_SWIFT_NAME(ows_conversationColor(colorName:));
// If the conversation color name is valid, return its colors. // If the conversation color name is valid, return its colors.
// Otherwise return the "default" conversation colors. // Otherwise return the "default" conversation colors.
+ (OWSConversationColors *)ows_conversationColorsOrDefaultForColorName:(NSString *)conversationColorName + (OWSConversationColor *)ows_conversationColorOrDefaultForColorName:(NSString *)conversationColorName
NS_SWIFT_NAME(ows_conversationColorsOrDefault(colorName:)); NS_SWIFT_NAME(ows_conversationColorOrDefault(colorName:));
@property (class, readonly, nonatomic) NSArray<NSString *> *ows_conversationColorNames; @property (class, readonly, nonatomic) NSArray<NSString *> *ows_conversationColorNames;
+ (NSString *)ows_defaultConversationColorName; + (NSString *)ows_defaultConversationColorName;
+ (OWSConversationColors *)ows_defaultConversationColors; + (OWSConversationColor *)ows_defaultConversationColor;
// TODO: Remove // TODO: Remove
@property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor; @property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor;

@ -10,7 +10,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface OWSConversationColors () @interface OWSConversationColor ()
@property (nonatomic) UIColor *defaultColor; @property (nonatomic) UIColor *defaultColor;
@property (nonatomic) UIColor *shadeColor; @property (nonatomic) UIColor *shadeColor;
@ -20,19 +20,24 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - #pragma mark -
@implementation OWSConversationColors @implementation OWSConversationColor
+ (OWSConversationColors *)conversationColorsWithDefaultColor:(UIColor *)defaultColor + (OWSConversationColor *)conversationColorWithDefaultColor:(UIColor *)defaultColor
shadeColor:(UIColor *)shadeColor shadeColor:(UIColor *)shadeColor
tintColor:(UIColor *)tintColor tintColor:(UIColor *)tintColor
{ {
OWSConversationColors *instance = [OWSConversationColors new]; OWSConversationColor *instance = [OWSConversationColor new];
instance.defaultColor = defaultColor; instance.defaultColor = defaultColor;
instance.shadeColor = shadeColor; instance.shadeColor = shadeColor;
instance.tintColor = tintColor; instance.tintColor = tintColor;
return instance; return instance;
} }
- (UIColor *)themeColor
{
return Theme.isDarkThemeEnabled ? self.shadeColor : self.defaultColor;
}
@end @end
#pragma mark - #pragma mark -
@ -488,7 +493,7 @@ NS_ASSUME_NONNULL_BEGIN
return self.ows_conversationColorMap.allKeys; return self.ows_conversationColorMap.allKeys;
} }
+ (nullable OWSConversationColors *)ows_conversationColorsForColorName:(NSString *)conversationColorName + (nullable OWSConversationColor *)ows_conversationColorForColorName:(NSString *)conversationColorName
{ {
UIColor *_Nullable defaultColor = self.ows_conversationColorMap[conversationColorName]; UIColor *_Nullable defaultColor = self.ows_conversationColorMap[conversationColorName];
UIColor *_Nullable shadeColor = self.ows_conversationColorMapShade[conversationColorName]; UIColor *_Nullable shadeColor = self.ows_conversationColorMapShade[conversationColorName];
@ -499,19 +504,17 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertDebug(defaultColor); OWSAssertDebug(defaultColor);
OWSAssertDebug(shadeColor); OWSAssertDebug(shadeColor);
OWSAssertDebug(tintColor); OWSAssertDebug(tintColor);
return [OWSConversationColors conversationColorsWithDefaultColor:defaultColor return
shadeColor:shadeColor [OWSConversationColor conversationColorWithDefaultColor:defaultColor shadeColor:shadeColor tintColor:tintColor];
tintColor:tintColor];
} }
+ (OWSConversationColors *)ows_conversationColorsOrDefaultForColorName:(NSString *)conversationColorName + (OWSConversationColor *)ows_conversationColorOrDefaultForColorName:(NSString *)conversationColorName
{ {
OWSConversationColors *_Nullable conversationColors = OWSConversationColor *_Nullable conversationColor = [self ows_conversationColorForColorName:conversationColorName];
[self ows_conversationColorsForColorName:conversationColorName]; if (conversationColor) {
if (conversationColors) { return conversationColor;
return conversationColors;
} }
return [self ows_defaultConversationColors]; return [self ows_defaultConversationColor];
} }
+ (NSString *)ows_defaultConversationColorName + (NSString *)ows_defaultConversationColorName
@ -521,9 +524,9 @@ NS_ASSUME_NONNULL_BEGIN
return conversationColorName; return conversationColorName;
} }
+ (OWSConversationColors *)ows_defaultConversationColors + (OWSConversationColor *)ows_defaultConversationColor
{ {
return [self ows_conversationColorsForColorName:self.ows_defaultConversationColorName]; return [self ows_conversationColorForColorName:self.ows_defaultConversationColorName];
} }
// TODO: Remove // TODO: Remove

@ -64,7 +64,7 @@ public class ConversationStyle: NSObject {
public required init(thread: TSThread) { public required init(thread: TSThread) {
self.thread = thread self.thread = thread
self.conversationColors = ConversationStyle.conversationColors(thread: thread) self.conversationColor = ConversationStyle.conversationColor(thread: thread)
super.init() super.init()
@ -126,18 +126,18 @@ public class ConversationStyle: NSObject {
lastTextLineAxis = CGFloat(round(baseFontOffset + messageTextFont.capHeight * 0.5)) lastTextLineAxis = CGFloat(round(baseFontOffset + messageTextFont.capHeight * 0.5))
self.conversationColors = ConversationStyle.conversationColors(thread: thread) self.conversationColor = ConversationStyle.conversationColor(thread: thread)
} }
// MARK: Colors // MARK: Colors
@objc @objc
public var conversationColors: OWSConversationColors public var conversationColor: OWSConversationColor
private class func conversationColors(thread: TSThread) -> OWSConversationColors { private class func conversationColor(thread: TSThread) -> OWSConversationColor {
let colorName = thread.conversationColorName let colorName = thread.conversationColorName
return UIColor.ows_conversationColorsOrDefault(colorName: colorName) return UIColor.ows_conversationColorOrDefault(colorName: colorName)
} }
@objc @objc
@ -162,7 +162,7 @@ public class ConversationStyle: NSObject {
if isIncoming { if isIncoming {
return ConversationStyle.defaultBubbleColorIncoming return ConversationStyle.defaultBubbleColorIncoming
} else { } else {
return conversationColors.defaultColor return conversationColor.defaultColor
} }
} }
@ -203,16 +203,16 @@ public class ConversationStyle: NSObject {
@objc @objc
public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor { public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor {
if Theme.isDarkThemeEnabled { if Theme.isDarkThemeEnabled {
return conversationColors.shadeColor return conversationColor.shadeColor
} else { } else {
return conversationColors.tintColor return conversationColor.tintColor
} }
} }
@objc @objc
public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor { public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor {
if isIncoming { if isIncoming {
return conversationColors.defaultColor return conversationColor.defaultColor
} else { } else {
return Theme.backgroundColor return Theme.backgroundColor
} }

@ -124,7 +124,7 @@ NS_ASSUME_NONNULL_BEGIN
[initials appendString:@"#"]; [initials appendString:@"#"];
} }
UIColor *color = [UIColor ows_conversationColorsOrDefaultForColorName:self.colorName].themeColor; UIColor *color = [UIColor ows_conversationColorOrDefaultForColorName:self.colorName].themeColor;
OWSAssertDebug(color); OWSAssertDebug(color);
UIImage *_Nullable image = UIImage *_Nullable image =

@ -66,8 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
return cachedAvatar; return cachedAvatar;
} }
UIColor *backgroundColor = UIColor *backgroundColor = [UIColor ows_conversationColorForColorName:conversationColorName].themeColor;
[UIColor ows_conversationColorForColorName:conversationColorName isShaded:Theme.isDarkThemeEnabled];
UIImage *_Nullable image = UIImage *_Nullable image =
[OWSGroupAvatarBuilder groupAvatarImageWithBackgroundColor:backgroundColor diameter:diameter]; [OWSGroupAvatarBuilder groupAvatarImageWithBackgroundColor:backgroundColor diameter:diameter];
if (!image) { if (!image) {

Loading…
Cancel
Save