|
|
|
@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
@interface OWSConversationColor ()
|
|
|
|
@interface OWSConversationColor ()
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic) NSString *name;
|
|
|
|
@property (nonatomic) ConversationColorName name;
|
|
|
|
@property (nonatomic) UIColor *primaryColor;
|
|
|
|
@property (nonatomic) UIColor *primaryColor;
|
|
|
|
@property (nonatomic) UIColor *shadeColor;
|
|
|
|
@property (nonatomic) UIColor *shadeColor;
|
|
|
|
@property (nonatomic) UIColor *tintColor;
|
|
|
|
@property (nonatomic) UIColor *tintColor;
|
|
|
|
@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
@implementation OWSConversationColor
|
|
|
|
@implementation OWSConversationColor
|
|
|
|
|
|
|
|
|
|
|
|
+ (OWSConversationColor *)conversationColorWithName:(NSString *)name
|
|
|
|
+ (OWSConversationColor *)conversationColorWithName:(ConversationColorName)name
|
|
|
|
primaryColor:(UIColor *)primaryColor
|
|
|
|
primaryColor:(UIColor *)primaryColor
|
|
|
|
shadeColor:(UIColor *)shadeColor
|
|
|
|
shadeColor:(UIColor *)shadeColor
|
|
|
|
tintColor:(UIColor *)tintColor
|
|
|
|
tintColor:(UIColor *)tintColor
|
|
|
|
@ -246,51 +246,51 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
// Order here affects the order in the conversation color picker.
|
|
|
|
// Order here affects the order in the conversation color picker.
|
|
|
|
allConversationColors = @[
|
|
|
|
allConversationColors = @[
|
|
|
|
[OWSConversationColor conversationColorWithName:@"crimson"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameCrimson
|
|
|
|
primaryColor:self.ows_crimsonColor
|
|
|
|
primaryColor:self.ows_crimsonColor
|
|
|
|
shadeColor:self.ows_crimsonShadeColor
|
|
|
|
shadeColor:self.ows_crimsonShadeColor
|
|
|
|
tintColor:self.ows_crimsonTintColor],
|
|
|
|
tintColor:self.ows_crimsonTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"vermilion"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameVermilion
|
|
|
|
primaryColor:self.ows_vermilionColor
|
|
|
|
primaryColor:self.ows_vermilionColor
|
|
|
|
shadeColor:self.ows_vermilionShadeColor
|
|
|
|
shadeColor:self.ows_vermilionShadeColor
|
|
|
|
tintColor:self.ows_vermilionTintColor],
|
|
|
|
tintColor:self.ows_vermilionTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"burlap"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameBurlap
|
|
|
|
primaryColor:self.ows_burlapColor
|
|
|
|
primaryColor:self.ows_burlapColor
|
|
|
|
shadeColor:self.ows_burlapShadeColor
|
|
|
|
shadeColor:self.ows_burlapShadeColor
|
|
|
|
tintColor:self.ows_burlapTintColor],
|
|
|
|
tintColor:self.ows_burlapTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"forest"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameForest
|
|
|
|
primaryColor:self.ows_forestColor
|
|
|
|
primaryColor:self.ows_forestColor
|
|
|
|
shadeColor:self.ows_forestShadeColor
|
|
|
|
shadeColor:self.ows_forestShadeColor
|
|
|
|
tintColor:self.ows_forestTintColor],
|
|
|
|
tintColor:self.ows_forestTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"wintergreen"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameWintergreen
|
|
|
|
primaryColor:self.ows_wintergreenColor
|
|
|
|
primaryColor:self.ows_wintergreenColor
|
|
|
|
shadeColor:self.ows_wintergreenShadeColor
|
|
|
|
shadeColor:self.ows_wintergreenShadeColor
|
|
|
|
tintColor:self.ows_wintergreenTintColor],
|
|
|
|
tintColor:self.ows_wintergreenTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"teal"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameTeal
|
|
|
|
primaryColor:self.ows_tealColor
|
|
|
|
primaryColor:self.ows_tealColor
|
|
|
|
shadeColor:self.ows_tealShadeColor
|
|
|
|
shadeColor:self.ows_tealShadeColor
|
|
|
|
tintColor:self.ows_tealTintColor],
|
|
|
|
tintColor:self.ows_tealTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"blue"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameBlue
|
|
|
|
primaryColor:self.ows_blueColor
|
|
|
|
primaryColor:self.ows_blueColor
|
|
|
|
shadeColor:self.ows_blueShadeColor
|
|
|
|
shadeColor:self.ows_blueShadeColor
|
|
|
|
tintColor:self.ows_blueTintColor],
|
|
|
|
tintColor:self.ows_blueTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"indigo"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameIndigo
|
|
|
|
primaryColor:self.ows_indigoColor
|
|
|
|
primaryColor:self.ows_indigoColor
|
|
|
|
shadeColor:self.ows_indigoShadeColor
|
|
|
|
shadeColor:self.ows_indigoShadeColor
|
|
|
|
tintColor:self.ows_indigoTintColor],
|
|
|
|
tintColor:self.ows_indigoTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"violet"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameViolet
|
|
|
|
primaryColor:self.ows_violetColor
|
|
|
|
primaryColor:self.ows_violetColor
|
|
|
|
shadeColor:self.ows_violetShadeColor
|
|
|
|
shadeColor:self.ows_violetShadeColor
|
|
|
|
tintColor:self.ows_violetTintColor],
|
|
|
|
tintColor:self.ows_violetTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"plum"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNamePlum
|
|
|
|
primaryColor:self.ows_plumColor
|
|
|
|
primaryColor:self.ows_plumColor
|
|
|
|
shadeColor:self.ows_plumShadeColor
|
|
|
|
shadeColor:self.ows_plumShadeColor
|
|
|
|
tintColor:self.ows_plumTintColor],
|
|
|
|
tintColor:self.ows_plumTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"taupe"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameTaupe
|
|
|
|
primaryColor:self.ows_taupeColor
|
|
|
|
primaryColor:self.ows_taupeColor
|
|
|
|
shadeColor:self.ows_taupeShadeColor
|
|
|
|
shadeColor:self.ows_taupeShadeColor
|
|
|
|
tintColor:self.ows_taupeTintColor],
|
|
|
|
tintColor:self.ows_taupeTintColor],
|
|
|
|
[OWSConversationColor conversationColorWithName:@"steel"
|
|
|
|
[OWSConversationColor conversationColorWithName:ConversationColorNameSteel
|
|
|
|
primaryColor:self.ows_steelColor
|
|
|
|
primaryColor:self.ows_steelColor
|
|
|
|
shadeColor:self.ows_steelShadeColor
|
|
|
|
shadeColor:self.ows_steelShadeColor
|
|
|
|
tintColor:self.ows_steelTintColor],
|
|
|
|
tintColor:self.ows_steelTintColor],
|
|
|
|
@ -300,12 +300,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
return allConversationColors;
|
|
|
|
return allConversationColors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSDictionary<NSString *, OWSConversationColor *> *)conversationColorMap
|
|
|
|
+ (NSDictionary<ConversationColorName, OWSConversationColor *> *)conversationColorMap
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static NSDictionary<NSString *, OWSConversationColor *> *colorMap;
|
|
|
|
static NSDictionary<ConversationColorName, OWSConversationColor *> *colorMap;
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
NSMutableDictionary<NSString *, OWSConversationColor *> *mutableColorMap = [NSMutableDictionary new];
|
|
|
|
NSMutableDictionary<ConversationColorName, OWSConversationColor *> *mutableColorMap = [NSMutableDictionary new];
|
|
|
|
for (OWSConversationColor *conversationColor in self.allConversationColors) {
|
|
|
|
for (OWSConversationColor *conversationColor in self.allConversationColors) {
|
|
|
|
mutableColorMap[conversationColor.name] = conversationColor;
|
|
|
|
mutableColorMap[conversationColor.name] = conversationColor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -315,22 +315,22 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
return colorMap;
|
|
|
|
return colorMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (NSArray<NSString *> *)conversationColorNames
|
|
|
|
+ (NSArray<ConversationColorName> *)conversationColorNames
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSMutableArray<NSString *> *names = [NSMutableArray new];
|
|
|
|
NSMutableArray<ConversationColorName> *names = [NSMutableArray new];
|
|
|
|
for (OWSConversationColor *conversationColor in self.allConversationColors) {
|
|
|
|
for (OWSConversationColor *conversationColor in self.allConversationColors) {
|
|
|
|
[names addObject:conversationColor.name];
|
|
|
|
[names addObject:conversationColor.name];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG
|
|
|
|
NSSet<NSString *> *colorNameSet = [NSSet setWithArray:names];
|
|
|
|
NSSet<ConversationColorName> *colorNameSet = [NSSet setWithArray:names];
|
|
|
|
// These constants are duplicated in two places. So this canary exists to make sure they stay in sync.
|
|
|
|
// These constants are duplicated in two places. So this canary exists to make sure they stay in sync.
|
|
|
|
NSSet<NSString *> *threadColorNameSet = [NSSet setWithArray:TSThread.conversationColorNames];
|
|
|
|
NSSet<ConversationColorName> *threadColorNameSet = [NSSet setWithArray:TSThread.conversationColorNames];
|
|
|
|
OWSAssertDebug([colorNameSet isEqual:threadColorNameSet]);
|
|
|
|
OWSAssertDebug([colorNameSet isEqual:threadColorNameSet]);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return [names copy];
|
|
|
|
return [names copy];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (nullable OWSConversationColor *)conversationColorForColorName:(NSString *)conversationColorName
|
|
|
|
+ (nullable OWSConversationColor *)conversationColorForColorName:(ConversationColorName)conversationColorName
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OWSConversationColor *_Nullable result = self.conversationColorMap[conversationColorName];
|
|
|
|
OWSConversationColor *_Nullable result = self.conversationColorMap[conversationColorName];
|
|
|
|
|
|
|
|
|
|
|
|
@ -340,7 +340,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ (OWSConversationColor *)conversationColorOrDefaultForColorName:(NSString *)conversationColorName
|
|
|
|
+ (OWSConversationColor *)conversationColorOrDefaultForColorName:(ConversationColorName)conversationColorName
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OWSConversationColor *_Nullable conversationColor = [self conversationColorForColorName:conversationColorName];
|
|
|
|
OWSConversationColor *_Nullable conversationColor = [self conversationColorForColorName:conversationColorName];
|
|
|
|
if (conversationColor) {
|
|
|
|
if (conversationColor) {
|
|
|
|
@ -351,7 +351,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
+ (OWSConversationColor *)defaultConversationColor
|
|
|
|
+ (OWSConversationColor *)defaultConversationColor
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return [self conversationColorForColorName:kTSThread_DefaultConversationColorName];
|
|
|
|
return [self conversationColorForColorName:kConversationColorName_Default];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|