Skip to content

Commit a474e3e

Browse files
committed
Change announcement type from String to NSAttributedString
1 parent a26e58a commit a474e3e

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

Sources/Layout/AnnounceMessageSizeCalculator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ open class AnnouncementMessageSizeCalculator: MessageSizeCalculator {
6161

6262
switch message.kind {
6363
case .announcement(let text):
64-
attributedText = NSAttributedString(string: text, attributes: [.font: messageLabelFont])
64+
attributedText = text
6565
default:
6666
fatalError("messageContainerSize received unhandled MessageDataType: \(message.kind)")
6767
}

Sources/Models/MessageKind.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public enum MessageKind {
5858
case contact(ContactItem)
5959

6060
/// An announcement message.
61-
case announcement(String)
61+
case announcement(NSAttributedString)
6262

6363
/// A custom message.
6464
/// - Note: Using this case requires that you implement the following methods and handle this case:

Sources/Views/Cells/TextMessageCell.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,7 @@ open class TextMessageCell: MessageContentCell {
7979
switch message.kind {
8080
case .announcement(let text):
8181
messageLabel.textAlignment = .center
82-
messageLabel.text = text
83-
84-
let textColor = displayDelegate.textColor(for: message, at: indexPath, in: messagesCollectionView)
85-
messageLabel.textColor = textColor
86-
87-
if let font = messageLabel.messageLabelFont {
88-
messageLabel.font = font
89-
}
82+
messageLabel.attributedText = text
9083
case .text(let text), .emoji(let text):
9184
messageLabel.textAlignment = .left
9285
messageLabel.text = text

0 commit comments

Comments
 (0)