Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LoopFollow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@
knownRegions = (
en,
Base,
tr,
);
mainGroup = FC97880B2485969B00A7906C;
packageReferences = (
Expand Down
3 changes: 2 additions & 1 deletion LoopFollow/Alarm/AddAlarm/AddAlarmSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ struct AddAlarmSheet: View {
private func matches(_ type: AlarmType) -> Bool {
let query = searchText.trimmingCharacters(in: .whitespacesAndNewlines)
guard !query.isEmpty else { return true }
return type.rawValue.localizedCaseInsensitiveContains(query)
return type.displayName.localizedCaseInsensitiveContains(query)
|| type.rawValue.localizedCaseInsensitiveContains(query)
|| type.blurb.localizedCaseInsensitiveContains(query)
|| type.group.rawValue.localizedCaseInsensitiveContains(query)
}
Expand Down
2 changes: 1 addition & 1 deletion LoopFollow/Alarm/AddAlarm/AlarmTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct AlarmTile: View {
Image(systemName: type.icon)
.font(.title2)
.foregroundColor(.accentColor)
Text(type.rawValue)
Text(type.displayName)
.font(.subheadline)
.multilineTextAlignment(.center)
.lineLimit(2)
Expand Down
12 changes: 9 additions & 3 deletions LoopFollow/Alarm/Alarm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ protocol DayNightDisplayable {

extension DayNightDisplayable where Self: RawRepresentable, Self.RawValue == String {
var displayName: String {
rawValue == "always" ? "Day & Night" : rawValue.capitalized
switch rawValue {
case "always": String(localized: "Day & Night", comment: "Alarm schedule option: at any time of day")
case "day": String(localized: "Day", comment: "Alarm schedule option: daytime only")
case "night": String(localized: "Night", comment: "Alarm schedule option: nighttime only")
case "never": String(localized: "Never", comment: "Alarm schedule option: never")
default: rawValue.capitalized
}
}
}

Expand Down Expand Up @@ -277,7 +283,7 @@ struct Alarm: Identifiable, Codable, Equatable {
}
}()

AlarmManager.shared.sendNotification(title: type.rawValue, actionTitle: snoozeDuration == 0 ? "Acknowledge" : "Snooze")
AlarmManager.shared.sendNotification(title: type.displayName, actionTitle: snoozeDuration == 0 ? "Acknowledge" : "Snooze")

if playSound {
AlarmSound.setSoundFile(soundFile)
Expand All @@ -289,7 +295,7 @@ struct Alarm: Identifiable, Codable, Equatable {

init(type: AlarmType) {
self.type = type
name = type.rawValue
name = type.displayName

switch type {
case .buildExpire:
Expand Down
2 changes: 1 addition & 1 deletion LoopFollow/Alarm/AlarmEditing/AlarmEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct AlarmEditor: View {
}
}
}
.navigationTitle(alarm.type.rawValue)
.navigationTitle(alarm.type.displayName)
}
.preferredColorScheme(Storage.shared.appearanceMode.value.colorScheme)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ struct HighBgAlarmEditor: View {

Section(
header: Text("FALLING BG"),
footer: Text("Stay silent while BG is falling. The alert only sounds "
+ "when the latest reading is flat or still rising.")
footer: Text("Stay silent while BG is falling. The alert only sounds when the latest reading is flat or still rising.")
) {
Toggle("Skip if BG is falling", isOn: $alarm.suppressIfFalling)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ struct LowBgAlarmEditor: View {

Section(
header: Text("RISING BG"),
footer: Text("Stay silent while BG is rising. The alert only sounds "
+ "when the latest reading is flat or still falling.")
footer: Text("Stay silent while BG is rising. The alert only sounds when the latest reading is flat or still falling.")
) {
Toggle("Skip if BG is rising", isOn: $alarm.suppressIfRising)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ struct PhoneBatteryAlarmEditor: View {

Section(
header: Text("CHARGING"),
footer: Text("Stay silent while the phone is charging. Requires the "
+ "uploader to report charging status; if it doesn't, the alert still sounds.")
footer: Text("Stay silent while the phone is charging. Requires the uploader to report charging status; if it doesn't, the alert still sounds.")
) {
Toggle("Skip while charging", isOn: $alarm.suppressIfCharging)
}
Expand Down
1 change: 1 addition & 0 deletions LoopFollow/Alarm/AlarmListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct AlarmListView: View {
let query = searchText.trimmingCharacters(in: .whitespacesAndNewlines)
guard !query.isEmpty else { return true }
return alarm.name.localizedCaseInsensitiveContains(query)
|| alarm.type.displayName.localizedCaseInsensitiveContains(query)
|| alarm.type.rawValue.localizedCaseInsensitiveContains(query)
}

Expand Down
4 changes: 1 addition & 3 deletions LoopFollow/Alarm/AlarmSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ struct AlarmSettingsView: View {

Section(
header: Text("Day / Night Schedule"),
footer: Text("Pick when your day period begins and when your night period begins. " +
"Any time from your Day-starts time up until your Night-starts time will count as day; " +
"from Night-starts until the next Day-starts will count as night.")
footer: Text("Pick when your day period begins and when your night period begins. Any time from your Day-starts time up until your Night-starts time will count as day; from Night-starts until the next Day-starts will count as night.")
) {
DatePicker(
"Day starts",
Expand Down
33 changes: 33 additions & 0 deletions LoopFollow/Alarm/AlarmType/AlarmType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,36 @@ extension AlarmType {
}
}
}

extension AlarmType {
/// User-facing, localized name. `rawValue` is persisted in Storage and must never be
/// shown to the user or translated; every display site goes through this property.
var displayName: String {
switch self {
case .temporary: String(localized: "Temporary Alert", comment: "Alarm type name")
case .iob: String(localized: "IOB Alert", comment: "Alarm type name")
case .cob: String(localized: "COB Alert", comment: "Alarm type name")
case .low: String(localized: "Low BG Alert", comment: "Alarm type name")
case .high: String(localized: "High BG Alert", comment: "Alarm type name")
case .fastDrop: String(localized: "Fast Drop Alert", comment: "Alarm type name")
case .fastRise: String(localized: "Fast Rise Alert", comment: "Alarm type name")
case .missedReading: String(localized: "Missed Reading Alert", comment: "Alarm type name")
case .notLooping: String(localized: "Not Looping Alert", comment: "Alarm type name")
case .missedBolus: String(localized: "Missed Bolus Alert", comment: "Alarm type name")
case .futureCarbs: String(localized: "Future Carbs Alert", comment: "Alarm type name")
case .sensorChange: String(localized: "Sensor Change Alert", comment: "Alarm type name")
case .pumpChange: String(localized: "Pump Change Alert", comment: "Alarm type name")
case .pump: String(localized: "Pump Insulin Alert", comment: "Alarm type name")
case .pumpBattery: String(localized: "Pump Battery Alert", comment: "Alarm type name")
case .battery: String(localized: "Low Battery", comment: "Alarm type name")
case .batteryDrop: String(localized: "Battery Drop", comment: "Alarm type name")
case .recBolus: String(localized: "Rec. Bolus", comment: "Alarm type name: recommended bolus")
case .overrideStart: String(localized: "Override Started", comment: "Alarm type name")
case .overrideEnd: String(localized: "Override Ended", comment: "Alarm type name")
case .tempTargetStart: String(localized: "Temp Target Started", comment: "Alarm type name")
case .tempTargetEnd: String(localized: "Temp Target Ended", comment: "Alarm type name")
case .buildExpire: String(localized: "Looping app expiration", comment: "Alarm type name")
case .dbSize: String(localized: "Nightscout Database Size", comment: "Alarm type name")
}
}
}
2 changes: 1 addition & 1 deletion LoopFollow/Remote/LoopAPNS/LoopAPNSBolusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct LoopAPNSBolusView: View {
Text("\(String(format: "%.2f", recommendedBolus))U")
.font(.headline)
.foregroundColor(.primary)
Text("Calculated \(minutesSinceCalculation) minute\(minutesSinceCalculation == 1 ? "" : "s") ago")
Text("Calculated \(minutesSinceCalculation) minutes ago")
.font(.caption)
.foregroundColor(.secondary)
}
Expand Down
2 changes: 1 addition & 1 deletion LoopFollow/Remote/TRC/BolusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ struct BolusView: View {
HStack {
VStack(alignment: .leading, spacing: 4) {
Text("\(InsulinFormatter.shared.string(steppedRec))U")
Text("Calculated \(mins) minute\(mins == 1 ? "" : "s") ago")
Text("Calculated \(mins) minutes ago")
.font(.caption)
.foregroundColor(.secondary)
}
Expand Down
Loading