mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-04-18 05:22:11 +00:00
Doing a bit of gutting.
This commit is contained in:
parent
a4d674bd2b
commit
28dbacd850
@ -1223,7 +1223,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
MACOSX_DEPLOYMENT_TARGET = 10.16;
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
@ -1251,7 +1251,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
MACOSX_DEPLOYMENT_TARGET = 10.16;
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
@ -1566,7 +1566,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
MACOSX_DEPLOYMENT_TARGET = 10.16;
|
||||||
MARKETING_VERSION = 1;
|
MARKETING_VERSION = 1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
PRODUCT_BUNDLE_IDENTIFIER = com.maxgoedjen.Secretive.Host;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
@ -3,12 +3,88 @@ import SwiftUI
|
|||||||
import SecretKit
|
import SecretKit
|
||||||
import Brief
|
import Brief
|
||||||
|
|
||||||
@NSApplicationMain
|
//@NSApplicationMain
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
//class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
//
|
||||||
|
// var window: NSWindow!
|
||||||
|
// @IBOutlet var newMenuItem: NSMenuItem!
|
||||||
|
// @IBOutlet var toolbar: NSToolbar!
|
||||||
|
// let storeList: SecretStoreList = {
|
||||||
|
// let list = SecretStoreList()
|
||||||
|
// list.add(store: SecureEnclave.Store())
|
||||||
|
// list.add(store: SmartCard.Store())
|
||||||
|
// return list
|
||||||
|
// }()
|
||||||
|
// let updater = Updater()
|
||||||
|
// let agentStatusChecker = AgentStatusChecker()
|
||||||
|
// let justUpdatedChecker = JustUpdatedChecker()
|
||||||
|
//
|
||||||
|
// func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
|
// let contentView = ContentView(storeList: storeList, updater: updater, agentStatusChecker: agentStatusChecker, runSetupBlock: { self.runSetup(sender: nil) })
|
||||||
|
// // Create the window and set the content view.
|
||||||
|
// window = NSWindow(
|
||||||
|
// contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
||||||
|
// styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
||||||
|
// backing: .buffered, defer: false)
|
||||||
|
// window.center()
|
||||||
|
// window.setFrameAutosaveName("Main Window")
|
||||||
|
// window.contentView = NSHostingView(rootView: contentView)
|
||||||
|
// window.makeKeyAndOrderFront(nil)
|
||||||
|
// window.titleVisibility = .hidden
|
||||||
|
// window.toolbar = toolbar
|
||||||
|
// window.isReleasedWhenClosed = false
|
||||||
|
// if storeList.modifiableStore?.isAvailable ?? false {
|
||||||
|
// let plus = NSTitlebarAccessoryViewController()
|
||||||
|
// plus.view = NSButton(image: NSImage(named: NSImage.addTemplateName)!, target: self, action: #selector(add(sender:)))
|
||||||
|
// plus.layoutAttribute = .right
|
||||||
|
// window.addTitlebarAccessoryViewController(plus)
|
||||||
|
// newMenuItem.isEnabled = true
|
||||||
|
// }
|
||||||
|
// runSetupIfNeeded()
|
||||||
|
// relaunchAgentIfNeeded()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func applicationDidBecomeActive(_ notification: Notification) {
|
||||||
|
// agentStatusChecker.check()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
||||||
|
// guard !flag else { return false }
|
||||||
|
// window.makeKeyAndOrderFront(self)
|
||||||
|
// return true
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @IBAction func add(sender: AnyObject?) {
|
||||||
|
// var addWindow: NSWindow!
|
||||||
|
// let addView = CreateSecretView(store: storeList.modifiableStore!) {
|
||||||
|
// self.window.endSheet(addWindow)
|
||||||
|
// }
|
||||||
|
// addWindow = NSWindow(
|
||||||
|
// contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
||||||
|
// styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
||||||
|
// backing: .buffered, defer: false)
|
||||||
|
// addWindow.contentView = NSHostingView(rootView: addView)
|
||||||
|
// window.beginSheet(addWindow, completionHandler: nil)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @IBAction func runSetup(sender: AnyObject?) {
|
||||||
|
// let setupWindow = NSWindow(
|
||||||
|
// contentRect: NSRect(x: 0, y: 0, width: 0, height: 0),
|
||||||
|
// styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
||||||
|
// backing: .buffered, defer: false)
|
||||||
|
// let setupView = SetupView() { success in
|
||||||
|
// self.window.endSheet(setupWindow)
|
||||||
|
// self.agentStatusChecker.check()
|
||||||
|
// }
|
||||||
|
// setupWindow.contentView = NSHostingView(rootView: setupView)
|
||||||
|
// window.beginSheet(setupWindow, completionHandler: nil)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
@main
|
||||||
|
struct AppDelegate: App {
|
||||||
|
|
||||||
var window: NSWindow!
|
|
||||||
@IBOutlet var newMenuItem: NSMenuItem!
|
|
||||||
@IBOutlet var toolbar: NSToolbar!
|
|
||||||
let storeList: SecretStoreList = {
|
let storeList: SecretStoreList = {
|
||||||
let list = SecretStoreList()
|
let list = SecretStoreList()
|
||||||
list.add(store: SecureEnclave.Store())
|
list.add(store: SecureEnclave.Store())
|
||||||
@ -19,71 +95,34 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
let agentStatusChecker = AgentStatusChecker()
|
let agentStatusChecker = AgentStatusChecker()
|
||||||
let justUpdatedChecker = JustUpdatedChecker()
|
let justUpdatedChecker = JustUpdatedChecker()
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
@SceneBuilder var body: some Scene {
|
||||||
let contentView = ContentView(storeList: storeList, updater: updater, agentStatusChecker: agentStatusChecker, runSetupBlock: { self.runSetup(sender: nil) })
|
WindowGroup {
|
||||||
// Create the window and set the content view.
|
ContentView(storeList: storeList, updater: updater, agentStatusChecker: agentStatusChecker, runSetupBlock: { self.runSetup(sender: nil) })
|
||||||
window = NSWindow(
|
|
||||||
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
|
||||||
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
|
||||||
backing: .buffered, defer: false)
|
|
||||||
window.center()
|
|
||||||
window.setFrameAutosaveName("Main Window")
|
|
||||||
window.contentView = NSHostingView(rootView: contentView)
|
|
||||||
window.makeKeyAndOrderFront(nil)
|
|
||||||
window.titleVisibility = .hidden
|
|
||||||
window.toolbar = toolbar
|
|
||||||
window.isReleasedWhenClosed = false
|
|
||||||
if storeList.modifiableStore?.isAvailable ?? false {
|
|
||||||
let plus = NSTitlebarAccessoryViewController()
|
|
||||||
plus.view = NSButton(image: NSImage(named: NSImage.addTemplateName)!, target: self, action: #selector(add(sender:)))
|
|
||||||
plus.layoutAttribute = .right
|
|
||||||
window.addTitlebarAccessoryViewController(plus)
|
|
||||||
newMenuItem.isEnabled = true
|
|
||||||
}
|
}
|
||||||
runSetupIfNeeded()
|
WindowGroup {
|
||||||
relaunchAgentIfNeeded()
|
SetupView() { _ in
|
||||||
}
|
print("Setup")
|
||||||
|
}
|
||||||
func applicationDidBecomeActive(_ notification: Notification) {
|
|
||||||
agentStatusChecker.check()
|
|
||||||
}
|
|
||||||
|
|
||||||
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
|
||||||
guard !flag else { return false }
|
|
||||||
window.makeKeyAndOrderFront(self)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func add(sender: AnyObject?) {
|
|
||||||
var addWindow: NSWindow!
|
|
||||||
let addView = CreateSecretView(store: storeList.modifiableStore!) {
|
|
||||||
self.window.endSheet(addWindow)
|
|
||||||
}
|
}
|
||||||
addWindow = NSWindow(
|
|
||||||
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
|
||||||
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
|
||||||
backing: .buffered, defer: false)
|
|
||||||
addWindow.contentView = NSHostingView(rootView: addView)
|
|
||||||
window.beginSheet(addWindow, completionHandler: nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func runSetup(sender: AnyObject?) {
|
|
||||||
let setupWindow = NSWindow(
|
|
||||||
contentRect: NSRect(x: 0, y: 0, width: 0, height: 0),
|
|
||||||
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
|
||||||
backing: .buffered, defer: false)
|
|
||||||
let setupView = SetupView() { success in
|
|
||||||
self.window.endSheet(setupWindow)
|
|
||||||
self.agentStatusChecker.check()
|
|
||||||
}
|
|
||||||
setupWindow.contentView = NSHostingView(rootView: setupView)
|
|
||||||
window.beginSheet(setupWindow, completionHandler: nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppDelegate {
|
extension AppDelegate {
|
||||||
|
|
||||||
|
func runSetup(sender: AnyObject?) {
|
||||||
|
let setupWindow = NSWindow(
|
||||||
|
contentRect: NSRect(x: 0, y: 0, width: 0, height: 0),
|
||||||
|
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
||||||
|
backing: .buffered, defer: false)
|
||||||
|
let setupView = SetupView() { success in
|
||||||
|
// self.window.endSheet(setupWindow)
|
||||||
|
self.agentStatusChecker.check()
|
||||||
|
}
|
||||||
|
setupWindow.contentView = NSHostingView(rootView: setupView)
|
||||||
|
// window.beginSheet(setupWindow, completionHandler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
func runSetupIfNeeded() {
|
func runSetupIfNeeded() {
|
||||||
if !UserDefaults.standard.bool(forKey: Constants.defaultsHasRunSetup) {
|
if !UserDefaults.standard.bool(forKey: Constants.defaultsHasRunSetup) {
|
||||||
UserDefaults.standard.set(true, forKey: Constants.defaultsHasRunSetup)
|
UserDefaults.standard.set(true, forKey: Constants.defaultsHasRunSetup)
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>$(PRODUCT_NAME) is MIT Licensed.</string>
|
<string>$(PRODUCT_NAME) is MIT Licensed.</string>
|
||||||
<key>NSMainStoryboardFile</key>
|
|
||||||
<string>Main</string>
|
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
<string>NSApplication</string>
|
<string>NSApplication</string>
|
||||||
<key>NSSupportsAutomaticTermination</key>
|
<key>NSSupportsAutomaticTermination</key>
|
||||||
|
@ -15,12 +15,12 @@ struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentSt
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
if updater.update != nil {
|
// if updater.update != nil {
|
||||||
updateNotice()
|
// updateNotice()
|
||||||
}
|
// }
|
||||||
if !agentStatusChecker.running {
|
// if !agentStatusChecker.running {
|
||||||
agentNotice()
|
// agentNotice()
|
||||||
}
|
// }
|
||||||
if storeList.anyAvailable {
|
if storeList.anyAvailable {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
List(selection: $active) {
|
List(selection: $active) {
|
||||||
@ -73,7 +73,21 @@ struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentSt
|
|||||||
} else {
|
} else {
|
||||||
NoStoresView()
|
NoStoresView()
|
||||||
}
|
}
|
||||||
}.frame(minWidth: 640, minHeight: 320)
|
}
|
||||||
|
.frame(minWidth: 640, minHeight: 320)
|
||||||
|
.toolbar {
|
||||||
|
self.toolbar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var toolbar: ToolbarItem<Void, Button<Image>> {
|
||||||
|
ToolbarItem {
|
||||||
|
Button(action: {
|
||||||
|
print("OK")
|
||||||
|
}, label: {
|
||||||
|
Image(systemName: "plus")
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateNotice() -> some View {
|
func updateNotice() -> some View {
|
||||||
|
Loading…
Reference in New Issue
Block a user