Room details: use italic font for state events

This commit is contained in:
giomfo
2014-12-02 16:48:26 +01:00
parent b1d98a83d0
commit 390edac9d5
4 changed files with 55 additions and 44 deletions
+43 -6
View File
@@ -43,19 +43,21 @@ NSString *const kFailedEventId = @"failedEventId";
_date = nil;
}
// Set display mode
// Set style
BOOL isIncomingMsg = ([event.userId isEqualToString:mxHandler.userId] == NO);
if ([textMessage hasPrefix:kMatrixHandlerUnsupportedMessagePrefix]) {
_status = RoomMessageComponentStatusUnsupported;
_style = RoomMessageComponentStyleUnsupported;
} else if ([_eventId hasPrefix:kFailedEventId]) {
_status = RoomMessageComponentStatusFailed;
_style = RoomMessageComponentStyleFailed;
} else if (isIncomingMsg && ([textMessage rangeOfString:mxHandler.userDisplayName options:NSCaseInsensitiveSearch].location != NSNotFound || [textMessage rangeOfString:mxHandler.userId options:NSCaseInsensitiveSearch].location != NSNotFound)) {
_status = RoomMessageComponentStatusHighlighted;
_style = RoomMessageComponentStyleHighlighted;
} else if (!isIncomingMsg && [_eventId hasPrefix:kLocalEchoEventIdPrefix]) {
_status = RoomMessageComponentStatusInProgress;
_style = RoomMessageComponentStyleInProgress;
} else {
_status = RoomMessageComponentStatusNormal;
_style = RoomMessageComponentStyleDefault;
}
_isStateEvent = (event.eventType != MXEventTypeRoomMessage);
} else {
// Ignore this event
self = nil;
@@ -63,5 +65,40 @@ NSString *const kFailedEventId = @"failedEventId";
}
return self;
}
- (NSDictionary*)stringAttributes {
UIColor *textColor;
UIFont *font;
switch (_style) {
case RoomMessageComponentStyleDefault:
textColor = [UIColor blackColor];
break;
case RoomMessageComponentStyleHighlighted:
textColor = [UIColor blueColor];
break;
case RoomMessageComponentStyleInProgress:
textColor = [UIColor lightGrayColor];
break;
case RoomMessageComponentStyleFailed:
case RoomMessageComponentStyleUnsupported:
textColor = [UIColor redColor];
break;
default:
textColor = [UIColor blackColor];
break;
}
if (_isStateEvent) {
font = [UIFont italicSystemFontOfSize:14];
} else {
font = [UIFont systemFontOfSize:14];
}
return @{
NSForegroundColorAttributeName : textColor,
NSFontAttributeName: font
};
}
@end