File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ import SwiftUI
10
10
public struct ExpandableText : View {
11
11
var text : String
12
12
13
+ @available ( iOS 15 , * )
14
+ var markdownText : AttributedString {
15
+ ( try ? AttributedString ( markdown: text, options: AttributedString . MarkdownParsingOptions ( interpretedSyntax: . inlineOnlyPreservingWhitespace) ) ) ?? AttributedString ( )
16
+ }
17
+
13
18
var font : Font = . body
14
19
var lineLimit : Int = 3
15
20
var foregroundColor : Color = . primary
@@ -28,7 +33,13 @@ public struct ExpandableText: View {
28
33
}
29
34
public var body : some View {
30
35
ZStack ( alignment: . bottomTrailing) {
31
- Text ( text)
36
+ Group {
37
+ if #available( iOS 15 . 0 , * ) {
38
+ Text ( markdownText)
39
+ } else {
40
+ Text ( text)
41
+ }
42
+ }
32
43
. font ( font)
33
44
. foregroundColor ( foregroundColor)
34
45
. lineLimit ( expand == true ? nil : lineLimit)
You can’t perform that action at this time.
0 commit comments