diff options
| author | FivePixels <o5pxels@gmail.com> | 2019-01-05 17:41:03 -0600 |
|---|---|---|
| committer | FivePixels <o5pxels@gmail.com> | 2019-01-05 17:41:03 -0600 |
| commit | ed4852501935cf85ebded5f58d0092925e38082a (patch) | |
| tree | c94163f0c02dcb48592f52a1c2d5ecf3b5f5462f /DWA140Menu/ViewController.swift | |
| parent | f58a1eea0c004db0966858b46884e5f78fd40780 (diff) | |
| download | dwa140shortcut-ed4852501935cf85ebded5f58d0092925e38082a.tar.xz dwa140shortcut-ed4852501935cf85ebded5f58d0092925e38082a.zip | |
Icons! A window! And many changes :)
Diffstat (limited to 'DWA140Menu/ViewController.swift')
| -rw-r--r-- | DWA140Menu/ViewController.swift | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/DWA140Menu/ViewController.swift b/DWA140Menu/ViewController.swift index 79d01c9..ea3fe55 100644 --- a/DWA140Menu/ViewController.swift +++ b/DWA140Menu/ViewController.swift @@ -2,26 +2,62 @@ // ViewController.swift // DWA140Menu // -// Created by Dylan Bolger on 9/3/18. // Copyright © 2018 Dylan Bolger. All rights reserved. // import Cocoa class ViewController: NSViewController { - - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. + + @IBOutlet weak var versionLabel: NSTextField! + @IBOutlet weak var loginButton: NSButton! + @IBOutlet weak var awesomeSubtitle: NSTextField! + @IBOutlet weak var loginSubtitle: NSTextField! + + let defaults : UserDefaults = .standard + let delegate = NSApplication.shared.delegate as! AppDelegate + var loginLaunch = UserDefaults.standard.bool(forKey: "loginLaunch") + + override func viewDidAppear() { + loginButton.state = loginLaunch ? .on : .off + versionLabel.stringValue = "Version " + (Bundle.main.infoDictionary!["CFBundleShortVersionString"] as? String)! + if loginLaunch { + loginSubtitle.stringValue = "This application will launch when you login." + } } - - override var representedObject: Any? { - didSet { - // Update the view, if already loaded. + + func toggleLoginLaunch() { + loginButton.state = !loginLaunch ? .on : .off + defaults.set(!loginLaunch, forKey: "loginLaunch") + loginLaunch = !loginLaunch + } + + @IBAction func loginButtonPressed(_ sender: NSButton) { + toggleLoginLaunch() + if loginLaunch { + loginSubtitle.stringValue = "This application will launch when you login." + } else { + loginSubtitle.stringValue = "An even easier way to get connected, faster." } } - - + @IBAction func triedAwesome(_ sender: NSButton) { + // it's an invisible button on top of the disabled checkbox. + awesomeSubtitle.stringValue = "You can't change the fact that you're awesome." + DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) { + self.awesomeSubtitle.stringValue = "It's just a fact." + } + } + + @IBAction func sourceButtonPressed(_ sender: NSButton) { + NSWorkspace.shared.open((URL(string:"https://github.com/fivepixels/dwa140shortcut") ?? nil)!) + } + + @IBAction func coffeePressed(_ sender: NSButton) { + NSWorkspace.shared.open((URL(string: "https://paypal.me/fivepixels") ?? nil)!) + } + + @IBAction func loveButtonPressed(_ sender: NSButton) { + NSWorkspace.shared.open((URL(string:"https://twitter.com/o5pxels") ?? nil)!) + } } |
