[O] Optimize alarm activation code
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
7C12BC7825BE25C000E5659C /* Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C12BC7725BE25C000E5659C /* Notification.swift */; };
|
||||
7C5DAE9C25AF812200E44C52 /* clock.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C5DAE9B25AF812200E44C52 /* clock.png */; };
|
||||
7C60741E25C11DC000B0A154 /* AlarmLogo1.png in Resources */ = {isa = PBXBuildFile; fileRef = 7C60741D25C11DC000B0A154 /* AlarmLogo1.png */; };
|
||||
7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* NotificationLogic.swift */; };
|
||||
7C83963625AF375B0027A94C /* AlarmActivationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963525AF375B0027A94C /* AlarmActivationLogic.swift */; };
|
||||
7C83963925AF68980027A94C /* DebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83963825AF68980027A94C /* DebugViewController.swift */; };
|
||||
7CD385A625BE4649007E9890 /* notif.caf in Resources */ = {isa = PBXBuildFile; fileRef = 7CD385A525BE4649007E9890 /* notif.caf */; };
|
||||
C7E638E825B88F8B00799512 /* MathExpressions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7E638E725B88F8B00799512 /* MathExpressions.swift */; };
|
||||
@@ -49,7 +49,7 @@
|
||||
7C60741D25C11DC000B0A154 /* AlarmLogo1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = AlarmLogo1.png; sourceTree = "<group>"; };
|
||||
7C83962D25AF34F00027A94C /* ProjectClock.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ProjectClock.entitlements; sourceTree = "<group>"; };
|
||||
7C83962F25AF34F10027A94C /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = System/Library/Frameworks/HealthKit.framework; sourceTree = SDKROOT; };
|
||||
7C83963525AF375B0027A94C /* NotificationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationLogic.swift; sourceTree = "<group>"; };
|
||||
7C83963525AF375B0027A94C /* AlarmActivationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmActivationLogic.swift; sourceTree = "<group>"; };
|
||||
7C83963825AF68980027A94C /* DebugViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugViewController.swift; sourceTree = "<group>"; };
|
||||
7CD385A525BE4649007E9890 /* notif.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = notif.caf; sourceTree = "<group>"; };
|
||||
C7E638E725B88F8B00799512 /* MathExpressions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MathExpressions.swift; sourceTree = "<group>"; };
|
||||
@@ -92,6 +92,7 @@
|
||||
4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */,
|
||||
4FD642DF25B4D5F30069171E /* AlarmActivationViewController.swift */,
|
||||
4FD642D225B48C380069171E /* AlarmActivator.swift */,
|
||||
7C83963525AF375B0027A94C /* AlarmActivationLogic.swift */,
|
||||
4FA419AE25AF93EC004CE0FC /* AlarmViewController.swift */,
|
||||
4FF0683E25A5F18700304E6B /* AppDelegate.swift */,
|
||||
4FF0684725A5F18800304E6B /* Assets.xcassets */,
|
||||
@@ -105,7 +106,6 @@
|
||||
4F509BD125AE22D100726227 /* Models.swift */,
|
||||
4F98955125A9260400F51321 /* Net.swift */,
|
||||
7C12BC7725BE25C000E5659C /* Notification.swift */,
|
||||
7C83963525AF375B0027A94C /* NotificationLogic.swift */,
|
||||
7C83962D25AF34F00027A94C /* ProjectClock.entitlements */,
|
||||
F0DF7C0625BCD9FC0064A26B /* StopwatchViewController.swift */,
|
||||
4FD642DA25B4B7F60069171E /* Utils.swift */,
|
||||
@@ -217,7 +217,7 @@
|
||||
4F509BD225AE22D100726227 /* Models.swift in Sources */,
|
||||
7C12BC7825BE25C000E5659C /* Notification.swift in Sources */,
|
||||
C7E638E825B88F8B00799512 /* MathExpressions.swift in Sources */,
|
||||
7C83963625AF375B0027A94C /* NotificationLogic.swift in Sources */,
|
||||
7C83963625AF375B0027A94C /* AlarmActivationLogic.swift in Sources */,
|
||||
4FD642E025B4D5F30069171E /* AlarmActivationViewController.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -44,25 +44,21 @@ class AlarmActivationViewController: UIViewController
|
||||
override func viewDidLoad()
|
||||
{
|
||||
super.viewDidLoad()
|
||||
//Set the time and date
|
||||
let date = Date()
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "MMM d, Y"
|
||||
|
||||
dateLabel.text = dateFormatter.string(from: date)
|
||||
// Set the time and date
|
||||
dateLabel.text = Date().str("MMM d, Y")
|
||||
timeLabel.text = currentAlarm?.timeText
|
||||
|
||||
dateFormatter.dateFormat = "hh:mm"
|
||||
timeLabel.text = dateFormatter.string(from: date)
|
||||
|
||||
|
||||
//Hide all inactive wakemethods
|
||||
// Hide all inactive wakemethods
|
||||
puzzleView.isHidden = true
|
||||
rpsView.isHidden = true
|
||||
shakeView.isHidden = true
|
||||
|
||||
// Play sound
|
||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
|
||||
setAlarmType()
|
||||
//print(MathExpression.random())
|
||||
|
||||
// Run alarm
|
||||
runAlarm()
|
||||
}
|
||||
|
||||
@objc func playSound()
|
||||
@@ -71,8 +67,10 @@ class AlarmActivationViewController: UIViewController
|
||||
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
|
||||
}
|
||||
|
||||
func setAlarmType()
|
||||
func runAlarm()
|
||||
{
|
||||
|
||||
|
||||
if let alarm = currentAlarm
|
||||
{
|
||||
switch alarm.wakeMethod.name {
|
||||
|
||||
@@ -13,10 +13,10 @@ import UIKit
|
||||
extension Date
|
||||
{
|
||||
/// Add toString to Date
|
||||
func str() -> String
|
||||
func str(_ format: String = "yyyy-MM-dd hh:mm:ss") -> String
|
||||
{
|
||||
let f = DateFormatter()
|
||||
f.dateFormat = "yyyy-MM-dd hh:mm:ss"
|
||||
f.dateFormat = format
|
||||
return f.string(from: self)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user