Skip to content

Commit

Permalink
Add all profile settings to card info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-b-m committed May 27, 2023
1 parent f7ecb89 commit 4d22482
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ extension OverrideProfilesConfig {
saveOverride.start = start as NSDecimalNumber
saveOverride.end = end as NSDecimalNumber
} else { saveOverride.smbIsAlwaysOff = false }
if smbMinutes != self.settingsManager.preferences.maxSMBBasalMinutes {
saveOverride.smbMinutes = smbMinutes as NSDecimalNumber
}
if uamMinutes != self.settingsManager.preferences.maxUAMSMBBasalMinutes {
saveOverride.uamMinutes = uamMinutes as NSDecimalNumber
}

saveOverride.smbMinutes = smbMinutes as NSDecimalNumber
saveOverride.uamMinutes = uamMinutes as NSDecimalNumber
}
try? self.coredataContext.save()
}
Expand Down Expand Up @@ -112,12 +109,9 @@ extension OverrideProfilesConfig {
saveOverride.start = start as NSDecimalNumber
saveOverride.end = end as NSDecimalNumber
} else { smbIsAlwaysOff = false }
if smbMinutes != self.settingsManager.preferences.maxSMBBasalMinutes {
saveOverride.smbMinutes = smbMinutes as NSDecimalNumber
}
if uamMinutes != self.settingsManager.preferences.maxUAMSMBBasalMinutes {
saveOverride.uamMinutes = uamMinutes as NSDecimalNumber
}

saveOverride.smbMinutes = smbMinutes as NSDecimalNumber
saveOverride.uamMinutes = uamMinutes as NSDecimalNumber
}
try? self.coredataContext.save()
}
Expand Down Expand Up @@ -155,14 +149,8 @@ extension OverrideProfilesConfig {
saveOverride.end = profile.end
} else { saveOverride.smbIsAlwaysOff = false }

let smb = (profile.smbMinutes ?? 30) as Decimal
if smb != self.settingsManager.preferences.maxSMBBasalMinutes {
saveOverride.smbMinutes = profile.smbMinutes
}
let uam = (profile.uamMinutes ?? 30) as Decimal
if uam != self.settingsManager.preferences.maxUAMSMBBasalMinutes {
saveOverride.uamMinutes = profile.uamMinutes
}
saveOverride.smbMinutes = smbMinutes as NSDecimalNumber
saveOverride.uamMinutes = uamMinutes as NSDecimalNumber
}
try? self.coredataContext.save()
}
Expand Down Expand Up @@ -195,12 +183,11 @@ extension OverrideProfilesConfig {
end = (overrideArray.first?.end ?? 0) as Decimal
}

let smb = (overrideArray.first?.smbMinutes ?? 30) as Decimal
if smb != self.settingsManager.preferences.maxSMBBasalMinutes {
if (overrideArray[0].smbMinutes as Decimal?) != nil {
smbMinutes = (overrideArray.first?.smbMinutes ?? 30) as Decimal
}
let uam = (overrideArray.first?.uamMinutes ?? 30) as Decimal
if uam != self.settingsManager.preferences.maxUAMSMBBasalMinutes {

if (overrideArray[0].uamMinutes as Decimal?) != nil {
uamMinutes = (overrideArray.first?.uamMinutes ?? 30) as Decimal
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ extension OverrideProfilesConfig {
let scheduledSMBstring = (preset.smbIsOff && preset.smbIsAlwaysOff) ? "Scheduled SMBs" : ""
let smbString = (preset.smbIsOff && scheduledSMBstring == "") ? "SMBs are off" : ""
let targetString = target != 0 ? "\(formatter.string(from: target as NSNumber)!)" : ""
let maxMinutesSMB = (preset.smbMinutes as Decimal?) != nil ? (preset.smbMinutes ?? 0) as Decimal : 0
let maxMinutesUAM = (preset.uamMinutes as Decimal?) != nil ? (preset.uamMinutes ?? 0) as Decimal : 0

let isfString = preset.isf ? "ISF" : ""
let crString = preset.cr ? "CR" : ""
let dash = crString != "" ? "/" : ""
let isfAndCRstring = isfString + dash + crString

if name != "" {
HStack {
Expand All @@ -303,25 +310,23 @@ extension OverrideProfilesConfig {
}
HStack(spacing: 5) {
Text(percent.formatted(.percent.grouping(.never).rounded().precision(.fractionLength(0))))
.foregroundColor(.secondary)
.font(.caption)
if targetString != "" {
Text(targetString)
.foregroundColor(.secondary)
.font(.caption)
Text(targetString != "" ? state.units.rawValue : "")
.foregroundColor(.secondary)
.font(.caption) }
if durationString != "" {
Text(durationString + (perpetual ? "" : "min"))
.foregroundColor(.secondary)
.font(.caption) }
}
if durationString != "" { Text(durationString + (perpetual ? "" : "min")) }
if smbString != "" { Text(smbString).foregroundColor(.secondary).font(.caption) }
Text(scheduledSMBstring)
.foregroundColor(.secondary)
.font(.caption)
if scheduledSMBstring != "" { Text(scheduledSMBstring) }
if preset.advancedSettings {
Text(maxMinutesSMB == 0 ? "" : maxMinutesSMB.formatted() + " SMB")
Text(maxMinutesUAM == 0 ? "" : maxMinutesUAM.formatted() + " UAM")
Text(isfAndCRstring)
}
Spacer()
}.padding(.top, 2)
}
.padding(.top, 2)
.foregroundColor(.secondary)
.font(.caption)
}
.contentShape(Rectangle())
.onTapGesture {
Expand Down

0 comments on commit 4d22482

Please sign in to comment.