mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Add a convenience method on MXKRoomBubbleTableViewCell
Riot category to update the color name based on the sender id.
This commit is contained in:
parent
fb3804e5f4
commit
f401f31021
2 changed files with 31 additions and 0 deletions
|
@ -68,6 +68,11 @@ extern NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer;
|
||||||
*/
|
*/
|
||||||
- (IBAction)onReceiptContainerTap:(UITapGestureRecognizer *)sender;
|
- (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.
|
Blur the view by adding a transparent overlay. Default is NO.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -386,6 +386,32 @@ NSString *const kMXKRoomBubbleCellTapOnReceiptsContainer = @"kMXKRoomBubbleCellT
|
||||||
return objc_getAssociatedObject(self, @selector(markerView));
|
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
|
#pragma mark - User actions
|
||||||
|
|
||||||
- (IBAction)onEditButtonPressed:(id)sender
|
- (IBAction)onEditButtonPressed:(id)sender
|
||||||
|
|
Loading…
Reference in a new issue