diff --git a/ProjectClock/AppDelegate.swift b/ProjectClock/AppDelegate.swift index 9306d1c..7649be6 100644 --- a/ProjectClock/AppDelegate.swift +++ b/ProjectClock/AppDelegate.swift @@ -15,7 +15,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Init default settings localStorage.register(defaults: [ - "alarms": JSON.stringify([Alarm(enabled: true, hour: 7, minute: 20, text: "Wake up lol", wakeMethod: wvms[0])])! + "alarms": JSON.stringify([Alarm(hour: 7, minute: 20, text: "Wake up lol", wakeMethod: wvms[0])])! ]) return true diff --git a/ProjectClock/Models.swift b/ProjectClock/Models.swift index 3a7a232..9bdfeb4 100644 --- a/ProjectClock/Models.swift +++ b/ProjectClock/Models.swift @@ -36,19 +36,27 @@ let wvms = [ WVM(name: "Smash", desc: "It'll never truns off"), ] -struct Alarm: Codable +class Alarm: Codable { - var enabled: Bool + var enabled: Bool = true var hour: Int // Hour (24) var minute: Int var text: String var wakeMethod: WVM + init(hour: Int, minute: Int, text: String, wakeMethod: WVM) + { + self.hour = hour + self.minute = minute + self.text = text + self.wakeMethod = wakeMethod + } + /// What days does it repeat (Sun, Mon, Tue, Wed, Thu, Fri, Sat) var repeats: [Bool] = [false, true, true, true, true, true, false] /// Does it automatically disable after activating once - var oneTime = true + var oneTime = false /// When is the last time that the alarm went off var lastActivate: Date = Date() diff --git a/ProjectClock/TestingViewController.swift b/ProjectClock/TestingViewController.swift index 459c1cc..769831f 100644 --- a/ProjectClock/TestingViewController.swift +++ b/ProjectClock/TestingViewController.swift @@ -32,7 +32,7 @@ class TestingViewController: UIViewController //Sends a test notification @IBAction func sendNotification(_ sender: Any) { - let alarm = Alarm(enabled: true, hour: 7, minute: 20, text: "Good morning!", wakeMethod: WVM(name: "walking", desc: "Walk")) + let alarm = Alarm(hour: 7, minute: 20, text: "Good morning!", wakeMethod: WVM(name: "walking", desc: "Walk")) let content = UNMutableNotificationContent() @@ -64,7 +64,7 @@ class TestingViewController: UIViewController { let (h, m, _) = Date().getHMS() let alarms = Alarms.fromLocal() - alarms.list.append(Alarm(enabled: true, hour: h, minute: m, text: "Test alarm - \(h * m)", wakeMethod: wvms[0])) + alarms.list.append(Alarm(hour: h, minute: m, text: "Test alarm - \(h * m)", wakeMethod: wvms[0])) alarms.localSave() } }