Compare commits

...

6 Commits

Author SHA1 Message Date
Joyce Yan
5218c5fa05 minor tweaks 2015-01-23 18:49:25 -10:00
Joyce Yan
8341455a77 off by one error 2015-01-23 18:40:38 -10:00
Joyce Yan
6a83e93f7f nil terminated dict 2015-01-23 18:37:49 -10:00
Joyce Yan
459f07aa55 nsattributedstring 2015-01-23 18:33:50 -10:00
Joyce Yan
f6ce71a1e0 blue text, no icon 2015-01-23 18:20:18 -10:00
Joyce Yan
a5c8b56e63 test 2015-01-23 18:16:42 -10:00
3 changed files with 36 additions and 22 deletions

View File

@ -470,11 +470,26 @@ static void * kJSQMessagesKeyValueObservingContext = &kJSQMessagesKeyValueObserv
JSQCall * call = (JSQCall*)messageItem;
cellIdentifier = self.callCellIndentifier;
JSQCallCollectionViewCell * callCell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
callCell.cellLabel.text = [call text];
if (call.status == kCallMissed)
{
callCell.cellLabel.textColor = [UIColor redColor];
}
NSString *text = [call text];
NSString *dateText = [call dateText];
NSString *allText = [text stringByAppendingString:dateText];
const CGFloat fontSize = 14;
UIFont *boldFont = [UIFont boldSystemFontOfSize:fontSize];
UIFont *regularFont = [UIFont systemFontOfSize:fontSize];
UIColor *foregroundColor = [UIColor whiteColor];
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
boldFont, NSFontAttributeName, nil];
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)

View File

@ -54,6 +54,7 @@ typedef enum : NSUInteger {
status:(CallStatus)status;
-(NSString*)text;
-(NSString*)dateText;
-(UIImage*)thumbnailImage;

View File

@ -50,35 +50,33 @@
-(NSString*)text
{
NSString *name = _senderDisplayName;
switch (self.status) {
case kCallMissed:
return [NSString stringWithFormat:@"You missed a call from %@.", _senderDisplayName];
return [NSString stringWithFormat:@"Missed call from %@. ", name];
case kCallIncoming:
return [NSString stringWithFormat:@"You received a call from %@.", _senderDisplayName];
return [NSString stringWithFormat:@"You received a call from %@. ", name];
case kCallOutgoing:
return [NSString stringWithFormat:@"You called %@.", _senderDisplayName];
return [NSString stringWithFormat:@"You called %@. ", name];
default:
return nil;
break;
}
}
-(NSString*)dateText
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterMediumStyle;
dateFormatter.doesRelativeDateFormatting = YES;
return [dateFormatter stringFromDate:_date];
}
-(UIImage*)thumbnailImage
{
switch (self.status) {
case kCallMissed:
return [UIImage imageNamed:@"call_missed"];
break;
case kCallIncoming:
return [[UIImage imageNamed:@"call_incoming"] jsq_imageMaskedWithColor:[UIColor darkGrayColor]];
break;
case kCallOutgoing:
return [[UIImage imageNamed:@"call_outgoing"] jsq_imageMaskedWithColor:[UIColor darkGrayColor]];
break;
default:
return nil;
break;
}
return nil;
}
#pragma mark - NSObject