first commit

This commit is contained in:
David Wernhart
2020-02-16 03:28:55 +01:00
commit 906cec6cc5
80 changed files with 3984 additions and 0 deletions

64
AlDente/AppDelegate.swift Normal file
View File

@@ -0,0 +1,64 @@
//
// AppDelegate.swift
// AlDente
//
// Created by David Wernhart on 09.02.20.
// Copyright © 2020 David Wernhart. All rights reserved.
//
import Cocoa
import SwiftUI
import ServiceManagement
import Foundation
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
//var window: NSWindow!
var statusBarItem: NSStatusItem!
var popover: NSPopover!
func applicationDidFinishLaunching(_ aNotification: Notification) {
let contentView = ContentView()
// Create the popover
let popover = NSPopover()
popover.contentSize = NSSize(width: 400, height: 600)
popover.behavior = .transient
popover.contentViewController = NSHostingController(rootView: contentView)
self.popover = popover
let statusBar = NSStatusBar.system
statusBarItem = statusBar.statusItem(
withLength: NSStatusItem.squareLength)
statusBarItem.button?.title = "🍝"
if let button = self.statusBarItem.button {
button.action = #selector(togglePopover(_:))
}
Helper.instance.checkHelperVersion()
}
@objc func togglePopover(_ sender: AnyObject?) {
self.popover.contentViewController?.view.window?.becomeKey()
if let button = self.statusBarItem.button {
if self.popover.isShown {
self.popover.performClose(sender)
} else {
self.popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY)
}
}
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
}