mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-27 11:46:58 +02:00
Room details: use italic font for state events
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user