Skip to content

Allow hiding of user's name for each message bubble #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChatSDKCore/Classes/Session/BConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,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;

Expand Down
1 change: 1 addition & 0 deletions ChatSDKCore/Classes/Session/BConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ @implementation BConfiguration
@synthesize messageBubbleMaskMiddle;
@synthesize messageBubbleMaskLast;
@synthesize messageBubbleMaskSingle;
@synthesize hideNameLabel;
@synthesize nameLabelPosition;
@synthesize combineTimeWithNameLabel;

Expand Down
9 changes: 6 additions & 3 deletions ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr
_timeLabel.userInteractionEnabled = NO;

[self.contentView addSubview:_timeLabel];

_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)];
_nameLabel.userInteractionEnabled = NO;

Expand All @@ -70,7 +70,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];
Expand Down Expand Up @@ -213,12 +213,15 @@ -(void) setMessage: (id<PElmMessage>) message isSelected: (BOOL) selected {

_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;

Expand Down