Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display pod days and hours #914

Merged
merged 1 commit into from
Oct 23, 2024
Merged
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
34 changes: 29 additions & 5 deletions FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift
Original file line number Diff line number Diff line change
@@ -109,14 +109,34 @@ struct PumpView: View {
let days = Int(time / 1.days.timeInterval)
let hours = Int(time / 1.hours.timeInterval)
let minutes = Int(time / 1.minutes.timeInterval)
let adjustedHours = Int(hours - days * 24)

if days >= 1 {
Text(" \(days)" + NSLocalizedString("d", comment: "abbreviation for days" + "+"))
HStack(spacing: 0) {
Text(" \(days)")
spacer
Text(NSLocalizedString("d", comment: "abbreviation for days")).foregroundStyle(.secondary)
if adjustedHours >= 0 {
Text(" ")
Text("\(adjustedHours)")
spacer
Text(NSLocalizedString("h", comment: "abbreviation for days")).foregroundStyle(.secondary)
}
}
} else if hours >= 1 {
Text(" \(hours)" + NSLocalizedString("h", comment: "abbreviation for hours"))
.foregroundStyle(time < 4 * 60 * 60 ? .red : .primary)
HStack(spacing: 0) {
Text(" \(hours)")
spacer
Text(NSLocalizedString("h", comment: "abbreviation for hours"))
.foregroundStyle(time < 4 * 60 * 60 ? .red : .secondary)
}
} else {
Text(" \(minutes)" + NSLocalizedString("m", comment: "abbreviation for minutes"))
.foregroundStyle(time < 4 * 60 * 60 ? .red : .primary)
HStack(spacing: 0) {
Text(" \(minutes)")
spacer
Text(NSLocalizedString("m", comment: "abbreviation for minutes"))
.foregroundStyle(time < 4 * 60 * 60 ? .red : .secondary)
}
}
} else {
Text(NSLocalizedString("Replace", comment: "View/Header when pod expired")).foregroundStyle(.red)
@@ -169,4 +189,8 @@ struct PumpView: View {
return .green
}
}

private var spacer: Text {
Text(" ").tracking(-3)
}
}