diff --git a/Checks/system-playback.swift b/Checks/system-playback.swift index 6252283..affa93c 100644 --- a/Checks/system-playback.swift +++ b/Checks/system-playback.swift @@ -33,9 +33,10 @@ struct SystemPlaybackChecks { require(compactProgressText(position: position, duration: duration, format: .time) == expected, "compact time uses total-duration units, truncation and bounded progress: \(expected)") } - for (position, expected) in [(59.9, "59"), (100.0, "100"), (105.0, "100"), (-1.0, "0")] { + for (position, expected) in [(59.9, "59.9"), (59.99, "59.9"), (0.0, "0.0"), + (100.0, "100.0"), (105.0, "100.0"), (-1.0, "0.0")] { require(compactProgressText(position: position, duration: 100, format: .percentage) == expected, - "compact percentage is a bounded integer: \(expected)") + "compact percentage has one decimal and stays bounded: \(expected)") } for duration in [0.0, -1.0, .nan, .infinity] { require(compactProgressText(position: 10, duration: duration, format: .time) == nil && diff --git a/README.md b/README.md index 870b585..c5d5da3 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ automatic_quality = true [ui] buffer_info = true compact_snap_to_edges = true -compact_title_progress = "percentage" # "time", "percentage", or "none" +compact_title_progress = "percentage" # "time", "percentage" (one decimal), or "none" [keys] play = "space" diff --git a/Sources/App/TerebiApp.swift b/Sources/App/TerebiApp.swift index 0d2040b..552fc3e 100644 --- a/Sources/App/TerebiApp.swift +++ b/Sources/App/TerebiApp.swift @@ -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[..