From b4077beffcdf74b7ba64187fdeffdf5dcd77a03f Mon Sep 17 00:00:00 2001 From: Pepe Becker Date: Mon, 16 Apr 2018 16:18:15 +0100 Subject: [PATCH] Update ChatSDKUI --- .../Components/Message Cells/BMessageCell.m | 26 +++++++++---------- .../Components/Message Cells/BMessageLayout.h | 2 ++ .../Components/Message Cells/BMessageLayout.m | 10 +++++-- .../Threads/BPrivateThreadsViewController.h | 2 ++ .../Threads/BPublicThreadsViewController.h | 1 + 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index 12855de5..d64bf42e 100644 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -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; @@ -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]; @@ -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) { diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.h b/ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.h index ad001a2b..dfb04a00 100644 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.h +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.h @@ -11,6 +11,8 @@ #import #define bTimeLabelPadding 10 +#define bTimeLabelHeight 12 +#define bTimeLabelWidth 30 #define bMaxMessageWidth 200 #define bMaxMessageHeight 300 #define bMinMessageHeight 50 diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.m index 4396a4a3..ca8bfd8c 100644 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageLayout.m @@ -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: @@ -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 { diff --git a/ChatSDKUI/Classes/Components/Threads/BPrivateThreadsViewController.h b/ChatSDKUI/Classes/Components/Threads/BPrivateThreadsViewController.h index 6c9d7d11..9cf31c62 100644 --- a/ChatSDKUI/Classes/Components/Threads/BPrivateThreadsViewController.h +++ b/ChatSDKUI/Classes/Components/Threads/BPrivateThreadsViewController.h @@ -13,4 +13,6 @@ @interface BPrivateThreadsViewController : BThreadsViewController { } +-(void) createThread; + @end diff --git a/ChatSDKUI/Classes/Components/Threads/BPublicThreadsViewController.h b/ChatSDKUI/Classes/Components/Threads/BPublicThreadsViewController.h index e3423e12..62671b10 100644 --- a/ChatSDKUI/Classes/Components/Threads/BPublicThreadsViewController.h +++ b/ChatSDKUI/Classes/Components/Threads/BPublicThreadsViewController.h @@ -16,5 +16,6 @@ } -(instancetype) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil; +-(void) createThread; @end