From 087dd895c27f0fb9602022adfa9711f22c2e3534 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 30 Oct 2019 21:18:06 +0800 Subject: [PATCH] Allow hiding of user's name for each message bubble --- ChatSDKCore/Classes/Session/BConfiguration.h | 2 ++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + .../Classes/Components/Message Cells/BMessageCell.m | 12 ++++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 8d6a31dc..a5232cde 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -140,6 +140,8 @@ typedef enum { @property(nonatomic, readwrite) NSString * messageBubbleMaskLast; @property(nonatomic, readwrite) NSString * messageBubbleMaskSingle; +/// Hide the name label for each message bubble. +@property(nonatomic, readwrite) BOOL hideNameLabel; @property(nonatomic, readwrite) bNameLabelPosition nameLabelPosition; @property(nonatomic, readwrite) BOOL combineTimeWithNameLabel; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index bf9d3fb7..d581b3f6 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -68,6 +68,7 @@ @implementation BConfiguration @synthesize messageBubbleMaskMiddle; @synthesize messageBubbleMaskLast; @synthesize messageBubbleMaskSingle; +@synthesize hideNameLabel; @synthesize nameLabelPosition; @synthesize combineTimeWithNameLabel; diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index ccc94a03..9ea39921 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -48,12 +48,13 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr if(BChatSDK.config.messageTimeFont) { _timeLabel.font = BChatSDK.config.messageTimeFont; } - + _timeLabel.textColor = [UIColor lightGrayColor]; + _timeLabel.userInteractionEnabled = NO; [self.contentView addSubview:_timeLabel]; - + _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)]; _nameLabel.userInteractionEnabled = NO; @@ -62,7 +63,7 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr _nameLabel.font = BChatSDK.config.messageNameFont; } [self.contentView addSubview:_nameLabel]; - + _readMessageImageView = [[UIImageView alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)]; [self setReadStatus:bMessageReadStatusNone]; [self.contentView addSubview:_readMessageImageView]; @@ -184,12 +185,15 @@ -(void) setMessage: (id) message withColorWeight: (float) colorWeig _nameLabel.text = _message.userModel.name; -// // // We only want to show the name label if the previous message was posted by someone else and if this is enabled in the thread // // Or if the message is mine... _nameLabel.hidden = ![BMessageCell showUserNameLabelForMessage:message atPosition:@(position)]; + if(BChatSDK.config.hideNameLabel) { + _nameLabel.hidden = BChatSDK.config.hideNameLabel; + } + // Hide the read receipt view if this is a public thread or if read receipts are disabled _readMessageImageView.hidden = _message.thread.type.intValue & bThreadFilterPublic || !BChatSDK.readReceipt;