Skip to content

Commit 81a20f9

Browse files
committed
Fix comment width
1 parent b0d25f3 commit 81a20f9

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

V2er/View/Widget/RichText/RichText.swift

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,23 @@ fileprivate struct AttributedText: UIViewRepresentable {
5959
self._height = height
6060
}
6161

62-
func makeUIView(context: Context) -> MaxWidthAttributedLabel {
63-
let label = MaxWidthAttributedLabel()
62+
func makeUIView(context: Context) -> AttributedLabel {
63+
let label = AttributedLabel()
6464
label.numberOfLines = 0
6565
label.lineBreakMode = .byWordWrapping
6666
label.attributedText = self.richString
67-
label.maxWidth = maxWidth
6867
clickEvent(label: label)
6968
return label
7069
}
7170

72-
func updateUIView(_ label: MaxWidthAttributedLabel, context: Context) {
71+
func updateUIView(_ label: AttributedLabel, context: Context) {
7372
label.attributedText = self.richString
74-
label.maxWidth = maxWidth
7573
runInMain(delay: 100) {
7674
self.height = label.sizeThatFits(CGSize(width: maxWidth, height: .infinity)).height
7775
}
7876
}
7977

80-
private func clickEvent(label: MaxWidthAttributedLabel) {
78+
private func clickEvent(label: AttributedLabel) {
8179
let baseURL = APIService.baseUrlString
8280
label.onClick = { label, detection in
8381
if let consumed = self.detection?(detection.type) {
@@ -106,14 +104,6 @@ fileprivate struct AttributedText: UIViewRepresentable {
106104

107105
}
108106

109-
fileprivate class MaxWidthAttributedLabel: AttributedLabel {
110-
var maxWidth: CGFloat!
111-
112-
open override var intrinsicContentSize: CGSize {
113-
sizeThatFits(CGSize(width: maxWidth, height: .infinity))
114-
}
115-
}
116-
117107
extension String {
118108
func rich(baseStyle: Atributika.Style = RichText.Styles.base) ->RichString {
119109
return self

0 commit comments

Comments
 (0)