@@ -59,25 +59,23 @@ fileprivate struct AttributedText: UIViewRepresentable {
59
59
self . _height = height
60
60
}
61
61
62
- func makeUIView( context: Context ) -> MaxWidthAttributedLabel {
63
- let label = MaxWidthAttributedLabel ( )
62
+ func makeUIView( context: Context ) -> AttributedLabel {
63
+ let label = AttributedLabel ( )
64
64
label. numberOfLines = 0
65
65
label. lineBreakMode = . byWordWrapping
66
66
label. attributedText = self . richString
67
- label. maxWidth = maxWidth
68
67
clickEvent ( label: label)
69
68
return label
70
69
}
71
70
72
- func updateUIView( _ label: MaxWidthAttributedLabel , context: Context ) {
71
+ func updateUIView( _ label: AttributedLabel , context: Context ) {
73
72
label. attributedText = self . richString
74
- label. maxWidth = maxWidth
75
73
runInMain ( delay: 100 ) {
76
74
self . height = label. sizeThatFits ( CGSize ( width: maxWidth, height: . infinity) ) . height
77
75
}
78
76
}
79
77
80
- private func clickEvent( label: MaxWidthAttributedLabel ) {
78
+ private func clickEvent( label: AttributedLabel ) {
81
79
let baseURL = APIService . baseUrlString
82
80
label. onClick = { label, detection in
83
81
if let consumed = self . detection ? ( detection. type) {
@@ -106,14 +104,6 @@ fileprivate struct AttributedText: UIViewRepresentable {
106
104
107
105
}
108
106
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
-
117
107
extension String {
118
108
func rich( baseStyle: Atributika . Style = RichText . Styles. base) -> RichString {
119
109
return self
0 commit comments