| @@ -0,0 +1,41 @@ | ||
| // | ||
| // ChangeDateViewController.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/3. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class ChangeDateViewController: UIViewController { | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // Do any additional setup after loading the view. | ||
| } | ||
|
|
||
| override func viewDidAppear(animated: Bool) { | ||
| super.viewDidAppear(animated) | ||
|
|
||
| UITabBar.appearance().tintColor = UIColor(red:0.600, green:0.784, blue:0.447, alpha:1) | ||
| } | ||
|
|
||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| // Dispose of any resources that can be recreated. | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| // MARK: - Navigation | ||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | ||
| // Get the new view controller using segue.destinationViewController. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } |
| @@ -0,0 +1,66 @@ | ||
| // | ||
| // DayQuestionareViewController.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/5. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class DayQuestionareViewController: UIViewController { | ||
|
|
||
| @IBOutlet weak var titleLabel: UILabel! | ||
| @IBOutlet weak var subtitleLabel: UILabel! | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // Do any additional setup after loading the view. | ||
| printFonts() | ||
| } | ||
|
|
||
| @IBAction func startButtonClicked(sender: AnyObject) { | ||
| // check date now | ||
| let formatter = NSDateFormatter() | ||
| // formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ" | ||
| formatter.dateFormat = "HH:mm" | ||
|
|
||
| print(formatter.stringFromDate(NSDate())) | ||
|
|
||
| QuestionareNotification.clearNotification() | ||
| QuestionareNotification.setNotificationAfterFewDays(2) | ||
| } | ||
|
|
||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| // Dispose of any resources that can be recreated. | ||
| } | ||
|
|
||
| func printFonts() { | ||
| let fontFamilyNames = UIFont.familyNames() | ||
| for familyName in fontFamilyNames { | ||
| print("------------------------------") | ||
| print("Font Family Name = [\(familyName)]") | ||
| let names = UIFont.fontNamesForFamilyName(familyName) | ||
| print("Font Names = [\(names)]") | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| // MARK: - Navigation | ||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | ||
| // Get the new view controller using segue.destinationViewController. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } | ||
|
|
||
| extension NSDate { | ||
| var timeOfLocalTimeZone: NSDate { | ||
| return NSDate() | ||
| } | ||
| } |
| @@ -0,0 +1,41 @@ | ||
| // | ||
| // DesignerViewController.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/3. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class DesignerViewController: UIViewController { | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // Do any additional setup after loading the view. | ||
| } | ||
|
|
||
| override func viewDidAppear(animated: Bool) { | ||
| super.viewDidAppear(animated) | ||
|
|
||
| UITabBar.appearance().tintColor = UIColor(red:0.729, green:0.600, blue:0.776, alpha:1) | ||
| } | ||
|
|
||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| // Dispose of any resources that can be recreated. | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| // MARK: - Navigation | ||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | ||
| // Get the new view controller using segue.destinationViewController. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } |
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "closeButton.png", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "closeButton@2x.png", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "closeButton@3x.png", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "version" : 1, | ||
| "author" : "xcode" | ||
| } | ||
| } |
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "designer.png", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "designer@2x.png", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "designer@3x.png", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "version" : 1, | ||
| "author" : "xcode" | ||
| } | ||
| } |
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "doques.png", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "doques@2x.png", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "doques@3x.png", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "version" : 1, | ||
| "author" : "xcode" | ||
| } | ||
| } |
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "explain.png", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "explain@2x.png", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "explain@3x.png", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "version" : 1, | ||
| "author" : "xcode" | ||
| } | ||
| } |
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "progress.png", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "progress@2x.png", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "progress@3x.png", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "version" : 1, | ||
| "author" : "xcode" | ||
| } | ||
| } |
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "resetDate.png", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "resetDate@2x.png", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "resetDate@3x.png", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "version" : 1, | ||
| "author" : "xcode" | ||
| } | ||
| } |
| @@ -19,7 +19,7 @@ | ||
| <key>CFBundleSignature</key> | ||
| <string>????</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>4</string> | ||
| <key>LSRequiresIPhoneOS</key> | ||
| <true/> | ||
| <key>UILaunchStoryboardName</key> | ||
| @@ -0,0 +1,41 @@ | ||
| // | ||
| // IntroductionViewController.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/3. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class IntroductionViewController: UIViewController { | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // Do any additional setup after loading the view. | ||
| } | ||
|
|
||
| override func viewDidAppear(animated: Bool) { | ||
| super.viewDidAppear(animated) | ||
|
|
||
| UITabBar.appearance().tintColor = UIColor(red:0.369, green:0.761, blue:0.776, alpha:1) | ||
| } | ||
|
|
||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| // Dispose of any resources that can be recreated. | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| // MARK: - Navigation | ||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | ||
| // Get the new view controller using segue.destinationViewController. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } |
| @@ -0,0 +1,41 @@ | ||
| // | ||
| // MainQuestionareViewController.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/3. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class MainQuestionareViewController: UIViewController { | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // Do any additional setup after loading the view. | ||
| } | ||
|
|
||
| override func viewDidAppear(animated: Bool) { | ||
| super.viewDidAppear(animated) | ||
|
|
||
| UITabBar.appearance().tintColor = UIColor(red:0.161, green:0.733, blue:0.937, alpha:1) | ||
| } | ||
|
|
||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| // Dispose of any resources that can be recreated. | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| // MARK: - Navigation | ||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | ||
| // Get the new view controller using segue.destinationViewController. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } |
| @@ -0,0 +1,41 @@ | ||
| // | ||
| // ProgressViewController.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/3. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class ProgressViewController: UIViewController { | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // Do any additional setup after loading the view. | ||
| } | ||
|
|
||
| override func viewDidAppear(animated: Bool) { | ||
| super.viewDidAppear(animated) | ||
|
|
||
| UITabBar.appearance().tintColor = UIColor(red:0.424, green:0.573, blue:0.800, alpha:1) | ||
| } | ||
|
|
||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| // Dispose of any resources that can be recreated. | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| // MARK: - Navigation | ||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | ||
| // Get the new view controller using segue.destinationViewController. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } |
| @@ -0,0 +1,111 @@ | ||
| // | ||
| // QUestionareNotification.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/6. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
| import Foundation | ||
|
|
||
| class QuestionareNotification { | ||
|
|
||
| class func clearNotification() { | ||
| UIApplication.sharedApplication().cancelAllLocalNotifications() | ||
| } | ||
|
|
||
| class func setNotificationAfterFewDays(days: Int) { | ||
| let calendar = NSCalendar.currentCalendar() | ||
| let component = NSDateComponents() | ||
| let now = NSDate() | ||
| component.year = now.year | ||
| component.month = now.month | ||
| component.day = now.day + days | ||
| component.hour = 9 | ||
| component.minute = 0 | ||
| component.second = 0 | ||
| calendar.timeZone = NSTimeZone.defaultTimeZone() | ||
| var dateToFire = calendar.dateFromComponents(component) | ||
|
|
||
| let localNotification = UILocalNotification() | ||
| localNotification.timeZone = NSTimeZone.defaultTimeZone() | ||
| localNotification.fireDate = dateToFire | ||
| localNotification.alertBody = "請填寫早上問卷!" | ||
| localNotification.soundName = "default" | ||
|
|
||
| UIApplication.sharedApplication().scheduleLocalNotification(localNotification) | ||
|
|
||
| component.hour = 14 | ||
| print(component) | ||
| dateToFire = calendar.dateFromComponents(component) | ||
| let localNotification2 = UILocalNotification() | ||
| localNotification2.timeZone = NSTimeZone.defaultTimeZone() | ||
| localNotification2.fireDate = dateToFire | ||
| localNotification2.alertBody = "請填寫中午問卷!" | ||
| localNotification2.soundName = "default" | ||
| UIApplication.sharedApplication().scheduleLocalNotification(localNotification2) | ||
|
|
||
| component.hour = 18 | ||
| print(component) | ||
| dateToFire = calendar.dateFromComponents(component) | ||
| let localNotification3 = UILocalNotification() | ||
| localNotification3.timeZone = NSTimeZone.defaultTimeZone() | ||
| localNotification3.fireDate = dateToFire | ||
| localNotification3.alertBody = "請填寫晚上問卷!" | ||
| localNotification3.soundName = "default" | ||
| UIApplication.sharedApplication().scheduleLocalNotification(localNotification3) | ||
|
|
||
| print(UIApplication.sharedApplication().scheduledLocalNotifications?.count) | ||
| } | ||
| } | ||
|
|
||
| extension NSDate { | ||
| var year: Int { | ||
| let formatter = NSDateFormatter() | ||
| // formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ" | ||
| formatter.dateFormat = "yyyy" | ||
| let year = Int(formatter.stringFromDate(self)) | ||
| return year! | ||
| } | ||
|
|
||
| var month: Int { | ||
| let formatter = NSDateFormatter() | ||
| // formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ" | ||
| formatter.dateFormat = "MM" | ||
| let month = Int(formatter.stringFromDate(self)) | ||
| return month! | ||
| } | ||
|
|
||
| var day: Int { | ||
| let formatter = NSDateFormatter() | ||
| // formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ" | ||
| formatter.dateFormat = "dd" | ||
| let day = Int(formatter.stringFromDate(self)) | ||
| return day! | ||
| } | ||
|
|
||
| var hour: Int { | ||
| let formatter = NSDateFormatter() | ||
| // formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ" | ||
| formatter.dateFormat = "HH" | ||
| let h = Int(formatter.stringFromDate(self)) | ||
| return h! | ||
| } | ||
|
|
||
| var minute: Int { | ||
| let formatter = NSDateFormatter() | ||
| // formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ" | ||
| formatter.dateFormat = "mm" | ||
| let m = Int(formatter.stringFromDate(self)) | ||
| return m! | ||
| } | ||
|
|
||
| var second: Int { | ||
| let formatter = NSDateFormatter() | ||
| // formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ" | ||
| formatter.dateFormat = "ss" | ||
| let s = Int(formatter.stringFromDate(self)) | ||
| return s! | ||
| } | ||
| } |
| @@ -0,0 +1,63 @@ | ||
| // | ||
| // ResetNotiDateViewController.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/7. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class ResetNotiDateViewController: UIViewController { | ||
|
|
||
| @IBOutlet weak var dayTextField: UITextField! | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| // Do any additional setup after loading the view. | ||
| dayTextField.delegate = self | ||
| let tap = UITapGestureRecognizer(target: self, action: "tap") | ||
| self.view.addGestureRecognizer(tap) | ||
| } | ||
|
|
||
| func tap() { | ||
| self.dayTextField.resignFirstResponder() | ||
| self.view.endEditing(true) | ||
| } | ||
|
|
||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| // Dispose of any resources that can be recreated. | ||
| } | ||
|
|
||
| @IBAction func closeButtonClicked() { | ||
| self.dismissViewControllerAnimated(true, completion: nil) | ||
| } | ||
|
|
||
| @IBAction func resetDateClicked() { | ||
| if let dayToSet = Int(dayTextField.text!) { | ||
| UserSetting.setNextWorkingDay(dayToSet) | ||
| closeButtonClicked() | ||
| } | ||
| } | ||
| /* | ||
| // MARK: - Navigation | ||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | ||
| // Get the new view controller using segue.destinationViewController. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } | ||
|
|
||
| extension ResetNotiDateViewController: UITextFieldDelegate { | ||
| func textFieldShouldReturn(textField: UITextField) -> Bool { | ||
| if textField == dayTextField { | ||
| dayTextField.resignFirstResponder() | ||
| } | ||
| return true | ||
| } | ||
| } |
| @@ -0,0 +1,59 @@ | ||
| // | ||
| // ShowDetailNotiDateViewController.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/7. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class ShowDetailNotiDateViewController: UIViewController { | ||
|
|
||
| @IBOutlet weak var contentLabel: UILabel! | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
|
|
||
| setView() | ||
|
|
||
| } | ||
|
|
||
| override func viewDidAppear(animated: Bool) { | ||
| super.viewDidAppear(animated) | ||
|
|
||
| setView() | ||
| } | ||
|
|
||
| func setView() { | ||
| // Do any additional setup after loading the view. | ||
| let nextWorkingDay = UserSetting().nextWorkingDay | ||
| let formatter = NSDateFormatter() | ||
| // formatter.dateFormat = "yyyy-MM-dd HH:mm:ss ZZZ" | ||
| formatter.dateFormat = "MM-dd" | ||
| if nextWorkingDay != nil { | ||
| let s = formatter.stringFromDate(nextWorkingDay!) | ||
| contentLabel.text = "目前設定的下次上班日:" + s | ||
| } else { | ||
| contentLabel.text = "目前設定的下次上班日:" + "尚未設定" | ||
| } | ||
| } | ||
| override func didReceiveMemoryWarning() { | ||
| super.didReceiveMemoryWarning() | ||
| // Dispose of any resources that can be recreated. | ||
| } | ||
|
|
||
| @IBAction func closeButtonClicked() { | ||
| self.dismissViewControllerAnimated(true, completion: nil) | ||
| } | ||
| /* | ||
| // MARK: - Navigation | ||
| // In a storyboard-based application, you will often want to do a little preparation before navigation | ||
| override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | ||
| // Get the new view controller using segue.destinationViewController. | ||
| // Pass the selected object to the new view controller. | ||
| } | ||
| */ | ||
|
|
||
| } |
| @@ -0,0 +1,26 @@ | ||
| // | ||
| // UserSetting.swift | ||
| // AnnGiNoCoreData | ||
| // | ||
| // Created by David on 2015/10/7. | ||
| // Copyright © 2015年 David. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| class UserSetting { | ||
| struct Key { | ||
| static let nextWorkingDay = "nextWorkingDay" | ||
| } | ||
| var nextWorkingDay: NSDate? { | ||
| get { | ||
| let ud = NSUserDefaults.standardUserDefaults() | ||
| return ud.objectForKey(Key.nextWorkingDay) as? NSDate | ||
| } | ||
| } | ||
| class func setNextWorkingDay(day: Int) { | ||
| let nextWorkingDay = NSDate().dateByAddingTimeInterval(60*60*24*Double(day)) | ||
| let ud = NSUserDefaults.standardUserDefaults() | ||
| ud.setObject(nextWorkingDay, forKey: Key.nextWorkingDay) | ||
| } | ||
| } |