- Create MarkdownContentView to encapsulate MarkdownUI rendering - Replace custom AttributedString markdown parsing with MarkdownUI - Simplify ReleaseNotesView by removing manual markdown styling - Improve markdown rendering with proper support for lists, links, and formatting - Make markdown rendering easily replaceable by keeping it in a dedicated view
44 lines
1.3 KiB
Swift
44 lines
1.3 KiB
Swift
import SwiftUI
|
|
|
|
struct ReleaseNotesView: View {
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
ScrollView {
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
if let markdownContent = loadReleaseNotes() {
|
|
MarkdownContentView(content: markdownContent)
|
|
.padding()
|
|
} else {
|
|
Text("Unable to load release notes")
|
|
.foregroundColor(.secondary)
|
|
.padding()
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("What's New")
|
|
.navigationBarTitleDisplayMode(.large)
|
|
.toolbar {
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
Button("Done") {
|
|
dismiss()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private func loadReleaseNotes() -> String? {
|
|
guard let url = Bundle.main.url(forResource: "RELEASE_NOTES", withExtension: "md"),
|
|
let markdownContent = try? String(contentsOf: url) else {
|
|
return nil
|
|
}
|
|
return markdownContent
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ReleaseNotesView()
|
|
}
|