diff --git a/Sources/UIComponent/Components/View/Text.swift b/Sources/UIComponent/Components/View/Text.swift index c55399fc..05abaca1 100644 --- a/Sources/UIComponent/Components/View/Text.swift +++ b/Sources/UIComponent/Components/View/Text.swift @@ -3,7 +3,7 @@ import UIKit public struct Text: ViewComponent { - public let attributedText: NSAttributedString + public let attributedString: NSAttributedString public let numberOfLines: Int public let lineBreakMode: NSLineBreakMode @@ -14,18 +14,18 @@ public struct Text: ViewComponent { numberOfLines: Int = 0, lineBreakMode: NSLineBreakMode = .byWordWrapping ) { - self.attributedText = NSAttributedString(string: String(localized: localized), attributes: [.font: font]) + self.attributedString = NSAttributedString(string: String(localized: localized), attributes: [.font: font]) self.numberOfLines = numberOfLines self.lineBreakMode = lineBreakMode } @available(iOS 15, *) public init( - _ attributedText: AttributedString, + attributedString: AttributedString, numberOfLines: Int = 0, lineBreakMode: NSLineBreakMode = .byWordWrapping ) { - self.attributedText = NSAttributedString(attributedText) + self.attributedString = NSAttributedString(attributedString) self.numberOfLines = numberOfLines self.lineBreakMode = lineBreakMode } @@ -36,17 +36,17 @@ public struct Text: ViewComponent { numberOfLines: Int = 0, lineBreakMode: NSLineBreakMode = .byWordWrapping ) { - self.attributedText = NSAttributedString(string: text, attributes: [.font: font]) + self.attributedString = NSAttributedString(string: text, attributes: [.font: font]) self.numberOfLines = numberOfLines self.lineBreakMode = lineBreakMode } public init( - _ attributedText: NSAttributedString, + attributedString: NSAttributedString, numberOfLines: Int = 0, lineBreakMode: NSLineBreakMode = .byWordWrapping ) { - self.attributedText = attributedText + self.attributedString = attributedString self.numberOfLines = numberOfLines self.lineBreakMode = lineBreakMode } @@ -54,10 +54,10 @@ public struct Text: ViewComponent { public func layout(_ constraint: Constraint) -> TextRenderNode { guard numberOfLines != 0 else { return TextRenderNode( - attributedText: attributedText, + attributedString: attributedString, numberOfLines: numberOfLines, lineBreakMode: lineBreakMode, - size: attributedText.boundingRect(with: constraint.maxSize, options: [.usesLineFragmentOrigin], context: nil).size.bound(to: constraint) + size: attributedString.boundingRect(with: constraint.maxSize, options: [.usesLineFragmentOrigin], context: nil).size.bound(to: constraint) ) } let textStorage = NSTextStorage() @@ -65,7 +65,7 @@ public struct Text: ViewComponent { layoutManager.usesFontLeading = false textStorage.addLayoutManager(layoutManager) - textStorage.setAttributedString(attributedText) + textStorage.setAttributedString(attributedString) let textContainer = NSTextContainer(size: constraint.maxSize) textContainer.lineFragmentPadding = 0 textContainer.lineBreakMode = lineBreakMode @@ -74,7 +74,7 @@ public struct Text: ViewComponent { layoutManager.ensureLayout(for: textContainer) let rect = layoutManager.usedRect(for: textContainer) return TextRenderNode( - attributedText: attributedText, + attributedString: attributedString, numberOfLines: numberOfLines, lineBreakMode: lineBreakMode, size: rect.size.bound(to: constraint) @@ -83,20 +83,20 @@ public struct Text: ViewComponent { } public struct TextRenderNode: ViewRenderNode { - public let attributedText: NSAttributedString + public let attributedString: NSAttributedString public let numberOfLines: Int public let lineBreakMode: NSLineBreakMode public let size: CGSize - public init(attributedText: NSAttributedString, numberOfLines: Int, lineBreakMode: NSLineBreakMode, size: CGSize) { - self.attributedText = attributedText + public init(attributedString: NSAttributedString, numberOfLines: Int, lineBreakMode: NSLineBreakMode, size: CGSize) { + self.attributedString = attributedString self.numberOfLines = numberOfLines self.lineBreakMode = lineBreakMode self.size = size } public func updateView(_ label: UILabel) { - label.attributedText = attributedText + label.attributedText = attributedString label.numberOfLines = numberOfLines label.lineBreakMode = lineBreakMode }