Skip to content

Commit

Permalink
Display days and hours (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-b-m authored Oct 23, 2024
1 parent 608a38c commit 8e00f7d
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -169,4 +189,8 @@ struct PumpView: View {
return .green
}
}

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

0 comments on commit 8e00f7d

Please sign in to comment.