mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Change conversation bubble colors.
This commit is contained in:
parent
5344766ef2
commit
17541a8888
2 changed files with 54 additions and 20 deletions
|
@ -38,11 +38,15 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
//#define SHOW_COLOR_PICKER
|
||||
|
||||
const CGFloat kIconViewLength = 24;
|
||||
|
||||
@interface OWSConversationSettingsViewController () <ContactEditingDelegate,
|
||||
ContactsViewHelperDelegate,
|
||||
#ifdef SHOW_COLOR_PICKER
|
||||
ColorPickerDelegate,
|
||||
#endif
|
||||
OWSSheetViewControllerDelegate>
|
||||
|
||||
@property (nonatomic) TSThread *thread;
|
||||
|
@ -59,7 +63,9 @@ const CGFloat kIconViewLength = 24;
|
|||
@property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper;
|
||||
@property (nonatomic, readonly) UIImageView *avatarView;
|
||||
@property (nonatomic, readonly) UILabel *disappearingMessagesDurationLabel;
|
||||
#ifdef SHOW_COLOR_PICKER
|
||||
@property (nonatomic) OWSColorPicker *colorPicker;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
@ -250,8 +256,10 @@ const CGFloat kIconViewLength = 24;
|
|||
[[OWSDisappearingMessagesConfiguration alloc] initDefaultWithThreadId:self.thread.uniqueId];
|
||||
}
|
||||
|
||||
#ifdef SHOW_COLOR_PICKER
|
||||
self.colorPicker = [[OWSColorPicker alloc] initWithThread:self.thread];
|
||||
self.colorPicker.delegate = self;
|
||||
#endif
|
||||
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
@ -465,6 +473,7 @@ const CGFloat kIconViewLength = 24;
|
|||
customRowHeight:UITableViewAutomaticDimension
|
||||
actionBlock:nil]];
|
||||
}
|
||||
#ifdef SHOW_COLOR_PICKER
|
||||
[mainSection
|
||||
addItem:[OWSTableItem
|
||||
itemWithCustomCellBlock:^{
|
||||
|
@ -479,6 +488,7 @@ const CGFloat kIconViewLength = 24;
|
|||
actionBlock:^{
|
||||
[weakSelf showColorPicker];
|
||||
}]];
|
||||
#endif
|
||||
|
||||
[contents addSection:mainSection];
|
||||
|
||||
|
@ -1297,6 +1307,8 @@ const CGFloat kIconViewLength = 24;
|
|||
|
||||
#pragma mark - ColorPickerDelegate
|
||||
|
||||
#ifdef SHOW_COLOR_PICKER
|
||||
|
||||
- (void)showColorPicker
|
||||
{
|
||||
OWSSheetViewController *sheetViewController = self.colorPicker.sheetViewController;
|
||||
|
@ -1329,6 +1341,8 @@ const CGFloat kIconViewLength = 24;
|
|||
});
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#pragma mark - OWSSheetViewController
|
||||
|
||||
- (void)sheetViewControllerRequestedDismiss:(OWSSheetViewController *)sheetViewController
|
||||
|
|
|
@ -145,15 +145,34 @@ public class ConversationStyle: NSObject {
|
|||
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
|
||||
public let dateBreakTextColor = UIColor.ows_gray60
|
||||
|
||||
@objc
|
||||
public func bubbleColor(message: TSMessage) -> UIColor {
|
||||
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 {
|
||||
return bubbleColor(isIncoming: false)
|
||||
owsFailDebug("Unexpected message type: \(message)")
|
||||
return bubbleColorOutgoingSent
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +181,7 @@ public class ConversationStyle: NSObject {
|
|||
if isIncoming {
|
||||
return ConversationStyle.defaultBubbleColorIncoming
|
||||
} 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
|
||||
public func bubbleSecondaryTextColor(isIncoming: Bool) -> UIColor {
|
||||
if !isIncoming {
|
||||
// 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
|
||||
}
|
||||
return bubbleTextColor(isIncoming: isIncoming).withAlphaComponent(0.7)
|
||||
}
|
||||
|
||||
@objc
|
||||
public func quotedReplyBubbleColor(isIncoming: Bool) -> UIColor {
|
||||
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 {
|
||||
return conversationColor.tintColor
|
||||
return ConversationStyle.defaultBubbleColorIncoming.withAlphaComponent(0.75)
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
public func quotedReplyStripeColor(isIncoming: Bool) -> UIColor {
|
||||
if isIncoming {
|
||||
return conversationColor.primaryColor
|
||||
if Theme.isDarkThemeEnabled {
|
||||
if isIncoming {
|
||||
return UIColor(rgbHex: 0x1976D2)
|
||||
} else {
|
||||
return UIColor.ows_black
|
||||
}
|
||||
} else if isIncoming {
|
||||
return bubbleColorOutgoingSent
|
||||
} else {
|
||||
return Theme.backgroundColor
|
||||
return UIColor.white
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue