mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fix for overlapping timestamp when last block is not plainText (#5629)
* fix for the overlapping timestamp when the last block is not plain text * remove id and use offset as iterator in the foearch of the components
This commit is contained in:
@@ -63,11 +63,18 @@ struct FormattedBodyText: View {
|
||||
// component so that the bubble's natural size accommodates the overlaid
|
||||
// timestamp, and TextKit decides whether to keep the timestamp on the last
|
||||
// line or push it to a new one.
|
||||
let components = attributedComponents
|
||||
var components = attributedComponents
|
||||
// When the body ends in a block component (blockquote/codeBlock) the overlaid
|
||||
// timestamp would land on top of it, so append an empty trailing plain-text
|
||||
// component that exists solely to reserve space for the timestamp underneath.
|
||||
if trailingReservedSize != .zero, let last = components.last, last.type != .plainText {
|
||||
components.append(AttributedStringBuilderComponent(attributedString: AttributedString(),
|
||||
type: .plainText))
|
||||
}
|
||||
let lastPlainTextIndex = components.lastIndex { $0.type == .plainText }
|
||||
|
||||
|
||||
return TimelineBubbleLayout(spacing: 8) {
|
||||
ForEach(Array(components.enumerated()), id: \.element.id) { index, component in
|
||||
ForEach(Array(components.enumerated()), id: \.offset) { index, component in
|
||||
switch component.type {
|
||||
case .blockquote:
|
||||
BlockquoteView(attributedString: component.attributedString, mode: .rendering)
|
||||
@@ -88,10 +95,10 @@ struct FormattedBodyText: View {
|
||||
.timelineBubbleLayoutSize(.natural)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Make a second iteration through the components adding naturally sized versions of the
|
||||
// block quotes and code blocks which are used for layout calculations but won't be rendered.
|
||||
ForEach(components) { component in
|
||||
ForEach(Array(components.enumerated()), id: \.offset) { _, component in
|
||||
switch component.type {
|
||||
case .blockquote:
|
||||
BlockquoteView(attributedString: component.attributedString, mode: .layout)
|
||||
|
||||
Reference in New Issue
Block a user