//
//  AppDelegate.swift
//  TRexAboutWindowController
//
//  Created by David Ehlen on 25.07.15.
//  Copyright © 2015 David Ehlen. All rights reserved.
//

import Cocoa
import TRexAboutWindowController

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    private lazy var aboutWindowController = TRexAboutWindowController()

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        // Insert code here to initialize your application
    }

    func applicationWillTerminate(_ aNotification: Notification) {
        // Insert code here to tear down your application
    }
    
    @IBAction func showAboutWindow(_ sender: Any) {
        guard let url = URL(string:"https://github.com/T-Rex-Editor/") else {
            print("Could not create URL!")
            return
        }
        aboutWindowController.appURL = url
        aboutWindowController.policyURL = url
        aboutWindowController.appName = "TRex-Editor"
        
        let font = NSFont(name: "HelveticaNeue", size: 11.0)
        let color = NSColor.tertiaryLabelColor
        let year = Calendar.current.component(.year, from: Date())
        let attribs = [
            NSAttributedString.Key.foregroundColor: color,
            NSAttributedString.Key.font: font!
        ]
        aboutWindowController.appCopyright = NSAttributedString(string: "Copyright (c) \(year) David Ehlen", attributes: attribs)
        
//        aboutWindowController.windowShouldHaveShadow = true
        aboutWindowController.showWindow(sender)
    }
}

