Skip to content

Commit

Permalink
Fix timestamp not rendering properly when RTL and LTR are mixed toget…
Browse files Browse the repository at this point in the history
…her (#1539)

* fix

* changelog
  • Loading branch information
Velin92 authored Aug 22, 2023
1 parent ae3f7ba commit 3ef15b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ struct FormattedBodyText: View {
container.foregroundColor = UIColor.compound.textPrimary
return container
}()

private var attributedComponents: [AttributedStringBuilderComponent] {
var adjustedAttributedString = attributedString + AttributedString(additionalWhitespacesSuffix)
var adjustedAttributedString = AttributedString(layoutDirection.isolateLayoutUnicodeString) + attributedString + AttributedString(additionalWhitespacesSuffix)

// Required to allow the underlying TextView to use body font when no font is specifie in the AttributedString.
adjustedAttributedString.mergeAttributes(defaultAttributesContainer, mergePolicy: .keepCurrent)
Expand Down Expand Up @@ -89,7 +89,10 @@ struct FormattedBodyText: View {
var bubbleLayout: some View {
TimelineBubbleLayout(spacing: 8) {
ForEach(attributedComponents, id: \.self) { component in
if component.isBlockquote {
// Ignore if the string contains only the layout correction
if String(component.attributedString.characters) == layoutDirection.isolateLayoutUnicodeString {
EmptyView()
} else if component.isBlockquote {
// The rendered blockquote with a greedy width. The custom layout prevents the
// infinite width from increasing the overall width of the view.
MessageText(attributedString: component.attributedString.mergingAttributes(blockquoteAttributes))
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-1539.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve timestamp rendering when mixed LTR and RTL languages are present in the message.

0 comments on commit 3ef15b9

Please sign in to comment.