Initial, holiday fun
This commit is contained in:
commit
abcab0c509
18 changed files with 2638 additions and 0 deletions
44
four/AppDelegate.swift
Normal file
44
four/AppDelegate.swift
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// AppDelegate.swift
|
||||
// four
|
||||
//
|
||||
// Created by Ryan McGrath on 12/23/18.
|
||||
// Copyright © 2018 Ryan McGrath. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
lazy var popover: NSPopover = {
|
||||
return NSPopover()
|
||||
}()
|
||||
|
||||
lazy var statusItem: NSStatusItem = {
|
||||
return NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
|
||||
}()
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
popover.behavior = .transient
|
||||
popover.appearance = NSAppearance.current
|
||||
popover.contentSize = CGSize(width: 300.0, height: 300.0)
|
||||
popover.contentViewController = ViewController()
|
||||
|
||||
let statusBarIcon = Icons.statusBarIcon()
|
||||
statusBarIcon.isTemplate = true
|
||||
statusItem.button?.image = statusBarIcon
|
||||
statusItem.button?.alternateImage = statusBarIcon
|
||||
statusItem.button?.action = #selector(togglePopover)
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
}
|
||||
|
||||
@objc
|
||||
func togglePopover(sender: Any?) {
|
||||
if(popover.isShown) {
|
||||
popover.performClose(sender)
|
||||
} else {
|
||||
popover.show(relativeTo: statusItem.button!.bounds, of: statusItem.button!, preferredEdge: .minY)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in a new issue