Add a convenience method on MXKRoomBubbleTableViewCell Riot category to update the color name based on the sender id.

This commit is contained in:
SBiOSoftWhare 2019-03-07 17:44:15 +01:00
parent fb3804e5f4
commit f401f31021
2 changed files with 31 additions and 0 deletions

View file

@ -68,6 +68,11 @@ extern NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer;
*/
- (IBAction)onReceiptContainerTap:(UITapGestureRecognizer *)sender;
/**
Update username label color based on bubble data sender ID.
*/
- (void)updateUserNameColor;
/**
Blur the view by adding a transparent overlay. Default is NO.
*/

View file

@ -386,6 +386,32 @@ NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer = @"kMXKRoomBubbleCellT
return objc_getAssociatedObject(self, @selector(markerView));
}
- (void)updateUserNameColor
{
static UserNameColorGenerator *userNameColorGenerator;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
userNameColorGenerator = [UserNameColorGenerator new];
});
id<Theme> theme = ThemeService.shared.theme;
userNameColorGenerator.defaultColor = theme.textPrimaryColor;
userNameColorGenerator.userNameColors = theme.userNameColors;
NSString *senderId = self.bubbleData.senderId;
if (senderId)
{
self.userNameLabel.textColor = [userNameColorGenerator colorFrom:senderId];
}
else
{
self.userNameLabel.textColor = userNameColorGenerator.defaultColor;
}
}
#pragma mark - User actions
- (IBAction)onEditButtonPressed:(id)sender