Change conversation bubble colors.

This commit is contained in:
Matthew Chen 2018-10-09 16:06:23 -04:00
parent 5344766ef2
commit 17541a8888
2 changed files with 54 additions and 20 deletions

View file

@ -38,11 +38,15 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
//#define SHOW_COLOR_PICKER
const CGFloat kIconViewLength = 24; const CGFloat kIconViewLength = 24;
@interface OWSConversationSettingsViewController () <ContactEditingDelegate, @interface OWSConversationSettingsViewController () <ContactEditingDelegate,
ContactsViewHelperDelegate, ContactsViewHelperDelegate,
#ifdef SHOW_COLOR_PICKER
ColorPickerDelegate, ColorPickerDelegate,
#endif
OWSSheetViewControllerDelegate> OWSSheetViewControllerDelegate>
@property (nonatomic) TSThread *thread; @property (nonatomic) TSThread *thread;
@ -59,7 +63,9 @@ const CGFloat kIconViewLength = 24;
@property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper; @property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper;
@property (nonatomic, readonly) UIImageView *avatarView; @property (nonatomic, readonly) UIImageView *avatarView;
@property (nonatomic, readonly) UILabel *disappearingMessagesDurationLabel; @property (nonatomic, readonly) UILabel *disappearingMessagesDurationLabel;
#ifdef SHOW_COLOR_PICKER
@property (nonatomic) OWSColorPicker *colorPicker; @property (nonatomic) OWSColorPicker *colorPicker;
#endif
@end @end
@ -250,8 +256,10 @@ const CGFloat kIconViewLength = 24;
[[OWSDisappearingMessagesConfiguration alloc] initDefaultWithThreadId:self.thread.uniqueId]; [[OWSDisappearingMessagesConfiguration alloc] initDefaultWithThreadId:self.thread.uniqueId];
} }
#ifdef SHOW_COLOR_PICKER
self.colorPicker = [[OWSColorPicker alloc] initWithThread:self.thread]; self.colorPicker = [[OWSColorPicker alloc] initWithThread:self.thread];
self.colorPicker.delegate = self; self.colorPicker.delegate = self;
#endif
[self updateTableContents]; [self updateTableContents];
} }
@ -465,6 +473,7 @@ const CGFloat kIconViewLength = 24;
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension
actionBlock:nil]]; actionBlock:nil]];
} }
#ifdef SHOW_COLOR_PICKER
[mainSection [mainSection
addItem:[OWSTableItem addItem:[OWSTableItem
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{
@ -479,6 +488,7 @@ const CGFloat kIconViewLength = 24;
actionBlock:^{ actionBlock:^{
[weakSelf showColorPicker]; [weakSelf showColorPicker];
}]]; }]];
#endif
[contents addSection:mainSection]; [contents addSection:mainSection];
@ -1297,6 +1307,8 @@ const CGFloat kIconViewLength = 24;
#pragma mark - ColorPickerDelegate #pragma mark - ColorPickerDelegate
#ifdef SHOW_COLOR_PICKER
- (void)showColorPicker - (void)showColorPicker
{ {
OWSSheetViewController *sheetViewController = self.colorPicker.sheetViewController; OWSSheetViewController *sheetViewController = self.colorPicker.sheetViewController;
@ -1329,6 +1341,8 @@ const CGFloat kIconViewLength = 24;
}); });
} }
#endif
#pragma mark - OWSSheetViewController #pragma mark - OWSSheetViewController
- (void)sheetViewControllerRequestedDismiss:(OWSSheetViewController *)sheetViewController - (void)sheetViewControllerRequestedDismiss:(OWSSheetViewController *)sheetViewController

View file

@ -145,15 +145,34 @@ 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 @objc
public func bubbleColor(message: TSMessage) -> UIColor { public func bubbleColor(message: TSMessage) -> UIColor {
if message is TSIncomingMessage { if message is TSIncomingMessage {
return bubbleColor(isIncoming: true) return ConversationStyle.defaultBubbleColorIncoming
} else if let outgoingMessage = message as? TSOutgoingMessage {
switch outgoingMessage.messageState {
case .failed:
return bubbleColorOutgoingFailed
case .sending:
return bubbleColorOutgoingSending
default:
return bubbleColorOutgoingSent
}
} else { } else {
return bubbleColor(isIncoming: false) owsFailDebug("Unexpected message type: \(message)")
return bubbleColorOutgoingSent
} }
} }
@ -162,7 +181,7 @@ public class ConversationStyle: NSObject {
if isIncoming { if isIncoming {
return ConversationStyle.defaultBubbleColorIncoming return ConversationStyle.defaultBubbleColorIncoming
} else { } else {
return conversationColor.primaryColor return self.bubbleColorOutgoingSent
} }
} }
@ -197,37 +216,38 @@ public class ConversationStyle: NSObject {
} }
} }
// Note that the exception for outgoing text only applies
// to secondary text within bubbles.
@objc @objc
public func bubbleSecondaryTextColor(isIncoming: Bool) -> UIColor { public func bubbleSecondaryTextColor(isIncoming: Bool) -> UIColor {
if !isIncoming { return bubbleTextColor(isIncoming: isIncoming).withAlphaComponent(0.7)
// All Outgoing
return UIColor.ows_white.withAlphaComponent(0.8)
} else if Theme.isDarkThemeEnabled {
// Incoming, dark.
return UIColor.ows_gray25
} else {
// Incoming, light.
return UIColor.ows_gray60
}
} }
@objc @objc
public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor { public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor {
if Theme.isDarkThemeEnabled { if Theme.isDarkThemeEnabled {
return conversationColor.shadeColor if isIncoming {
return UIColor(rgbHex: 0x1976D2).withAlphaComponent(0.75)
} else {
return UIColor.ows_black.withAlphaComponent(0.4)
}
} else if isIncoming {
return bubbleColorOutgoingSent.withAlphaComponent(0.25)
} else { } else {
return conversationColor.tintColor return ConversationStyle.defaultBubbleColorIncoming.withAlphaComponent(0.75)
} }
} }
@objc @objc
public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor { public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor {
if isIncoming { if Theme.isDarkThemeEnabled {
return conversationColor.primaryColor if isIncoming {
return UIColor(rgbHex: 0x1976D2)
} else {
return UIColor.ows_black
}
} else if isIncoming {
return bubbleColorOutgoingSent
} else { } else {
return Theme.backgroundColor return UIColor.white
} }
} }