// SPDX-License-Identifier: GPL-3.0-or-later import SwiftUI struct ReleaseHistoryView: View { private let paragraphs: [String] = { guard let url = Bundle.main.url(forResource: "RELEASES", withExtension: "md"), let source = try? String(contentsOf: url, encoding: .utf8) else { return [] } return source.components(separatedBy: "\n\n") .map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } .filter { !$0.isEmpty } }() var body: some View { Group { if paragraphs.isEmpty { ContentUnavailableView("Release history unavailable", systemImage: "doc.text", description: Text("The release history is missing from this app. Rebuild or reinstall the complete application.")) } else { ScrollView { VStack(alignment: .leading, spacing: 16) { ForEach(Array(paragraphs.enumerated()), id: \.offset) { _, paragraph in if paragraph.hasPrefix("# ") { Text(String(paragraph.dropFirst(2))) .font(.largeTitle.bold()) .accessibilityAddTraits(.isHeader) } else if paragraph.hasPrefix("## ") { Text(String(paragraph.dropFirst(3))) .font(.title2.weight(.semibold)) .padding(.top, 12) .accessibilityAddTraits(.isHeader) } else { Text((try? AttributedString(markdown: paragraph.replacingOccurrences(of: "\n", with: " "))) ?? AttributedString(paragraph)) .lineSpacing(4) } } } .textSelection(.enabled) .frame(maxWidth: 700, alignment: .leading) .padding(24) .frame(maxWidth: .infinity, alignment: .top) } .accessibilityLabel("VCC Plus release history") .accessibilityIdentifier("release-history") } } .background(Color(nsColor: .windowBackgroundColor)) .frame(minWidth: 460, minHeight: 360) } }