Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
liambuchanan committed Feb 20, 2018
1 parent 8ca95b5 commit 6d6c184
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 677 deletions.
2 changes: 2 additions & 0 deletions TalkTime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = TalkTime/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_BUNDLE_IDENTIFIER = net.liamb.TalkTime;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
Expand All @@ -279,6 +280,7 @@
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = TalkTime/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
PRODUCT_BUNDLE_IDENTIFIER = net.liamb.TalkTime;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
Expand Down
51 changes: 45 additions & 6 deletions TalkTime/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,65 @@
// AppDelegate.swift
// TalkTime
//
// Created by Liam Buchanan on 1/14/18.
// Created by Liam Buchanan on 2/19/18.
// Copyright © 2018 Liam Buchanan. All rights reserved.
//

import Cocoa

let TIME_INTERVALS: [TimeInterval] = [10, 30, 60, 120, 300]

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var settingsSlider: NSSlider!
@IBOutlet weak var settingsSliderLabel: NSTextFieldCell!
@IBOutlet weak var statusMenu: NSMenu!

@IBOutlet weak var window: NSWindow!

var speechSynth: NSSpeechSynthesizer!
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
var timeElapsed: TimeInterval! = 0
var timeInterval: TimeInterval! = TIME_INTERVALS[0]
var timer: Timer!

func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
statusItem.menu = statusMenu
statusItem.image = NSImage(named: NSImage.Name(rawValue: "statusIcon"))
statusItem.image?.isTemplate = true
settingsSliderLabel.title = String(Int(timeInterval)) + " seconds"
speechSynth = NSSpeechSynthesizer.init()
}

func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
if (timer != nil) {
timer.invalidate()
}
}

@IBAction func sliderActionReceived(_ sender: NSSlider) {
timeInterval = TIME_INTERVALS[Int(sender.intValue)]
settingsSliderLabel.title = String(Int(timeInterval)) + " seconds"
}

}
@IBAction func startClicked(_ sender: NSMenuItem) {
timer = Timer.scheduledTimer(timeInterval: timeInterval, target: self, selector: #selector(timerFired), userInfo: nil, repeats: true)
speechSynth.startSpeaking("start")
settingsSlider.isEnabled = false
}

@IBAction func stopClicked(_ sender: NSMenuItem) {
if (timer != nil) {
timer.invalidate()
}
timeElapsed = 0
settingsSlider.isEnabled = true
}

@IBAction func quitClicked(_ sender: NSMenuItem) {
NSApplication.shared.terminate(self)
}

@objc func timerFired() {
timeElapsed = timeElapsed + timeInterval
speechSynth.startSpeaking(String(Int(timeElapsed)) + " seconds")
}
}
15 changes: 10 additions & 5 deletions TalkTime/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"idiom" : "mac",
"filename" : "metronome_16px.png",
"scale" : "1x"
},
{
Expand All @@ -11,8 +12,9 @@
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"idiom" : "mac",
"filename" : "metronome_32px.png",
"scale" : "1x"
},
{
Expand All @@ -21,8 +23,9 @@
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"idiom" : "mac",
"filename" : "metronome_128.png",
"scale" : "1x"
},
{
Expand All @@ -31,8 +34,9 @@
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"idiom" : "mac",
"filename" : "metronome_256.png",
"scale" : "1x"
},
{
Expand All @@ -41,8 +45,9 @@
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"idiom" : "mac",
"filename" : "metronome_512.png",
"scale" : "1x"
},
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions TalkTime/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
22 changes: 22 additions & 0 deletions TalkTime/Assets.xcassets/statusIcon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "metronome_16px.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "metronome_32px.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6d6c184

Please sign in to comment.