Run SwiftFormat.

This commit is contained in:
Doug
2026-05-27 14:38:50 +01:00
committed by Doug
parent 5138e05e47
commit fa67713726
573 changed files with 2426 additions and 2426 deletions
@@ -49,7 +49,7 @@ struct MentionBuilder: MentionBuilderProtocol {
func handleAllUsersMention(for attributedString: NSMutableAttributedString, in range: NSRange) {
let attributesToRestore = getAttributesToRestore(for: attributedString, in: range)
let attachmentData = PillTextAttachmentData(type: .allUsers, font: attributesToRestore.font)
guard let attachment = PillTextAttachment(attachmentData: attachmentData) else {
return
@@ -80,7 +80,7 @@ struct MentionBuilder: MentionBuilderProtocol {
.font: attributesToRestore.font,
.foregroundColor: attributesToRestore.foregroundColor]
attachmentAttributes.addBlockquoteIfNeeded(attributesToRestore.blockquote)
setPillAttachment(attachment: attachment,
attributedString: attributedString,
in: range,
@@ -93,7 +93,7 @@ struct MessageText: UIViewRepresentable {
guard let baseText = try? NSAttributedString(attributedString, including: \.elementX) else {
return nil
}
let combined = NSMutableAttributedString(attributedString: baseText)
if trailingReservedSize.width > 0 {
let attachment = TransparentTextAttachment()
@@ -101,7 +101,7 @@ struct MessageText: UIViewRepresentable {
attachment.bounds = CGRect(origin: .zero,
size: CGSize(width: trailingReservedSize.width,
height: max(trailingReservedSize.height, 1)))
// Inherit the font from the preceding character so the appended runs
// (newline and attachment) carry the same line metrics as the surrounding
// text — otherwise a small default font on those characters can shrink the
@@ -109,7 +109,7 @@ struct MessageText: UIViewRepresentable {
let trailingFont = baseText.length > 0
? baseText.attribute(.font, at: baseText.length - 1, effectiveRange: nil)
: nil
// When the last paragraph's natural text direction doesn't match the layout
// direction, the inline attachment would land on the wrong side and overlap the
// overlaid timestamp. Force it onto its own line so the bubble just grows taller.
@@ -122,7 +122,7 @@ struct MessageText: UIViewRepresentable {
}
combined.append(newlineString)
}
let attachmentString = NSMutableAttributedString(attachment: attachment)
if let trailingFont {
attachmentString.addAttribute(.font,
@@ -131,19 +131,19 @@ struct MessageText: UIViewRepresentable {
}
combined.append(attachmentString)
}
return combined
}
private func lastParagraphDirectionMatchesLayout(in attributedText: NSAttributedString) -> Bool {
let string = attributedText.string as NSString
guard string.length > 0 else { return true }
// Isolate the last paragraph because its direction is what decides
// which side the trailing attachment ends up on.
let lastParagraphRange = string.paragraphRange(for: NSRange(location: string.length - 1, length: 0))
let lastParagraph = string.substring(with: lastParagraphRange)
let textIsRTL = lastParagraph.firstStrongCharacterIsRTL
let layoutIsRTL = layoutDirection == .rightToLeft
return textIsRTL == layoutIsRTL
@@ -25,7 +25,7 @@ final class PillAttachmentViewProvider: NSTextAttachmentViewProvider, NSSecureCo
override init(textAttachment: NSTextAttachment, parentView: UIView?, textLayoutManager: NSTextLayoutManager?, location: NSTextLocation) {
super.init(textAttachment: textAttachment, parentView: parentView, textLayoutManager: textLayoutManager, location: location)
// Keep a reference to the parent text view for size adjustments and pills flushing.
delegate = parentView?.superview as? PillAttachmentViewProviderDelegate
tracksTextAttachmentViewBounds = true
@@ -34,7 +34,7 @@ final class PillAttachmentViewProvider: NSTextAttachmentViewProvider, NSSecureCo
@MainActor
override func loadView() {
super.loadView()
guard let textAttachment = textAttachment as? PillTextAttachment,
let pillData = textAttachment.pillData else {
MXLog.failure("Attachment is missing data or not of expected class")
@@ -82,7 +82,7 @@ final class PillAttachmentViewProvider: NSTextAttachmentViewProvider, NSSecureCo
final class ComposerMentionDisplayHelper: MentionDisplayHelper {
weak var timelineContext: TimelineViewModel.Context?
init(timelineContext: TimelineViewModel.Context) {
self.timelineContext = timelineContext
}
@@ -10,7 +10,7 @@ import Foundation
enum PillUtilities {
static let atRoom = "@room"
/// Used by the WYSIWYG as the urlString value to identify @room mentions
static let composerAtRoomURLString = "#"
+1 -1
View File
@@ -21,7 +21,7 @@ struct PillView: View {
var backgroundColor: Color {
context.viewState.isOwnMention ? .compound.bgBadgeAccent : .compound.bgBadgePrimary
}
var body: some View {
mainContent
.onChange(of: context.viewState.displayText) {