Skip to content
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

Move timestamp into message bubble #239

Open
wants to merge 1 commit 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
26 changes: 13 additions & 13 deletions ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr

[self.contentView addSubview:_profilePicture];

_timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)];
_timeLabel = [[UILabel alloc] initWithFrame:CGRectZero];

_timeLabel.font = [UIFont italicSystemFontOfSize:12];
if([BChatSDK config].messageTimeFont) {
_timeLabel.font = [BChatSDK config].messageTimeFont;
}

_timeLabel.textColor = [UIColor lightGrayColor];
_timeLabel.textColor = [UIColor grayColor];
_timeLabel.userInteractionEnabled = NO;

[self.contentView addSubview:_timeLabel];
[bubbleImageView addSubview:_timeLabel];

_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)];
_nameLabel.userInteractionEnabled = NO;
Expand Down Expand Up @@ -252,13 +252,11 @@ -(void) layoutSubviews {
// TODO: Fix this
float xMargin = _profilePicture.image ? 0 : 0;

// Layout the date label this will be the full size of the cell
// This will automatically center the text in the y direction
// we'll set the side using text alignment
[_timeLabel setViewFrameWidth:self.fw - bTimeLabelPadding * 2.0];
[_timeLabel setViewFrameWidth:l.bubbleWidth - l.bubblePadding * 2.0];
[_timeLabel.keepBottomInset setEqual:l.bubblePadding - 4];

// We don't want the label getting in the way of the read receipt
[_timeLabel setViewFrameHeight:l.cellHeight * 0.8];
[_timeLabel setViewFrameHeight:bTimeLabelHeight];

[_readMessageImageView setViewFrameWidth:bReadReceiptWidth];
[_readMessageImageView setViewFrameHeight:bReadReceiptHeight];
Expand All @@ -273,18 +271,20 @@ -(void) layoutSubviews {
if (!isMine) {
[_profilePicture setViewFrameX:_profilePicture.hidden ? 0 : l.profilePicturePadding];
[bubbleImageView setViewFrameX:l.bubbleMargin + _profilePicture.fx + _profilePicture.fw + xMargin];
[_nameLabel setViewFrameX:bTimeLabelPadding];
// [_nameLabel setViewFrameX:bTimeLabelPadding];
[_timeLabel.keepRightInset setEqual:l.bubblePadding];

_timeLabel.textAlignment = NSTextAlignmentRight;
_nameLabel.textAlignment = NSTextAlignmentLeft;
_timeLabel.textAlignment = NSTextAlignmentLeft;
// _nameLabel.textAlignment = NSTextAlignmentLeft;
}
else {
[_profilePicture setViewFrameX:_profilePicture.hidden ? self.contentView.fw : self.contentView.fw - _profilePicture.fw - l.profilePicturePadding];
[bubbleImageView setViewFrameX:_profilePicture.fx - l.bubbleWidth - l.bubbleMargin - xMargin];
//[_nameLabel setViewFrameX: bTimeLabelPadding];
[_timeLabel.keepRightInset setEqual:l.bubblePadding + bTailSize];

_timeLabel.textAlignment = NSTextAlignmentLeft;
_nameLabel.textAlignment = NSTextAlignmentRight;
_timeLabel.textAlignment = NSTextAlignmentRight;
// _nameLabel.textAlignment = NSTextAlignmentRight;

// // We need to make sure the time label isn't in the way if there is a users name
// if (self.fh < 50) {
Expand Down
2 changes: 2 additions & 0 deletions ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#import <ChatSDK/PMessageLayout.h>

#define bTimeLabelPadding 10
#define bTimeLabelHeight 12
#define bTimeLabelWidth 30
#define bMaxMessageWidth 200
#define bMaxMessageHeight 300
#define bMinMessageHeight 50
Expand Down
10 changes: 8 additions & 2 deletions ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ -(float) messageWidth {
switch ((bMessageType)_message.type.intValue) {
case bMessageTypeText:
case bMessageTypeSystem:
return MIN([self textWidth:_message.textString], bMaxMessageWidth);
return MAX(MIN([self textWidth:_message.textString], bMaxMessageWidth), bTimeLabelWidth);
case bMessageTypeImage:
case bMessageTypeVideo:
case bMessageTypeLocation:
Expand Down Expand Up @@ -83,7 +83,13 @@ -(float) textWidth: (NSString *) text {
}

-(float) bubbleHeight {
return self.messageHeight + /*[self cellMargin] + */self.bubblePadding * 2;
// return self.messageHeight + bTimeLabelHeight + /*[self cellMargin] + */self.bubblePadding * 2;
switch ((bMessageType)_message.type.intValue) {
case bMessageTypeText:
return self.messageHeight + bTimeLabelHeight + self.bubblePadding * 2;
default:
return self.messageHeight + self.bubblePadding * 2;
}
}

-(float) cellHeight {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
@interface BPrivateThreadsViewController : BThreadsViewController {
}

-(void) createThread;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
}

-(instancetype) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
-(void) createThread;

@end