mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-04-20 06:22:12 +00:00
61 lines
1.6 KiB
Swift
61 lines
1.6 KiB
Swift
import SwiftUI
|
|
import Brief
|
|
|
|
//struct UpdateView<UpdaterType: UpdaterProtocol>: View {
|
|
//
|
|
//
|
|
//}
|
|
|
|
struct UpdateDetailView: View {
|
|
|
|
private let update: Release
|
|
|
|
init(update: Release) {
|
|
self.update = update
|
|
}
|
|
|
|
var body: some View {
|
|
VStack {
|
|
Text("Secretive \(update.name)").font(.title)
|
|
GroupBox(label: Text("Release Notes")) {
|
|
ScrollView {
|
|
attributedBody
|
|
}
|
|
}
|
|
Button(action: {
|
|
NSWorkspace.shared.open(update.html_url)
|
|
}, label: {
|
|
Text("Update")
|
|
})
|
|
}
|
|
.padding()
|
|
.frame(maxWidth: 500)
|
|
}
|
|
|
|
var attributedBody: Text {
|
|
var text = Text("")
|
|
for line in update.body.split(whereSeparator: \.isNewline) {
|
|
let attributed: Text
|
|
let split = line.split(separator: " ")
|
|
let unprefixed = split.dropFirst().joined()
|
|
if let prefix = split.first {
|
|
switch prefix {
|
|
case "#":
|
|
attributed = Text(unprefixed).font(.title) + Text("\n")
|
|
case "##":
|
|
attributed = Text(unprefixed).font(.title2) + Text("\n")
|
|
case "###":
|
|
attributed = Text(unprefixed).font(.title3) + Text("\n")
|
|
default:
|
|
attributed = Text(line) + Text("\n\n")
|
|
}
|
|
} else {
|
|
attributed = Text(line) + Text("\n\n")
|
|
}
|
|
text = text + attributed
|
|
}
|
|
return text
|
|
}
|
|
|
|
}
|