mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-04-19 05:52:12 +00:00
Changing update view.
This commit is contained in:
parent
6a24a66627
commit
535b5efe8e
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
50020BB024064869003D4025 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50020BAF24064869003D4025 /* AppDelegate.swift */; };
|
50020BB024064869003D4025 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50020BAF24064869003D4025 /* AppDelegate.swift */; };
|
||||||
|
50153E20250AFCB200525160 /* UpdateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50153E1F250AFCB200525160 /* UpdateView.swift */; };
|
||||||
5018F54F24064786002EB505 /* Notifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5018F54E24064786002EB505 /* Notifier.swift */; };
|
5018F54F24064786002EB505 /* Notifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5018F54E24064786002EB505 /* Notifier.swift */; };
|
||||||
50524B442420969E008DBD97 /* OpenSSHWriterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50524B432420969D008DBD97 /* OpenSSHWriterTests.swift */; };
|
50524B442420969E008DBD97 /* OpenSSHWriterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50524B432420969D008DBD97 /* OpenSSHWriterTests.swift */; };
|
||||||
50571E0324393C2600F76F6C /* JustUpdatedChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50571E0224393C2600F76F6C /* JustUpdatedChecker.swift */; };
|
50571E0324393C2600F76F6C /* JustUpdatedChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50571E0224393C2600F76F6C /* JustUpdatedChecker.swift */; };
|
||||||
@ -204,6 +205,7 @@
|
|||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
50020BAF24064869003D4025 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
50020BAF24064869003D4025 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
50153E1F250AFCB200525160 /* UpdateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateView.swift; sourceTree = "<group>"; };
|
||||||
5018F54E24064786002EB505 /* Notifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifier.swift; sourceTree = "<group>"; };
|
5018F54E24064786002EB505 /* Notifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifier.swift; sourceTree = "<group>"; };
|
||||||
50524B432420969D008DBD97 /* OpenSSHWriterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenSSHWriterTests.swift; sourceTree = "<group>"; };
|
50524B432420969D008DBD97 /* OpenSSHWriterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenSSHWriterTests.swift; sourceTree = "<group>"; };
|
||||||
50571E0224393C2600F76F6C /* JustUpdatedChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JustUpdatedChecker.swift; sourceTree = "<group>"; };
|
50571E0224393C2600F76F6C /* JustUpdatedChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JustUpdatedChecker.swift; sourceTree = "<group>"; };
|
||||||
@ -501,6 +503,7 @@
|
|||||||
50B8550C24138C4F009958AC /* DeleteSecretView.swift */,
|
50B8550C24138C4F009958AC /* DeleteSecretView.swift */,
|
||||||
50BB046A2418AAAE00D6E079 /* EmptyStoreView.swift */,
|
50BB046A2418AAAE00D6E079 /* EmptyStoreView.swift */,
|
||||||
506772C82425BB8500034DED /* NoStoresView.swift */,
|
506772C82425BB8500034DED /* NoStoresView.swift */,
|
||||||
|
50153E1F250AFCB200525160 /* UpdateView.swift */,
|
||||||
50C385A8240B636500AF2719 /* SetupView.swift */,
|
50C385A8240B636500AF2719 /* SetupView.swift */,
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
@ -920,6 +923,7 @@
|
|||||||
508A58B3241ED2180069DC07 /* AgentStatusChecker.swift in Sources */,
|
508A58B3241ED2180069DC07 /* AgentStatusChecker.swift in Sources */,
|
||||||
50C385A52407A76D00AF2719 /* SecretDetailView.swift in Sources */,
|
50C385A52407A76D00AF2719 /* SecretDetailView.swift in Sources */,
|
||||||
5099A02423FD2AAA0062B6F2 /* CreateSecretView.swift in Sources */,
|
5099A02423FD2AAA0062B6F2 /* CreateSecretView.swift in Sources */,
|
||||||
|
50153E20250AFCB200525160 /* UpdateView.swift in Sources */,
|
||||||
50571E0524393D1500F76F6C /* LaunchAgentController.swift in Sources */,
|
50571E0524393D1500F76F6C /* LaunchAgentController.swift in Sources */,
|
||||||
50B8550D24138C4F009958AC /* DeleteSecretView.swift in Sources */,
|
50B8550D24138C4F009958AC /* DeleteSecretView.swift in Sources */,
|
||||||
50BB046B2418AAAE00D6E079 /* EmptyStoreView.swift in Sources */,
|
50BB046B2418AAAE00D6E079 /* EmptyStoreView.swift in Sources */,
|
||||||
|
@ -12,6 +12,7 @@ struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentSt
|
|||||||
@State private var active: AnySecret.ID?
|
@State private var active: AnySecret.ID?
|
||||||
@State private var showingCreation = false
|
@State private var showingCreation = false
|
||||||
@State private var deletingSecret: AnySecret?
|
@State private var deletingSecret: AnySecret?
|
||||||
|
@State private var selectedUpdate: Release?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
@ -74,7 +75,7 @@ struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentSt
|
|||||||
.frame(minWidth: 640, minHeight: 320)
|
.frame(minWidth: 640, minHeight: 320)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
// if updater.update != nil {
|
// if updater.update != nil {
|
||||||
// updateNotice()
|
updateNotice()
|
||||||
// }
|
// }
|
||||||
// if !agentStatusChecker.running {
|
// if !agentStatusChecker.running {
|
||||||
// agentNotice()z
|
// agentNotice()z
|
||||||
@ -89,29 +90,34 @@ struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func updateNotice() -> ToolbarItem<Void, some View> {
|
func updateNotice() -> ToolbarItem<Void, AnyView> {
|
||||||
|
let update = updater.update ?? Release(name: "", html_url: URL(string:"https://example.com")!, body: "")
|
||||||
// guard let update = updater.update else { fatalError() }
|
// guard let update = updater.update else { fatalError() }
|
||||||
// let color: Color
|
let color: Color
|
||||||
// let text: String
|
let text: String
|
||||||
// if update.critical {
|
if update.critical {
|
||||||
// text = "Critical Security Update Required"
|
text = "Critical Security Update Required"
|
||||||
// color = .orange
|
color = .red
|
||||||
// } else {
|
} else {
|
||||||
// text = "Update Available"
|
text = "Update Available"
|
||||||
// color = .red
|
color = .orange
|
||||||
// }
|
}
|
||||||
// return ToolbarItem {
|
return ToolbarItem {
|
||||||
// Button(action: {
|
AnyView(Button(action: {
|
||||||
// NSWorkspace.shared.open(update.html_url)
|
self.selectedUpdate = update
|
||||||
// }, label: {
|
}, label: {
|
||||||
// Text(text)
|
Text(text)
|
||||||
// .font(.headline)
|
.font(.headline)
|
||||||
// .foregroundColor(.white)
|
.foregroundColor(.white)
|
||||||
// })
|
})
|
||||||
// .background(color)
|
.background(color)
|
||||||
// .cornerRadius(5)
|
.cornerRadius(5)
|
||||||
// }
|
.popover(item: $selectedUpdate, attachmentAnchor: .point(.bottom), arrowEdge: .bottom) { update in
|
||||||
// }
|
UpdateDetailView(update: update)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// func agentNotice() -> ToolbarItem<Void, AnyView> {
|
// func agentNotice() -> ToolbarItem<Void, AnyView> {
|
||||||
// ToolbarItem {
|
// ToolbarItem {
|
||||||
|
60
Secretive/Views/UpdateView.swift
Normal file
60
Secretive/Views/UpdateView.swift
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user