diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index db19662e36..6499d4b991 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -738,7 +738,7 @@ NS_ASSUME_NONNULL_BEGIN NSString *text = displayableText.displayText; NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; - paragraphStyle.alignment = text.naturalTextAlignment; + paragraphStyle.alignment = displayableText.displayTextNaturalAlignment; NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index 6398e64c27..c4f2739863 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -466,7 +466,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3; self.quotedTextLabel.numberOfLines = self.isForPreview ? 1 : 2; self.quotedTextLabel.lineBreakMode = NSLineBreakByTruncatingTail; self.quotedTextLabel.text = text; - self.quotedTextLabel.textAlignment = text.naturalTextAlignment; + self.quotedTextLabel.textAlignment = self.displayableQuotedText.displayTextNaturalAlignment; self.quotedTextLabel.textColor = textColor; self.quotedTextLabel.font = font; diff --git a/Signal/src/ViewControllers/LongTextViewController.swift b/Signal/src/ViewControllers/LongTextViewController.swift index 8529b78b02..891440991f 100644 --- a/Signal/src/ViewControllers/LongTextViewController.swift +++ b/Signal/src/ViewControllers/LongTextViewController.swift @@ -131,7 +131,7 @@ public class LongTextViewController: OWSViewController { messageTextView.textColor = Theme.primaryColor if let displayableText = displayableText { messageTextView.text = fullText - messageTextView.textAlignment = fullText.naturalTextAlignment + messageTextView.textAlignment = displayableText.fullTextNaturalAlignment messageTextView.ensureShouldLinkifyText(displayableText.shouldAllowLinkification) } else { owsFailDebug("displayableText was unexpectedly nil") diff --git a/SignalMessaging/utils/DisplayableText.swift b/SignalMessaging/utils/DisplayableText.swift index e7e72f87f5..9badc37548 100644 --- a/SignalMessaging/utils/DisplayableText.swift +++ b/SignalMessaging/utils/DisplayableText.swift @@ -7,7 +7,11 @@ import Foundation @objc public class DisplayableText: NSObject { @objc public let fullText: String + @objc public let fullTextNaturalAlignment: NSTextAlignment + @objc public let displayText: String + @objc public let displayTextNaturalAlignment: NSTextAlignment + @objc public let isTextTruncated: Bool @objc public let jumbomojiCount: UInt @@ -24,7 +28,9 @@ import Foundation @objc public init(fullText: String, displayText: String, isTextTruncated: Bool) { self.fullText = fullText + self.fullTextNaturalAlignment = fullText.naturalTextAlignment self.displayText = displayText + self.displayTextNaturalAlignment = displayText.naturalTextAlignment self.isTextTruncated = isTextTruncated self.jumbomojiCount = DisplayableText.jumbomojiCount(in: fullText) } diff --git a/SignalServiceKit/src/Util/String+SSK.swift b/SignalServiceKit/src/Util/String+SSK.swift index 7cf84310bb..dded4f5a82 100644 --- a/SignalServiceKit/src/Util/String+SSK.swift +++ b/SignalServiceKit/src/Util/String+SSK.swift @@ -45,6 +45,8 @@ public extension NSString { } } +// MARK: - Attributed String Concatentation + public extension NSAttributedString { @objc func stringByAppendingString(_ string: String, attributes: [NSAttributedString.Key: Any] = [:]) -> NSAttributedString {