feat: add compact progress decimal

This commit is contained in:
2026-10-17 18:26:39 +02:00
parent 117bf77902
commit 3368228537
4 changed files with 20 additions and 5 deletions
+14 -2
View File
@@ -5,7 +5,10 @@ import TerebiConfiguration
func compactProgressText(position: Double, duration: Double, format: CompactTitleProgress) -> String? {
guard format != .none, duration.isFinite, duration > 0, position.isFinite else { return nil }
let position = min(max(0, position), duration)
if format == .percentage { return String(Int((position / duration * 100).rounded(.down))) }
if format == .percentage {
let tenths = Int((position / duration * 1000).rounded(.down))
return "\(tenths / 10).\(tenths % 10)"
}
let total = Int(min(duration, Double(Int.max / 2)))
let current = Int(min(position, Double(Int.max / 2)))
if duration < 60 { return "\(current) / \(total) s" }
@@ -1830,8 +1833,17 @@ private struct PlayerContent: View {
.frame(minWidth: 0, maxWidth: constrained ? .infinity : nil, alignment: .leading)
.clipped()
if let progress {
Text(" · \(progress)")
HStack(alignment: .center, spacing: 0) {
if model.compactTitleProgress == .percentage, let decimal = progress.firstIndex(of: ".") {
Text(" · \(progress[..<decimal])")
Text(String(progress[decimal...]))
.font(.system(size: 11 * 2 / 3, weight: .medium))
} else {
Text(" · \(progress)")
}
}
.monospacedDigit()
.accessibilityElement(children: .ignore)
.accessibilityLabel(model.compactTitleProgress == .percentage ? "\(progress) percent" : progress)
.fixedSize(horizontal: true, vertical: false)
}