Skip to content

Commit

Permalink
Support for Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
serhatEmirates committed Jul 1, 2022
1 parent fdb152f commit 75fbe0d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/ExpandableText/ExpandableText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import SwiftUI
public struct ExpandableText: View {
var text : String

@available(iOS 15, *)
var markdownText: AttributedString {
(try? AttributedString(markdown: text)) ?? AttributedString()
}

var font: Font = .body
var lineLimit: Int = 3
var foregroundColor: Color = .primary
Expand All @@ -28,7 +33,13 @@ public struct ExpandableText: View {
}
public var body: some View {
ZStack(alignment: .bottomTrailing){
Text(text)
Group {
if #available(iOS 15.0, *) {
Text(markdownText)
} else {
Text(text)
}
}
.font(font)
.foregroundColor(foregroundColor)
.lineLimit(expand == true ? nil : lineLimit)
Expand Down

0 comments on commit 75fbe0d

Please sign in to comment.