fix: keep compact title progress adjacent and truncate the title tail

This commit is contained in:
2026-10-12 16:28:25 +02:00
parent 35fa89e492
commit daac27be8d
3 changed files with 27 additions and 19 deletions
+22 -14
View File
@@ -14,7 +14,7 @@ func compactProgressText(position: Double, duration: Double, format: CompactTitl
let totalUnits = total / divisor
let currentTime = String(format: "%02lld:%02lld", Int64(currentUnits / 60), Int64(currentUnits % 60))
let totalTime = String(format: "%02lld:%02lld", Int64(totalUnits / 60), Int64(totalUnits % 60))
return "\(currentTime) / \(totalTime) \(duration < 3600 ? "min" : "h")"
return "\(currentTime) / \(totalTime) \(duration < 3600 ? "m" : "h")"
}
@MainActor
@@ -1286,6 +1286,22 @@ private struct PlayerContent: View {
@State private var controlOffset = CGSize.zero
@State private var dragOrigin = CGSize.zero
private func compactTitleLabel(progress: String?, constrained: Bool) -> some View {
HStack(spacing: 0) {
Text(model.fileName ?? "terebi")
.lineLimit(1)
.truncationMode(.tail)
.frame(minWidth: 0, maxWidth: constrained ? .infinity : nil, alignment: .leading)
.clipped()
if let progress {
Text(" · \(progress)")
.monospacedDigit()
.accessibilityLabel(model.compactTitleProgress == .percentage ? "\(progress) percent" : progress)
.fixedSize(horizontal: true, vertical: false)
}
}
}
private func toggleYouTubeInput() {
if showsYouTubeInput { youTubeInputFocused = false }
withAnimation(reduceMotion ? nil : .easeInOut(duration: 0.22)) {
@@ -1659,20 +1675,12 @@ private struct PlayerContent: View {
.allowsHitTesting(false)
}
let progress = model.isCompact || model.compactWindow.isTransitioning ? model.compactProgress : nil
ZStack(alignment: .top) {
let progress = model.isCompact || model.compactWindow.isTransitioning ? model.compactProgress : nil
HStack(spacing: 0) {
Text(model.fileName ?? "terebi")
.lineLimit(1)
.truncationMode(.middle)
.frame(minWidth: 0, maxWidth: progress == nil ? nil : .infinity, alignment: .leading)
.clipped()
if let progress {
Text(" · \(progress)")
.monospacedDigit()
.accessibilityLabel(model.compactTitleProgress == .percentage ? "\(progress) percent" : progress)
.fixedSize(horizontal: true, vertical: false)
}
ViewThatFits(in: .horizontal) {
compactTitleLabel(progress: progress, constrained: false)
.fixedSize(horizontal: true, vertical: false)
compactTitleLabel(progress: progress, constrained: true)
}
.font(.system(size: 11, weight: .medium))
.accessibilityElement(children: .combine)