From ed80c1922eab2a290f90ea47a08275db60c0441b Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 7 Mar 2019 17:32:10 +0100 Subject: [PATCH 1/6] Add a custom hash method on String same as Riot Web --- Riot/Categories/Character.swift | 23 +++++++++++++++++++++++ Riot/Categories/String.swift | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 Riot/Categories/Character.swift create mode 100644 Riot/Categories/String.swift diff --git a/Riot/Categories/Character.swift b/Riot/Categories/Character.swift new file mode 100644 index 000000000..50ef89114 --- /dev/null +++ b/Riot/Categories/Character.swift @@ -0,0 +1,23 @@ +/* + Copyright 2019 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import Foundation + +extension Character { + var vc_unicodeScalarCodePoint: UInt32 { + return self.unicodeScalars[self.unicodeScalars.startIndex].value + } +} diff --git a/Riot/Categories/String.swift b/Riot/Categories/String.swift new file mode 100644 index 000000000..c492e71dd --- /dev/null +++ b/Riot/Categories/String.swift @@ -0,0 +1,32 @@ +/* + Copyright 2019 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import Foundation + +extension String { + + /// Calculates a numeric hash same as Riot Web + /// See original function here https://github.com/matrix-org/matrix-react-sdk/blob/321dd49db4fbe360fc2ff109ac117305c955b061/src/utils/FormattingUtils.js#L47 + var vc_hashCode: Int32 { + var hash: Int32 = 0 + + for character in self { + let shiftedHash = hash << 5 + hash = shiftedHash.subtractingReportingOverflow(hash).partialValue + Int32(character.vc_unicodeScalarCodePoint) + } + return abs(hash) + } +} From 9287699a254f42d5454638bac9ba56852041cd55 Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 7 Mar 2019 17:33:52 +0100 Subject: [PATCH 2/6] Add user name colors property on Theme. Used for user name color generation. --- Riot/Managers/Theme/Theme.swift | 3 ++- Riot/Managers/Theme/Themes/DarkTheme.swift | 11 +++++++++++ Riot/Managers/Theme/Themes/DefaultTheme.swift | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Riot/Managers/Theme/Theme.swift b/Riot/Managers/Theme/Theme.swift index 8ead5dbbe..375dd3913 100644 --- a/Riot/Managers/Theme/Theme.swift +++ b/Riot/Managers/Theme/Theme.swift @@ -50,7 +50,8 @@ import UIKit var warningColor: UIColor { get } var avatarColors: [UIColor] { get } - + + var userNameColors: [UIColor] { get } // MARK: - Appearance and style diff --git a/Riot/Managers/Theme/Themes/DarkTheme.swift b/Riot/Managers/Theme/Themes/DarkTheme.swift index a3e6d1c5f..1b3651a6e 100644 --- a/Riot/Managers/Theme/Themes/DarkTheme.swift +++ b/Riot/Managers/Theme/Themes/DarkTheme.swift @@ -51,6 +51,17 @@ class DarkTheme: NSObject, Theme { UIColor(rgb: 0x03B381), UIColor(rgb: 0x368BD6), UIColor(rgb: 0xAC3BA8)] + + var userNameColors: [UIColor] = [ + UIColor(rgb: 0x368BD6), + UIColor(rgb: 0xAC3BA8), + UIColor(rgb: 0x03B381), + UIColor(rgb: 0xE64F7A), + UIColor(rgb: 0xFF812D), + UIColor(rgb: 0x2DC2C5), + UIColor(rgb: 0x5C56F5), + UIColor(rgb: 0x74D12C) + ] var statusBarStyle: UIStatusBarStyle = .lightContent var scrollBarStyle: UIScrollView.IndicatorStyle = .white diff --git a/Riot/Managers/Theme/Themes/DefaultTheme.swift b/Riot/Managers/Theme/Themes/DefaultTheme.swift index d2490640d..d1bcaf9f8 100644 --- a/Riot/Managers/Theme/Themes/DefaultTheme.swift +++ b/Riot/Managers/Theme/Themes/DefaultTheme.swift @@ -51,6 +51,17 @@ class DefaultTheme: NSObject, Theme { UIColor(rgb: 0x03B381), UIColor(rgb: 0x368BD6), UIColor(rgb: 0xAC3BA8)] + + var userNameColors: [UIColor] = [ + UIColor(rgb: 0x368BD6), + UIColor(rgb: 0xAC3BA8), + UIColor(rgb: 0x03B381), + UIColor(rgb: 0xE64F7A), + UIColor(rgb: 0xFF812D), + UIColor(rgb: 0x2DC2C5), + UIColor(rgb: 0x5C56F5), + UIColor(rgb: 0x74D12C) + ] var statusBarStyle: UIStatusBarStyle = .lightContent var scrollBarStyle: UIScrollView.IndicatorStyle = .default From 28b28eda0a11efa62b5b4b3abd159f821bcba807 Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 7 Mar 2019 17:36:40 +0100 Subject: [PATCH 3/6] Create UserNameColorGenerator used to generate a user name color from user id --- Riot.xcodeproj/project.pbxproj | 18 +++++++++ Riot/Utils/UserNameColorGenerator.swift | 50 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 Riot/Utils/UserNameColorGenerator.swift diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index aba1424ef..f4f6d4f54 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -380,6 +380,12 @@ B1D4752821EE4E630067973F /* KeyboardNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D4752621EE4E620067973F /* KeyboardNotification.swift */; }; B1D4752A21EE52B10067973F /* KeyBackupSetupIntroViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1D4752921EE52B10067973F /* KeyBackupSetupIntroViewController.swift */; }; B1D4752C21EE52C30067973F /* KeyBackupSetupIntroViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B1D4752B21EE52C30067973F /* KeyBackupSetupIntroViewController.storyboard */; }; + B1DB4F06223015080065DBFA /* Character.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB4F05223015080065DBFA /* Character.swift */; }; + B1DB4F0722301AF20065DBFA /* Character.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB4F05223015080065DBFA /* Character.swift */; }; + B1DB4F0B223131600065DBFA /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB4F0A223131600065DBFA /* String.swift */; }; + B1DB4F0C2231494F0065DBFA /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB4F0A223131600065DBFA /* String.swift */; }; + B1DB4F0E22316FFF0065DBFA /* UserNameColorGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB4F0D22316FFF0065DBFA /* UserNameColorGenerator.swift */; }; + B1DB4F0F223170000065DBFA /* UserNameColorGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DB4F0D22316FFF0065DBFA /* UserNameColorGenerator.swift */; }; B1E5368921FB1E20001F3AFF /* UIButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1E5368821FB1E20001F3AFF /* UIButton.swift */; }; B1E5368D21FB7245001F3AFF /* KeyBackupRecoverFromPassphraseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1E5368C21FB7245001F3AFF /* KeyBackupRecoverFromPassphraseViewController.swift */; }; B1E5368F21FB7258001F3AFF /* KeyBackupRecoverFromPassphraseViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B1E5368E21FB7258001F3AFF /* KeyBackupRecoverFromPassphraseViewController.storyboard */; }; @@ -1036,6 +1042,9 @@ B1D4752621EE4E620067973F /* KeyboardNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardNotification.swift; sourceTree = ""; }; B1D4752921EE52B10067973F /* KeyBackupSetupIntroViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyBackupSetupIntroViewController.swift; sourceTree = ""; }; B1D4752B21EE52C30067973F /* KeyBackupSetupIntroViewController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = KeyBackupSetupIntroViewController.storyboard; sourceTree = ""; }; + B1DB4F05223015080065DBFA /* Character.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Character.swift; sourceTree = ""; }; + B1DB4F0A223131600065DBFA /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = ""; }; + B1DB4F0D22316FFF0065DBFA /* UserNameColorGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNameColorGenerator.swift; sourceTree = ""; }; B1E5368821FB1E20001F3AFF /* UIButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIButton.swift; sourceTree = ""; }; B1E5368C21FB7245001F3AFF /* KeyBackupRecoverFromPassphraseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyBackupRecoverFromPassphraseViewController.swift; sourceTree = ""; }; B1E5368E21FB7258001F3AFF /* KeyBackupRecoverFromPassphraseViewController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = KeyBackupRecoverFromPassphraseViewController.storyboard; sourceTree = ""; }; @@ -2857,6 +2866,8 @@ B1E5368821FB1E20001F3AFF /* UIButton.swift */, 3281BCF62201FA4200F4A383 /* UIControl.swift */, B109D6F0222D8C400061B6D9 /* UIApplication.swift */, + B1DB4F05223015080065DBFA /* Character.swift */, + B1DB4F0A223131600065DBFA /* String.swift */, ); path = Categories; sourceTree = ""; @@ -2890,6 +2901,7 @@ F083BC131E7009EC00A9B29C /* EventFormatter.m */, F083BC141E7009EC00A9B29C /* Tools.h */, F083BC151E7009EC00A9B29C /* Tools.m */, + B1DB4F0D22316FFF0065DBFA /* UserNameColorGenerator.swift */, ); path = Utils; sourceTree = ""; @@ -3417,9 +3429,11 @@ 32242F1621E8FBCC00725742 /* ThemeService.m in Sources */, 24EEE5A31F23A8C300B3C705 /* AvatarGenerator.m in Sources */, B1664BCF20F4E67600808783 /* ShareExtensionManager.m in Sources */, + B1DB4F0722301AF20065DBFA /* Character.swift in Sources */, 3209451321F1C1D50088CAA2 /* BlackTheme.swift in Sources */, 24EEE5A21F23A8B400B3C705 /* MXRoom+Riot.m in Sources */, B1664BC720F4E67600808783 /* SharePresentingViewController.m in Sources */, + B1DB4F0F223170000065DBFA /* UserNameColorGenerator.swift in Sources */, F0A8955F1F7D1FEA00BD6C2A /* MXRoomSummary+Riot.m in Sources */, 32242F1721E8FBE500725742 /* Theme.swift in Sources */, B169328320F38AE600746532 /* RiotSettings.swift in Sources */, @@ -3427,6 +3441,7 @@ 32242F1921E8FBFB00725742 /* DarkTheme.swift in Sources */, B1664BC820F4E67600808783 /* ShareDataSource.m in Sources */, B1664BCD20F4E67600808783 /* RecentRoomTableViewCell.m in Sources */, + B1DB4F0C2231494F0065DBFA /* String.swift in Sources */, B169331720F3CBE000746532 /* RecentCellData.m in Sources */, B1664BCC20F4E67600808783 /* RoomsListViewController.m in Sources */, ); @@ -3459,6 +3474,7 @@ B169330820F3CA0E00746532 /* ContactsDataSource.m in Sources */, B1B5574B20EE6C4D00210D55 /* MediaAlbumContentViewController.m in Sources */, B1B5598820EFC3E000210D55 /* WidgetManager.m in Sources */, + B1DB4F0E22316FFF0065DBFA /* UserNameColorGenerator.swift in Sources */, B1057789221304EC00334B1E /* KeyBackupSetupSuccessFromPassphraseViewController.swift in Sources */, B16932B120F3AC9200746532 /* RoomSearchDataSource.m in Sources */, B16932A320F3A21C00746532 /* main.m in Sources */, @@ -3666,6 +3682,7 @@ 32BF994F21FA29A400698084 /* SettingsKeyBackupViewModel.swift in Sources */, B1B5574920EE6C4D00210D55 /* RiotSplitViewController.m in Sources */, B1B5574E20EE6C4D00210D55 /* DirectoryServerPickerViewController.m in Sources */, + B1DB4F0B223131600065DBFA /* String.swift in Sources */, B1B5575B20EE6C4D00210D55 /* HomeFilesSearchViewController.m in Sources */, B139C22521FF01C100BB68EC /* KeyBackupRecoverFromPassphraseCoordinator.swift in Sources */, B1098BFD21ECFE65000DDA48 /* PasswordStrengthManager.swift in Sources */, @@ -3680,6 +3697,7 @@ B1B558FF20EF768F00210D55 /* RoomIncomingTextMsgBubbleCell.m in Sources */, B1098C0021ECFE65000DDA48 /* KeyBackupSetupPassphraseViewController.swift in Sources */, B1B5591020EF782800210D55 /* TableViewCellWithPhoneNumberTextField.m in Sources */, + B1DB4F06223015080065DBFA /* Character.swift in Sources */, B14F143022144F6500FA0595 /* KeyBackupRecoverFromRecoveryKeyCoordinatorType.swift in Sources */, B1E5368921FB1E20001F3AFF /* UIButton.swift in Sources */, ); diff --git a/Riot/Utils/UserNameColorGenerator.swift b/Riot/Utils/UserNameColorGenerator.swift new file mode 100644 index 000000000..3e5c2adcd --- /dev/null +++ b/Riot/Utils/UserNameColorGenerator.swift @@ -0,0 +1,50 @@ +/* + Copyright 2019 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +import Foundation +import UIKit + +/// Generate a user name color from user id +@objcMembers +final class UserNameColorGenerator: NSObject { + + // MARK: - Properties + + /// User name colors. + var userNameColors: [UIColor] = [] + + /// Fallback color when `userNameColors` is empty. + var defaultColor: UIColor = .black + + // MARK: - Public + + /// Generate a user name color from the user ID. + /// + /// - Parameter userId: The user ID of the user. + /// - Returns: A color associated to the user ID. + func color(from userId: String) -> UIColor { + guard self.userNameColors.isEmpty == false else { + return self.defaultColor + } + + guard userId.isEmpty == false else { + return self.userNameColors[0] + } + + let senderNameColorIndex = Int(userId.vc_hashCode % Int32(self.userNameColors.count)) + return self.userNameColors[senderNameColorIndex] + } +} From 5407e0e85164aaaf9cb0bfa3f5876854cf72c718 Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 7 Mar 2019 17:44:15 +0100 Subject: [PATCH 4/6] Add a convenience method on `MXKRoomBubbleTableViewCell` Riot category to update the color name based on the sender id. --- .../MXKRoomBubbleTableViewCell+Riot.h | 5 ++++ .../MXKRoomBubbleTableViewCell+Riot.m | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.h b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.h index 7967ba35e..5162457f2 100644 --- a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.h +++ b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.h @@ -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. */ diff --git a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m index 92e6044b6..2e025b1ac 100644 --- a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m +++ b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m @@ -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 = 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 From f45cd824a1252b777374a44fc9a9653d6338e7a7 Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 7 Mar 2019 17:46:45 +0100 Subject: [PATCH 5/6] Apply new user name color generation on bubble cells where needed --- .../Views/MessagesSearchResultAttachmentBubbleCell.m | 7 +++++-- .../Views/MessagesSearchResultTextMsgBubbleCell.m | 5 ++++- .../BubbleCells/RoomIncomingAttachmentBubbleCell.m | 11 ++++++++++- ...IncomingAttachmentWithPaginationTitleBubbleCell.m | 6 ++++-- .../BubbleCells/RoomIncomingTextMsgBubbleCell.m | 11 ++++++++++- ...oomIncomingTextMsgWithPaginationTitleBubbleCell.m | 6 ++++-- .../BubbleCells/RoomOutgoingAttachmentBubbleCell.m | 5 ++++- ...OutgoingAttachmentWithPaginationTitleBubbleCell.m | 5 +++-- .../BubbleCells/RoomOutgoingTextMsgBubbleCell.m | 12 +++++++++++- 9 files changed, 55 insertions(+), 13 deletions(-) diff --git a/Riot/Modules/GlobalSearch/Messages/Views/MessagesSearchResultAttachmentBubbleCell.m b/Riot/Modules/GlobalSearch/Messages/Views/MessagesSearchResultAttachmentBubbleCell.m index 2423473ed..a7e22ae4b 100644 --- a/Riot/Modules/GlobalSearch/Messages/Views/MessagesSearchResultAttachmentBubbleCell.m +++ b/Riot/Modules/GlobalSearch/Messages/Views/MessagesSearchResultAttachmentBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation MessagesSearchResultAttachmentBubbleCell @@ -26,11 +27,11 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; - self.roomNameLabel.textColor = ThemeService.shared.theme.textSecondaryColor; self.messageTextView.tintColor = ThemeService.shared.theme.tintColor; + + [self updateUserNameColor]; } - (void)render:(MXKCellData *)cellData @@ -52,6 +53,8 @@ { self.roomNameLabel.text = bubbleData.roomId; } + + [self updateUserNameColor]; } } diff --git a/Riot/Modules/GlobalSearch/Messages/Views/MessagesSearchResultTextMsgBubbleCell.m b/Riot/Modules/GlobalSearch/Messages/Views/MessagesSearchResultTextMsgBubbleCell.m index ea0e14502..3a29ef6b1 100644 --- a/Riot/Modules/GlobalSearch/Messages/Views/MessagesSearchResultTextMsgBubbleCell.m +++ b/Riot/Modules/GlobalSearch/Messages/Views/MessagesSearchResultTextMsgBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation MessagesSearchResultTextMsgBubbleCell @@ -26,7 +27,7 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + [self updateUserNameColor]; self.roomNameLabel.textColor = ThemeService.shared.theme.textSecondaryColor; @@ -48,6 +49,8 @@ { self.roomNameLabel.text = bubbleData.roomId; } + + [self updateUserNameColor]; } } diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomIncomingAttachmentBubbleCell.m b/Riot/Modules/Room/Views/BubbleCells/RoomIncomingAttachmentBubbleCell.m index ba01ef0b5..00018fb4d 100644 --- a/Riot/Modules/Room/Views/BubbleCells/RoomIncomingAttachmentBubbleCell.m +++ b/Riot/Modules/Room/Views/BubbleCells/RoomIncomingAttachmentBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation RoomIncomingAttachmentBubbleCell @@ -26,8 +27,16 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + [self updateUserNameColor]; + self.messageTextView.tintColor = ThemeService.shared.theme.tintColor; } +- (void)render:(MXKCellData *)cellData +{ + [super render:cellData]; + + [self updateUserNameColor]; +} + @end diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomIncomingAttachmentWithPaginationTitleBubbleCell.m b/Riot/Modules/Room/Views/BubbleCells/RoomIncomingAttachmentWithPaginationTitleBubbleCell.m index 8686be688..519bff872 100644 --- a/Riot/Modules/Room/Views/BubbleCells/RoomIncomingAttachmentWithPaginationTitleBubbleCell.m +++ b/Riot/Modules/Room/Views/BubbleCells/RoomIncomingAttachmentWithPaginationTitleBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation RoomIncomingAttachmentWithPaginationTitleBubbleCell @@ -26,8 +27,7 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; - + [self updateUserNameColor]; self.paginationLabel.textColor = ThemeService.shared.theme.tintColor; self.paginationSeparatorView.backgroundColor = ThemeService.shared.theme.tintColor; self.messageTextView.tintColor = ThemeService.shared.theme.tintColor; @@ -40,6 +40,8 @@ if (bubbleData) { self.paginationLabel.text = [[bubbleData.eventFormatter dateStringFromDate:bubbleData.date withTime:NO] uppercaseString]; + + [self updateUserNameColor]; } } diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomIncomingTextMsgBubbleCell.m b/Riot/Modules/Room/Views/BubbleCells/RoomIncomingTextMsgBubbleCell.m index 605d9e9a3..d308fcfea 100644 --- a/Riot/Modules/Room/Views/BubbleCells/RoomIncomingTextMsgBubbleCell.m +++ b/Riot/Modules/Room/Views/BubbleCells/RoomIncomingTextMsgBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation RoomIncomingTextMsgBubbleCell @@ -26,8 +27,16 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + [self updateUserNameColor]; + self.messageTextView.tintColor = ThemeService.shared.theme.tintColor; } +- (void)render:(MXKCellData *)cellData +{ + [super render:cellData]; + + [self updateUserNameColor]; +} + @end diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomIncomingTextMsgWithPaginationTitleBubbleCell.m b/Riot/Modules/Room/Views/BubbleCells/RoomIncomingTextMsgWithPaginationTitleBubbleCell.m index 83bff1cf7..2e8bdeb34 100644 --- a/Riot/Modules/Room/Views/BubbleCells/RoomIncomingTextMsgWithPaginationTitleBubbleCell.m +++ b/Riot/Modules/Room/Views/BubbleCells/RoomIncomingTextMsgWithPaginationTitleBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation RoomIncomingTextMsgWithPaginationTitleBubbleCell @@ -26,8 +27,7 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; - + [self updateUserNameColor]; self.paginationLabel.textColor = ThemeService.shared.theme.tintColor; self.paginationSeparatorView.backgroundColor = ThemeService.shared.theme.tintColor; self.messageTextView.tintColor = ThemeService.shared.theme.tintColor; @@ -40,6 +40,8 @@ if (bubbleData) { self.paginationLabel.text = [[bubbleData.eventFormatter dateStringFromDate:bubbleData.date withTime:NO] uppercaseString]; + + [self updateUserNameColor]; } } diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingAttachmentBubbleCell.m b/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingAttachmentBubbleCell.m index bb786416a..a50ffe6c9 100644 --- a/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingAttachmentBubbleCell.m +++ b/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingAttachmentBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation RoomOutgoingAttachmentBubbleCell @@ -26,7 +27,8 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + [self updateUserNameColor]; + self.messageTextView.tintColor = ThemeService.shared.theme.tintColor; } @@ -34,6 +36,7 @@ { [super render:cellData]; + [self updateUserNameColor]; [RoomOutgoingAttachmentBubbleCell render:cellData inBubbleCell:self]; } diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m b/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m index 25911ddf2..bd4df0000 100644 --- a/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m +++ b/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingAttachmentWithPaginationTitleBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation RoomOutgoingAttachmentWithPaginationTitleBubbleCell @@ -26,8 +27,7 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; - + [self updateUserNameColor]; self.paginationLabel.textColor = ThemeService.shared.theme.tintColor; self.paginationSeparatorView.backgroundColor = ThemeService.shared.theme.tintColor; self.messageTextView.tintColor = ThemeService.shared.theme.tintColor; @@ -40,6 +40,7 @@ if (bubbleData) { self.paginationLabel.text = [[bubbleData.eventFormatter dateStringFromDate:bubbleData.date withTime:NO] uppercaseString]; + [self updateUserNameColor]; } } diff --git a/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingTextMsgBubbleCell.m b/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingTextMsgBubbleCell.m index bff6e2f13..374ed6da0 100644 --- a/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingTextMsgBubbleCell.m +++ b/Riot/Modules/Room/Views/BubbleCells/RoomOutgoingTextMsgBubbleCell.m @@ -19,6 +19,7 @@ #import "ThemeService.h" #import "Riot-Swift.h" +#import "MXKRoomBubbleTableViewCell+Riot.h" @implementation RoomOutgoingTextMsgBubbleCell @@ -26,8 +27,17 @@ { [super customizeTableViewCellRendering]; - self.userNameLabel.textColor = ThemeService.shared.theme.textPrimaryColor; + [self updateUserNameColor]; + self.messageTextView.tintColor = ThemeService.shared.theme.tintColor; } + +- (void)render:(MXKCellData *)cellData +{ + [super render:cellData]; + + [self updateUserNameColor]; +} + @end From c6cbb4fdf0734c7381ac476c6a2ebe443e454377 Mon Sep 17 00:00:00 2001 From: SBiOSoftWhare Date: Thu, 7 Mar 2019 17:51:39 +0100 Subject: [PATCH 6/6] Update changes --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index c7de5aec8..eb248eb88 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -13,6 +13,7 @@ Improvements: * Fix SWIFT_VERSION configuration in post install hook of Podfile (PR #2302). * Authentication: support SSO by using the fallback URL (#2307). * Authentication: .well-known support (#2117). + * Reskin: Colorise users displaynames (#2287). Bug fix: * Reskin: status bar text is no more readable on iPad (#2276).