Merge branch 'charlesmchen/converationColorsVsBubbles'

pull/1/head
Matthew Chen 7 years ago
commit b5dd8d0c7b

@ -8,6 +8,7 @@
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"
#import <SignalMessaging/Theme.h>
#import <SignalServiceKit/OWSSignalService.h> #import <SignalServiceKit/OWSSignalService.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN

@ -82,8 +82,8 @@ class ColorPickerViewController: UIViewController, UIPickerViewDelegate, UIPicke
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
if let colorName = thread.conversationColorName, let colorName = thread.conversationColorName
let index = colorNames.index(of: colorName) { if let index = colorNames.index(of: colorName) {
pickerView.selectRow(index, inComponent: 0, animated: false) pickerView.selectRow(index, inComponent: 0, animated: false)
} }
} }
@ -110,12 +110,11 @@ 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 color = UIColor.ows_conversationColor(colorName: colorName, guard let colors = UIColor.ows_conversationColor(colorName: colorName) else {
isShaded: Theme.isDarkThemeEnabled) else {
owsFailDebug("unknown color name") owsFailDebug("unknown color name")
return ColorView(color: .white) return ColorView(color: UIColor.ows_defaultConversationColor().themeColor)
} }
return ColorView(color: color) return ColorView(color: colors.themeColor)
} }
// MARK: Actions // MARK: Actions

@ -122,7 +122,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
- (UIColor *)highlightColor - (UIColor *)highlightColor
{ {
BOOL isQuotingSelf = [NSObject isNullableObject:self.quotedMessage.authorId equalTo:TSAccountManager.localNumber]; BOOL isQuotingSelf = [NSObject isNullableObject:self.quotedMessage.authorId equalTo:TSAccountManager.localNumber];
return (isQuotingSelf ? self.conversationStyle.bubbleColorOutgoingSent return (isQuotingSelf ? [self.conversationStyle bubbleColorWithIsIncoming:NO]
: [self.conversationStyle quotingSelfHighlightColor]); : [self.conversationStyle quotingSelfHighlightColor]);
} }

@ -6,6 +6,7 @@
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"
#import <SignalMessaging/Theme.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN

