diff --git a/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m b/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m index 6339a51b4..fe69086ae 100644 --- a/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m +++ b/Riot/Modules/GlobalSearch/Messages/DataSources/HomeMessagesSearchDataSource.m @@ -66,7 +66,10 @@ if (cellData) { // Highlight the search pattern - [cellData highlightPatternInTextMessage:self.searchText withForegroundColor:ThemeService.shared.theme.tintColor andFont:patternFont]; + [cellData highlightPatternInTextMessage:self.searchText + withBackgroundColor:[UIColor clearColor] + foregroundColor:ThemeService.shared.theme.tintColor + andFont:patternFont]; // Use profile information as data to display MXSearchUserProfile *userProfile = result.context.profileInfo[result.result.sender]; diff --git a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellData.h b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellData.h index e63d2f586..cd76e39f8 100644 --- a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellData.h +++ b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellData.h @@ -50,7 +50,8 @@ The optional text pattern to be highlighted in the body of the message. */ NSString *highlightedPattern; - UIColor *highlightedPatternColor; + UIColor *highlightedPatternForegroundColor; + UIColor *highlightedPatternBackgroundColor; UIFont *highlightedPatternFont; } diff --git a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellData.m b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellData.m index b435b2f9d..0fe6bf0e0 100644 --- a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellData.m +++ b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellData.m @@ -351,10 +351,14 @@ return customAttributedTextMsg; } -- (void)highlightPatternInTextMessage:(NSString*)pattern withForegroundColor:(UIColor*)patternColor andFont:(UIFont*)patternFont +- (void)highlightPatternInTextMessage:(NSString*)pattern + withBackgroundColor:(UIColor *)backgroundColor + foregroundColor:(UIColor*)foregroundColor + andFont:(UIFont*)patternFont { highlightedPattern = pattern; - highlightedPatternColor = patternColor; + highlightedPatternBackgroundColor = backgroundColor; + highlightedPatternForegroundColor = foregroundColor; highlightedPatternFont = patternFont; // Indicate that the text message layout should be recomputed. @@ -889,10 +893,16 @@ while (range.location != NSNotFound) { - if (highlightedPatternColor) + if (highlightedPatternBackgroundColor) + { + // Update background color + [customAttributedTextMsg addAttribute:NSBackgroundColorAttributeName value:highlightedPatternBackgroundColor range:range]; + } + + if (highlightedPatternForegroundColor) { // Update text color - [customAttributedTextMsg addAttribute:NSForegroundColorAttributeName value:highlightedPatternColor range:range]; + [customAttributedTextMsg addAttribute:NSForegroundColorAttributeName value:highlightedPatternForegroundColor range:range]; } if (highlightedPatternFont) diff --git a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellDataStoring.h b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellDataStoring.h index 06b1584c4..53b96037c 100644 --- a/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellDataStoring.h +++ b/Riot/Modules/MatrixKit/Models/Room/MXKRoomBubbleCellDataStoring.h @@ -269,10 +269,14 @@ Update the event because its sent state changed or it is has been redacted. Highlight all the occurrences of a pattern in the resulting message body 'attributedTextMessage'. @param pattern the text pattern to highlight. - @param patternColor optional text color (the pattern text color is unchanged if nil). + @param backgroundColor optional text background color (the patterns background color is unchanged if nil) + @param foregroundColor optional text color (the pattern text color is unchanged if nil). @param patternFont optional text font (the pattern font is unchanged if nil). */ -- (void)highlightPatternInTextMessage:(NSString*)pattern withForegroundColor:(UIColor*)patternColor andFont:(UIFont*)patternFont; +- (void)highlightPatternInTextMessage:(NSString*)pattern + withBackgroundColor:(UIColor *)backgroundColor + foregroundColor:(UIColor*)foregroundColor + andFont:(UIFont*)patternFont; /** Refresh the sender flair information diff --git a/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m b/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m index 81d938e33..58e80961e 100644 --- a/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m +++ b/Riot/Modules/Room/Search/DataSources/RoomSearchDataSource.m @@ -69,7 +69,10 @@ if (cellData) { // Highlight the search pattern - [cellData highlightPatternInTextMessage:self.searchText withForegroundColor:ThemeService.shared.theme.tintColor andFont:patternFont]; + [cellData highlightPatternInTextMessage:self.searchText + withBackgroundColor:[UIColor clearColor] + foregroundColor:ThemeService.shared.theme.tintColor + andFont:patternFont]; // Use profile information as data to display MXSearchUserProfile *userProfile = result.context.profileInfo[result.result.sender];