Configure attributed text for room creation event and for multiple events

This commit is contained in:
ismailgulek
2020-09-14 14:12:14 +03:00
parent c1b0ed423a
commit d31dfd0319
+25 -2
View File
@@ -180,7 +180,7 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
}
else
{
return nil;
return [super attributedStringFromEvent:event withRoomState:roomState error:error];
}
}
@@ -260,7 +260,30 @@ static NSString *const kEventFormatterTimeFormat = @"HH:mm";
if (events.count)
{
if (events[0].eventType == MXEventTypeRoomMember)
MXEvent *roomCreateEvent = [events filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"type == %@", kMXEventTypeStringRoomCreate]].firstObject;
if (roomCreateEvent)
{
MXKEventFormatterError tmpError;
displayText = [super attributedStringFromEvent:roomCreateEvent withRoomState:roomState error:&tmpError].string;
NSAttributedString *rendered = [self renderString:displayText forEvent:roomCreateEvent];
NSMutableAttributedString *result = [[NSMutableAttributedString alloc] initWithAttributedString:rendered];
[result setAttributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:13],
NSForegroundColorAttributeName: ThemeService.shared.theme.textSecondaryColor
} range:NSMakeRange(0, rendered.length)];
// add one char space
[result appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
// add more link
NSAttributedString *linkMore = [[NSAttributedString alloc] initWithString:@"More" attributes:@{
NSFontAttributeName: [UIFont systemFontOfSize:13],
NSForegroundColorAttributeName: ThemeService.shared.theme.tintColor
}];
[result appendAttributedString:linkMore];
return result;
}
else if (events[0].eventType == MXEventTypeRoomMember)
{
// This is a series for cells tagged with RoomBubbleCellDataTagMembership
// TODO: Build a complete summary like Riot-web