[F] Get tone name through list rather than adding another field to Alarm
This commit is contained in:
@@ -81,7 +81,7 @@ class AlarmTableCell: UITableViewCell
|
|||||||
descriptionText.text = "- " + alarm.text
|
descriptionText.text = "- " + alarm.text
|
||||||
enable.isOn = alarm.enabled
|
enable.isOn = alarm.enabled
|
||||||
wvmText.text = alarm.wakeMethod.name
|
wvmText.text = alarm.wakeMethod.name
|
||||||
toneLabel.text = alarm.toneName
|
toneLabel.text = ringtones.first { $0.tone.description == alarm.alarmTone.description }?.name
|
||||||
|
|
||||||
// Display Hour, Minute, and AM or PM
|
// Display Hour, Minute, and AM or PM
|
||||||
ampm.text = alarm.hour < 12 || alarm.hour == 24 ? "AM" : "PM"
|
ampm.text = alarm.hour < 12 || alarm.hour == 24 ? "AM" : "PM"
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ class Alarm: Codable, Equatable
|
|||||||
var wakeMethod: WVM
|
var wakeMethod: WVM
|
||||||
var alarmTone: SystemSoundID
|
var alarmTone: SystemSoundID
|
||||||
var notificationID: String
|
var notificationID: String
|
||||||
var toneName: String
|
|
||||||
|
|
||||||
/// What days does it repeat (Sun, Mon, Tue, Wed, Thu, Fri, Sat)
|
/// What days does it repeat (Sun, Mon, Tue, Wed, Thu, Fri, Sat)
|
||||||
var repeats: [Bool]
|
var repeats: [Bool]
|
||||||
@@ -111,7 +110,6 @@ class Alarm: Codable, Equatable
|
|||||||
self.lastActivate = lastActivate
|
self.lastActivate = lastActivate
|
||||||
self.alarmTone = alarmTone
|
self.alarmTone = alarmTone
|
||||||
self.notificationID = "notification.id.\(Int.random(in: 1...Int.max))"
|
self.notificationID = "notification.id.\(Int.random(in: 1...Int.max))"
|
||||||
self.toneName = toneName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Does it automatically disable after activating once
|
/// Does it automatically disable after activating once
|
||||||
@@ -160,7 +158,7 @@ class Alarms: Codable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Read alarms from local storage
|
/// Read alarms from local storage
|
||||||
func localRead() { list = JSON.parse([Alarm].self, localStorage.string(forKey: "alarms")!) ?? []}
|
func localRead() { list = JSON.parse([Alarm].self, localStorage.string(forKey: "alarms")!)! }
|
||||||
|
|
||||||
/// Read an alarm object from local storage
|
/// Read an alarm object from local storage
|
||||||
static func fromLocal() -> Alarms { return Alarms().apply { $0.localRead() } }
|
static func fromLocal() -> Alarms { return Alarms().apply { $0.localRead() } }
|
||||||
|
|||||||
Reference in New Issue
Block a user