@ -1342,75 +1342,25 @@ NS_ASSUME_NONNULL_BEGIN
hasCaption:YES], hasCaption:YES],
[self fakeOutgoingPngAction:thread [self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" actionLabel:@"Fake Outgoing 'Outgoing' Png"
imageSize:CGSizeMake(200.f, 200.f) imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingFailed] backgroundColor:[conversationStyle bubbleColorWithIsIncoming:NO]
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
messageState:TSOutgoingMessageStateFailed messageState:TSOutgoingMessageStateFailed
hasCaption:YES], hasCaption:YES],
[self fakeOutgoingPngAction:thread [self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" actionLabel:@"Fake Outgoing 'Outgoing' Png"
imageSize:CGSizeMake(200.f, 200.f) imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingFailed] backgroundColor:[conversationStyle bubbleColorWithIsIncoming:NO]
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
messageState:TSOutgoingMessageStateSending messageState:TSOutgoingMessageStateSending
hasCaption:YES], hasCaption:YES],
[self fakeOutgoingPngAction:thread [self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" actionLabel:@"Fake Outgoing 'Outgoing' Png"
imageSize:CGSizeMake(200.f, 200.f) imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingFailed] backgroundColor:[conversationStyle bubbleColorWithIsIncoming:NO]
textColor:[UIColor whiteColor]
imageLabel:@"W"
messageState:TSOutgoingMessageStateSent
hasCaption:YES],
[self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Sending' Png"
imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingSending]
textColor:[UIColor whiteColor]
imageLabel:@"W"
messageState:TSOutgoingMessageStateFailed
hasCaption:YES],
[self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Sending' Png"
imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingSending]
textColor:[UIColor whiteColor]
imageLabel:@"W"
messageState:TSOutgoingMessageStateSending
hasCaption:YES],
[self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Sending' Png"
imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingSending]
textColor:[UIColor whiteColor]
imageLabel:@"W"
messageState:TSOutgoingMessageStateSent
hasCaption:YES],
[self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Sent' Png"
imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingSent]
textColor:[UIColor whiteColor]
imageLabel:@"W"
messageState:TSOutgoingMessageStateFailed
hasCaption:YES],
[self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Sent' Png"
imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingSent]
textColor:[UIColor whiteColor]
imageLabel:@"W"
messageState:TSOutgoingMessageStateSending
hasCaption:YES],
[self fakeOutgoingPngAction:thread
actionLabel:@"Fake Outgoing 'Outgoing Sent' Png"
imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle bubbleColorOutgoingSent]
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
messageState:TSOutgoingMessageStateSent messageState:TSOutgoingMessageStateSent
@ -1578,7 +1528,15 @@ 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 primaryColor] backgroundColor:[conversationStyle conversationColor].primaryColor
textColor:[UIColor whiteColor]
imageLabel:@"W"
isAttachmentDownloaded:YES
hasCaption:YES],
[self fakeIncomingPngAction:thread
actionLabel:@"Fake Incoming 'Incoming' Png"
imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle conversationColor].shadeColor
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
isAttachmentDownloaded:YES isAttachmentDownloaded:YES
@ -1586,7 +1544,15 @@ 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 primaryColor] backgroundColor:[conversationStyle conversationColor].primaryColor
textColor:[UIColor whiteColor]
imageLabel:@"W"
isAttachmentDownloaded:NO
hasCaption:YES],
[self fakeIncomingPngAction:thread
actionLabel:@"Fake Incoming 'Incoming' Png"
imageSize:CGSizeMake(200.f, 200.f)
backgroundColor:[conversationStyle conversationColor].shadeColor
textColor:[UIColor whiteColor] textColor:[UIColor whiteColor]
imageLabel:@"W" imageLabel:@"W"
isAttachmentDownloaded:NO isAttachmentDownloaded:NO

@ -289,8 +289,7 @@ const CGFloat kIconViewLength = 24;
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{
NSString *colorName = self.thread.conversationColorName; NSString *colorName = self.thread.conversationColorName;
UIColor *currentColor = UIColor *currentColor =
[UIColor ows_conversationColorForColorName:colorName [UIColor ows_conversationColorOrDefaultForColorName:colorName].themeColor;
isShaded:Theme.isDarkThemeEnabled];
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];

@ -5,6 +5,7 @@
#import "CountryCodeViewController.h" #import "CountryCodeViewController.h"
#import "OWSSearchBar.h" #import "OWSSearchBar.h"
#import "PhoneNumberUtil.h" #import "PhoneNumberUtil.h"
#import "Theme.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"

@ -4,6 +4,7 @@
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "Theme.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"

@ -2,6 +2,7 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "UIColor+OWS.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN

@ -2,11 +2,26 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "Theme.h"
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN 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) @interface UIColor (OWS)
#pragma mark - #pragma mark -
@ -28,14 +43,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (UIColor *)colorWithRGBHex:(unsigned long)value; + (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<NSString *> *ows_conversationColorNames;
- (UIColor *)blendWithColor:(UIColor *)otherColor alpha:(CGFloat)alpha; - (UIColor *)blendWithColor:(UIColor *)otherColor alpha:(CGFloat)alpha;
#pragma mark - Color Palette #pragma mark - Color Palette
@ -59,19 +66,66 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Conversation Colors #pragma mark - Conversation Colors
@property (class, readonly, nonatomic) UIColor *ows_red700Color; @property (class, readonly, nonatomic) UIColor *ows_crimsonColor;
@property (class, readonly, nonatomic) UIColor *ows_pink600Color; @property (class, readonly, nonatomic) UIColor *ows_vermilionColor;
@property (class, readonly, nonatomic) UIColor *ows_purple600Color; @property (class, readonly, nonatomic) UIColor *ows_burlapColor;
@property (class, readonly, nonatomic) UIColor *ows_indigo600Color; @property (class, readonly, nonatomic) UIColor *ows_forestColor;
@property (class, readonly, nonatomic) UIColor *ows_blue700Color; @property (class, readonly, nonatomic) UIColor *ows_wintergreenColor;
@property (class, readonly, nonatomic) UIColor *ows_cyan800Color; @property (class, readonly, nonatomic) UIColor *ows_tealColor;
@property (class, readonly, nonatomic) UIColor *ows_teal700Color; @property (class, readonly, nonatomic) UIColor *ows_blueColor;
@property (class, readonly, nonatomic) UIColor *ows_green800Color; @property (class, readonly, nonatomic) UIColor *ows_indigoColor;
@property (class, readonly, nonatomic) UIColor *ows_deepOrange900Color; @property (class, readonly, nonatomic) UIColor *ows_violetColor;
@property (class, readonly, nonatomic) UIColor *ows_grey600Color; @property (class, readonly, nonatomic) UIColor *ows_plumColor;
@property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor; @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<NSString *> *ows_conversationColorNames;
+ (NSString *)ows_defaultConversationColorName; + (NSString *)ows_defaultConversationColorName;
+ (OWSConversationColor *)ows_defaultConversationColor;
// TODO: Remove
@property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor;
@end @end

@ -2,12 +2,46 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "UIColor+OWS.h"
#import "OWSMath.h" #import "OWSMath.h"
#import "Theme.h"
#import "UIColor+OWS.h"
#import <SignalServiceKit/Cryptography.h> #import <SignalServiceKit/Cryptography.h>
NS_ASSUME_NONNULL_BEGIN 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) @implementation UIColor (OWS)
#pragma mark - #pragma mark -
@ -196,123 +230,309 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Conversation Colors #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];
} }
+ (NSDictionary<NSString *, UIColor *> *)ows_conversationColorMapLight + (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<NSString *, UIColor *> *)ows_conversationColorMap
{ {
static NSDictionary<NSString *, UIColor *> *colorMap; static NSDictionary<NSString *, UIColor *> *colorMap;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
colorMap = @{ colorMap = @{
@"red" : self.ows_red700Color, @"crimson" : self.ows_crimsonColor,
@"pink" : self.ows_pink600Color, @"vermilion" : self.ows_vermilionColor,
@"purple" : self.ows_purple600Color, @"burlap" : self.ows_burlapColor,
@"indigo" : self.ows_indigo600Color, @"forest" : self.ows_forestColor,
@"blue" : self.ows_blue700Color, @"wintergreen" : self.ows_wintergreenColor,
@"cyan" : self.ows_cyan800Color, @"teal" : self.ows_tealColor,
@"teal" : self.ows_teal700Color, @"blue" : self.ows_blueColor,
@"green" : self.ows_green800Color, @"indigo" : self.ows_indigoColor,
@"deep_orange" : self.ows_deepOrange900Color, @"violet" : self.ows_violetColor,
@"grey" : self.ows_grey600Color @"plum" : self.ows_plumColor,
@"taupe" : self.ows_taupeColor,
@"steel" : self.ows_steelColor,
}; };
}); });
return colorMap; return colorMap;
} }
+ (NSDictionary<NSString *, UIColor *> *)ows_conversationColorMapDark + (NSDictionary<NSString *, UIColor *> *)ows_conversationColorMapShade
{ {
static NSDictionary<NSString *, UIColor *> *colorMap; static NSDictionary<NSString *, UIColor *> *colorMap;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
colorMap = @{ colorMap = @{
@"red" : self.ows_red700Color, @"crimson" : self.ows_crimsonShadeColor,
@"pink" : self.ows_pink600Color, @"vermilion" : self.ows_vermilionShadeColor,
@"purple" : self.ows_purple600Color, @"burlap" : self.ows_burlapShadeColor,
@"indigo" : self.ows_indigo600Color, @"forest" : self.ows_forestShadeColor,
@"blue" : self.ows_blue700Color, @"wintergreen" : self.ows_wintergreenShadeColor,
@"cyan" : self.ows_cyan800Color, @"teal" : self.ows_tealShadeColor,
@"teal" : self.ows_teal700Color, @"blue" : self.ows_blueShadeColor,
@"green" : self.ows_green800Color, @"indigo" : self.ows_indigoShadeColor,
@"deep_orange" : self.ows_deepOrange900Color, @"violet" : self.ows_violetShadeColor,
@"grey" : self.ows_grey600Color @"plum" : self.ows_plumShadeColor,
@"taupe" : self.ows_taupeShadeColor,
@"steel" : self.ows_steelShadeColor,
}; };
OWSAssertDebug([self.ows_conversationColorMap.allKeys isEqualToArray:colorMap.allKeys]);
}); });
return colorMap; return colorMap;
} }
+ (NSArray<NSString *> *)ows_conversationColorNames + (NSDictionary<NSString *, UIColor *> *)ows_conversationColorMapTint
{ {
OWSAssertDebug( static NSDictionary<NSString *, UIColor *> *colorMap;
[self.ows_conversationColorMapLight.allKeys isEqualToArray:self.ows_conversationColorMapDark.allKeys]); 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 self.ows_conversationColorMapLight.allKeys; return colorMap;
}
+ (NSArray<NSString *> *)ows_conversationColorNames
{
return self.ows_conversationColorMap.allKeys;
} }
+ (nullable UIColor *)ows_conversationColorForColorName:(NSString *)colorName isShaded:(BOOL)isShaded + (nullable OWSConversationColor *)ows_conversationColorForColorName:(NSString *)conversationColorName
{ {
OWSAssertDebug(colorName.length > 0); 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];
}
return (isShaded ? self.ows_conversationColorMapDark : self.ows_conversationColorMapLight)[colorName]; + (OWSConversationColor *)ows_conversationColorOrDefaultForColorName:(NSString *)conversationColorName
{
OWSConversationColor *_Nullable conversationColor = [self ows_conversationColorForColorName:conversationColorName];
if (conversationColor) {
return conversationColor;
}
return [self ows_defaultConversationColor];
} }
+ (NSString *)ows_defaultConversationColorName + (NSString *)ows_defaultConversationColorName
{ {
return @"teal"; NSString *conversationColorName = @"teal";
OWSAssert([self.ows_conversationColorNames containsObject:conversationColorName]);
return conversationColorName;
}
+ (OWSConversationColor *)ows_defaultConversationColor
{
return [self ows_conversationColorForColorName:self.ows_defaultConversationColorName];
}
// 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 @end

@ -2,9 +2,10 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "UIViewController+OWS.h" #import "Theme.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"
#import "UIViewController+OWS.h"
#import <SignalServiceKit/AppContext.h> #import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/iOSVersions.h> #import <SignalServiceKit/iOSVersions.h>

@ -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.primaryColor = ConversationStyle.primaryColor(thread: thread) self.conversationColor = ConversationStyle.conversationColor(thread: thread)
super.init() super.init()
@ -126,22 +126,18 @@ public class ConversationStyle: NSObject {
lastTextLineAxis = CGFloat(round(baseFontOffset + messageTextFont.capHeight * 0.5)) lastTextLineAxis = CGFloat(round(baseFontOffset + messageTextFont.capHeight * 0.5))
self.primaryColor = ConversationStyle.primaryColor(thread: thread) self.conversationColor = ConversationStyle.conversationColor(thread: thread)
} }
// MARK: Colors // MARK: Colors
private class func primaryColor(thread: TSThread) -> UIColor { @objc
guard let colorName = thread.conversationColorName else { public var conversationColor: OWSConversationColor
return self.defaultBubbleColorIncoming
}
guard let color = UIColor.ows_conversationColor(colorName: colorName, private class func conversationColor(thread: TSThread) -> OWSConversationColor {
isShaded: Theme.isDarkThemeEnabled) else { let colorName = thread.conversationColorName
return self.defaultBubbleColorIncoming
}
return color return UIColor.ows_conversationColorOrDefault(colorName: colorName)
} }
@objc @objc
@ -149,37 +145,15 @@ public class ConversationStyle: NSObject {
return Theme.isDarkThemeEnabled ? UIColor.ows_gray75 : UIColor.ows_messageBubbleLightGray return Theme.isDarkThemeEnabled ? UIColor.ows_gray75 : UIColor.ows_messageBubbleLightGray
} }
@objc
public let bubbleColorOutgoingFailed = UIColor.ows_darkSkyBlue
@objc
public let bubbleColorOutgoingSending = UIColor.ows_darkSkyBlue
@objc
public let bubbleColorOutgoingSent = UIColor.ows_darkSkyBlue
@objc @objc
public let dateBreakTextColor = UIColor.ows_gray60 public let dateBreakTextColor = UIColor.ows_gray60
@objc
public var primaryColor: UIColor
@objc @objc
public func bubbleColor(message: TSMessage) -> UIColor { public func bubbleColor(message: TSMessage) -> UIColor {
if message is TSIncomingMessage { if message is TSIncomingMessage {
return ConversationStyle.defaultBubbleColorIncoming return bubbleColor(isIncoming: true)
} else if let outgoingMessage = message as? TSOutgoingMessage {
switch outgoingMessage.messageState {
case .failed:
return bubbleColorOutgoingFailed
case .sending:
return bubbleColorOutgoingSending
default:
return bubbleColorOutgoingSent
}
} else { } else {
owsFailDebug("Unexpected message type: \(message)") return bubbleColor(isIncoming: false)
return bubbleColorOutgoingSent
} }
} }
@ -188,7 +162,7 @@ public class ConversationStyle: NSObject {
if isIncoming { if isIncoming {
return ConversationStyle.defaultBubbleColorIncoming return ConversationStyle.defaultBubbleColorIncoming
} else { } else {
return self.bubbleColorOutgoingSent return conversationColor.primaryColor
} }
} }
@ -229,21 +203,18 @@ public class ConversationStyle: NSObject {
@objc @objc
public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor { public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor {
if Theme.isDarkThemeEnabled { if Theme.isDarkThemeEnabled {
let alpha: CGFloat = (isIncoming ? 0.6 :0.5) return conversationColor.shadeColor
return UIColor.white.blend(with: bubbleColorOutgoingSent, alpha: alpha)
} else if isIncoming {
return bubbleColorOutgoingSent.withAlphaComponent(0.25)
} else { } else {
return ConversationStyle.defaultBubbleColorIncoming.withAlphaComponent(0.75) return conversationColor.tintColor
} }
} }
@objc @objc
public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor { public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor {
if isIncoming { if isIncoming {
return bubbleColorOutgoingSent return conversationColor.primaryColor
} else { } else {
return UIColor.white return Theme.backgroundColor
} }
} }
@ -255,12 +226,16 @@ public class ConversationStyle: NSObject {
@objc @objc
public func quotedReplyAuthorColor() -> UIColor { public func quotedReplyAuthorColor() -> UIColor {
return UIColor.ows_gray90 return quotedReplyTextColor()
} }
@objc @objc
public func quotedReplyTextColor() -> UIColor { public func quotedReplyTextColor() -> UIColor {
return UIColor.ows_gray90 if Theme.isDarkThemeEnabled {
return UIColor.ows_gray05
} else {
return UIColor.ows_gray90
}
} }
@objc @objc

@ -7,6 +7,7 @@
#import "OWSGroupAvatarBuilder.h" #import "OWSGroupAvatarBuilder.h"
#import "TSContactThread.h" #import "TSContactThread.h"
#import "TSGroupThread.h" #import "TSGroupThread.h"
#import "Theme.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"

@ -124,7 +124,7 @@ NS_ASSUME_NONNULL_BEGIN
[initials appendString:@"#"]; [initials appendString:@"#"];
} }
UIColor *color = [UIColor ows_conversationColorForColorName:self.colorName isShaded:Theme.isDarkThemeEnabled]; 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) {

@ -3,6 +3,7 @@
// //
#import "UIUtil.h" #import "UIUtil.h"
#import "Theme.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import <SignalServiceKit/AppContext.h> #import <SignalServiceKit/AppContext.h>

@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
- (NSString *)name; - (NSString *)name;
@property (readonly, nullable) NSString *conversationColorName; @property (nonatomic, readonly) NSString *conversationColorName;
- (void)updateConversationColorName:(NSString *)colorName transaction:(YapDatabaseReadWriteTransaction *)transaction; - (void)updateConversationColorName:(NSString *)colorName transaction:(YapDatabaseReadWriteTransaction *)transaction;
+ (NSString *)stableConversationColorNameForString:(NSString *)colorSeed; + (NSString *)stableConversationColorNameForString:(NSString *)colorSeed;

@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) NSDate *creationDate; @property (nonatomic) NSDate *creationDate;
@property (nonatomic, copy, nullable) NSDate *archivalDate; @property (nonatomic, copy, nullable) NSDate *archivalDate;
@property (nonatomic, nullable) NSString *conversationColorName; @property (nonatomic) NSString *conversationColorName;
@property (nonatomic, nullable) NSDate *lastMessageDate; @property (nonatomic, nullable) NSDate *lastMessageDate;
@property (nonatomic, copy, nullable) NSString *messageDraft; @property (nonatomic, copy, nullable) NSString *messageDraft;
@property (atomic, nullable) NSDate *mutedUntilDate; @property (atomic, nullable) NSDate *mutedUntilDate;

Loading…
Cancel
Save