mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-09-20 03:10:57 +00:00
Cleaup.
This commit is contained in:
parent
34aad09126
commit
80ffe466f7
@ -45,9 +45,9 @@ struct Secretive: App {
|
|||||||
ContentView(showingCreation: $showingCreation, runningSetup: $showingSetup, hasRunSetup: $hasRunSetup)
|
ContentView(showingCreation: $showingCreation, runningSetup: $showingSetup, hasRunSetup: $hasRunSetup)
|
||||||
.environment(EnvironmentValues._secretStoreList)
|
.environment(EnvironmentValues._secretStoreList)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
// if !hasRunSetup {
|
if !hasRunSetup {
|
||||||
showingSetup = true
|
showingSetup = true
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in
|
.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in
|
||||||
guard hasRunSetup else { return }
|
guard hasRunSetup else { return }
|
||||||
|
@ -12,7 +12,7 @@ struct UpdateDetailView: View {
|
|||||||
Text(.updateVersionName(updateName: update.name)).font(.title)
|
Text(.updateVersionName(updateName: update.name)).font(.title)
|
||||||
GroupBox(label: Text(.updateReleaseNotesTitle)) {
|
GroupBox(label: Text(.updateReleaseNotesTitle)) {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
Text(attributedBody)
|
attributedBody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
@ -35,62 +35,29 @@ struct UpdateDetailView: View {
|
|||||||
.frame(maxWidth: 500)
|
.frame(maxWidth: 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
var attributedBody: AttributedString {
|
var attributedBody: Text {
|
||||||
do {
|
var text = Text(verbatim: "")
|
||||||
var text = try AttributedString(
|
for line in update.body.split(whereSeparator: \.isNewline) {
|
||||||
markdown: update.body,
|
let attributed: Text
|
||||||
options: .init(
|
let split = line.split(separator: " ")
|
||||||
allowsExtendedAttributes: true,
|
let unprefixed = split.dropFirst().joined(separator: " ")
|
||||||
interpretedSyntax: .full,
|
if let prefix = split.first {
|
||||||
),
|
switch prefix {
|
||||||
baseURL: URL(string: "https://github.com/maxgoedjen/secretive")!
|
case "#":
|
||||||
)
|
attributed = Text(unprefixed).font(.title) + Text(verbatim: "\n")
|
||||||
.transformingAttributes(AttributeScopes.FoundationAttributes.PresentationIntentAttribute.self) { key in
|
case "##":
|
||||||
let font: Font? = switch key.value?.components.first?.kind {
|
attributed = Text(unprefixed).font(.title2) + Text(verbatim: "\n")
|
||||||
case .header(level: 1):
|
case "###":
|
||||||
Font.title
|
attributed = Text(unprefixed).font(.title3) + Text(verbatim: "\n")
|
||||||
case .header(level: 2):
|
|
||||||
Font.title2
|
|
||||||
case .header(level: 3):
|
|
||||||
Font.title3
|
|
||||||
default:
|
default:
|
||||||
nil
|
attributed = Text(line) + Text(verbatim: "\n\n")
|
||||||
}
|
|
||||||
if let font {
|
|
||||||
key.replace(with: AttributeScopes.SwiftUIAttributes.FontAttribute.self, value: font)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
attributed = Text(line) + Text(verbatim: "\n\n")
|
||||||
}
|
}
|
||||||
let lineBreak = AttributedString("\n\n")
|
text = text + attributed
|
||||||
for run in text.runs.reversed() {
|
|
||||||
text.insert(lineBreak, at: run.range.lowerBound)
|
|
||||||
}
|
|
||||||
return text
|
|
||||||
} catch {
|
|
||||||
var text = AttributedString()
|
|
||||||
for line in update.body.split(whereSeparator: \.isNewline) {
|
|
||||||
let attributed: AttributedString
|
|
||||||
let split = line.split(separator: " ")
|
|
||||||
let unprefixed = split.dropFirst().joined(separator: " ")
|
|
||||||
if let prefix = split.first {
|
|
||||||
var container = AttributeContainer()
|
|
||||||
switch prefix {
|
|
||||||
case "#":
|
|
||||||
container.font = .title
|
|
||||||
case "##":
|
|
||||||
container.font = .title2
|
|
||||||
case "###":
|
|
||||||
container.font = .title3
|
|
||||||
default:
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
attributed = AttributedString(unprefixed, attributes: container)
|
|
||||||
} else {
|
|
||||||
attributed = AttributedString(line + "\n\n")
|
|
||||||
}
|
|
||||||
text = text + attributed
|
|
||||||
}
|
|
||||||
return text
|
|
||||||
}
|
}
|
||||||
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user