Compare commits

..

3 Commits

4 changed files with 67 additions and 26 deletions

View File

@ -471,34 +471,43 @@ static void * kJSQMessagesKeyValueObservingContext = &kJSQMessagesKeyValueObserv
cellIdentifier = self.callCellIndentifier;
JSQCallCollectionViewCell * callCell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
NSString *text = [call text];
NSString *dateText = [call dateText];
NSString *allText = [text stringByAppendingString:dateText];
NSString *text = call.date != nil ? [call text] : call.senderDisplayName;
NSString *allText = call.date != nil ? [text stringByAppendingString:[call dateText]] : text;
const CGFloat fontSize = 14;
UIFont *boldFont = [UIFont boldSystemFontOfSize:fontSize];
UIFont *regularFont = [UIFont systemFontOfSize:fontSize];
UIFont *boldFont = [UIFont fontWithName:@"HelveticaNeue-Medium" size:12.0f];
UIFont *regularFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:12.0f];
UIColor *foregroundColor = [UIColor whiteColor];
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
boldFont, NSFontAttributeName, nil];
NSDictionary *subAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:allText
attributes:attrs];
if([call date]!=nil) {
// Not a group meta message
NSDictionary *subAttrs = [NSDictionary dictionaryWithObjectsAndKeys:
regularFont, NSFontAttributeName, nil];
const NSRange range = NSMakeRange([text length],[dateText length]);
NSMutableAttributedString *attributedText =
[[NSMutableAttributedString alloc] initWithString:allText
attributes:attrs];
[attributedText setAttributes:subAttrs range:range];
callCell.cellLabel.attributedText = attributedText;
callCell.cellLabel.textColor = [UIColor colorWithRed:32.f/255.f green:144.f/255.f blue:234.f/255.f alpha:1.f];
BOOL isOutgoing = [self.senderId isEqualToString:call.senderId];
if (isOutgoing)
{
callCell.outgoingCallImageView.image = [call thumbnailImage];
} else {
const NSRange range = NSMakeRange([text length],[[call dateText] length]);
[attributedText setAttributes:subAttrs range:range];
BOOL isOutgoing = [self.senderId isEqualToString:call.senderId];
if (isOutgoing)
{
callCell.outgoingCallImageView.image = [call thumbnailImage];
} else {
callCell.incomingCallImageView.image = [call thumbnailImage];
}
}
else {
// A group meta message
callCell.incomingCallImageView.image = [call thumbnailImage];
}
callCell.cellLabel.attributedText = attributedText;
callCell.cellLabel.lineBreakMode = UILineBreakModeWordWrap;
callCell.cellLabel.numberOfLines = 0; // uses as many lines as it needs
callCell.cellLabel.textColor = [UIColor colorWithRed:32.f/255.f green:144.f/255.f blue:234.f/255.f alpha:1.f];
callCell.layer.shouldRasterize = YES;
callCell.layer.rasterizationScale = [UIScreen mainScreen].scale;
return callCell;

View File

@ -13,9 +13,13 @@ typedef enum : NSUInteger {
kCallOutgoing = 1,
kCallIncoming = 2,
kCallMissed = 3,
kGroupUpdateJoin = 4,
kGroupUpdateLeft = 5,
kGroupUpdate = 6
} CallStatus;
@interface JSQCall : NSObject <JSQMessageData, NSCoding, NSCopying>
/*
@ -45,6 +49,11 @@ typedef enum : NSUInteger {
*/
@property (nonatomic) TSMessageAdapterType messageType;
/*
* User can configure whether a thumbnail is used in the display of this cell or not
*/
@property (nonatomic) BOOL useThumbnail;
#pragma mark - Initialization

View File

@ -21,7 +21,6 @@
{
NSParameterAssert(senderId != nil);
NSParameterAssert(senderDisplayName != nil);
NSParameterAssert(date != nil);
self = [super init];
if (self) {
@ -74,11 +73,35 @@
return [dateFormatter stringFromDate:_date];
}
-(UIImage*)thumbnailImage
{
return nil;
-(UIImage*)thumbnailImage {
// This relies on those assets being in the project
if(!_useThumbnail) {
return nil;
}
switch (_status) {
case kCallOutgoing:
return [UIImage imageNamed:@"statCallOutgoing--blue"];
break;
case kCallIncoming:
case kCallMissed:
return [UIImage imageNamed:@"statCallIncoming--blue"];
break;
case kGroupUpdate:
return [UIImage imageNamed:@"statRefreshedGroup--blue"];
break;
case kGroupUpdateLeft:
return [UIImage imageNamed:@"statLeftGroup--blue"];
break;
case kGroupUpdateJoin:
return [UIImage imageNamed:@"statJoinedGroup--blue"];
break;
default:
return nil;
break;
}
}
#pragma mark - NSObject
-(BOOL)isEqual:(id)object

View File

@ -9,8 +9,8 @@
#import "JSQMessagesLabel.h"
#define kCallCellHeight 20.0f
#define kCallCellWidth 200.0f
#define kCallCellHeight 40.0f
#define kCallCellWidth 400.0f
@interface JSQCallCollectionViewCell : UICollectionViewCell