Render descriptions with shared Markdown preview
Use one Markdown presentation for free-form content. - issue and pull-request descriptions and comments - milestone and commit descriptions
This commit is contained in:
@@ -1,5 +1,28 @@
|
||||
import MarkdownUI
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
struct MarkdownContent: View {
|
||||
let source: String
|
||||
|
||||
var body: some View {
|
||||
Markdown(source)
|
||||
.markdownTheme(.gitHub)
|
||||
.textSelection(.enabled)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func markdownView(_ source: String) -> UIView {
|
||||
UIHostingConfiguration {
|
||||
MarkdownContent(source: source)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
.margins(.all, 0)
|
||||
.makeContentView()
|
||||
}
|
||||
|
||||
func localDate(forUTCTimestamp timestamp: Int64) -> Date {
|
||||
var utc = Calendar(identifier: .gregorian)
|
||||
utc.timeZone = TimeZone(secondsFromGMT: 0)!
|
||||
@@ -179,17 +202,6 @@ extension UIColor {
|
||||
}
|
||||
}
|
||||
|
||||
func markdown(_ source: String, textStyle: UIFont.TextStyle = .body) -> NSAttributedString {
|
||||
let attributed = (try? AttributedString(
|
||||
markdown: source,
|
||||
options: .init(interpretedSyntax: .full)
|
||||
)) ?? AttributedString(source)
|
||||
var mutable = attributed
|
||||
mutable.font = .preferredFont(forTextStyle: textStyle)
|
||||
mutable.foregroundColor = UIColor.label
|
||||
return NSAttributedString(mutable)
|
||||
}
|
||||
|
||||
func configureTextCell(_ cell: UITableViewCell, title: String, detail: String, image: UIImage? = nil) {
|
||||
var content = cell.defaultContentConfiguration()
|
||||
content.text = title
|
||||
|
||||
Reference in New Issue
Block a user