mirror of
https://github.com/yattee/yattee.git
synced 2026-04-10 09:36:58 +00:00
Deduplicate time formatting and clean up unused code
Extract shared TimeInterval.formattedAsTimestamp replacing 8 identical formatTime/formattedTime implementations across player views. Remove unused currentTime parameter from GestureSeekPreviewView. Consolidate duplicated geometry math in MacOSControlBar into seekPreviewPosition().
This commit is contained in:
@@ -427,9 +427,9 @@ struct RemoteControlView: View {
|
||||
#endif
|
||||
|
||||
HStack {
|
||||
Text(formatTime(displayCurrentTime))
|
||||
Text(displayCurrentTime.formattedAsTimestamp)
|
||||
Spacer()
|
||||
Text("-" + formatTime(remoteState.duration - displayCurrentTime))
|
||||
Text("-" + (remoteState.duration - displayCurrentTime).formattedAsTimestamp)
|
||||
}
|
||||
.font(.caption.monospacedDigit())
|
||||
.foregroundStyle(.secondary)
|
||||
@@ -683,19 +683,6 @@ struct RemoteControlView: View {
|
||||
isConnected = false
|
||||
}
|
||||
|
||||
private func formatTime(_ time: TimeInterval) -> String {
|
||||
let totalSeconds = Int(time)
|
||||
let hours = totalSeconds / 3600
|
||||
let minutes = (totalSeconds % 3600) / 60
|
||||
let seconds = totalSeconds % 60
|
||||
|
||||
if hours > 0 {
|
||||
return String(format: "%d:%02d:%02d", hours, minutes, seconds)
|
||||
} else {
|
||||
return String(format: "%d:%02d", minutes, seconds)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the previous playback rate, or nil if at minimum.
|
||||
private func previousRate() -> PlaybackRate? {
|
||||
let allRates = PlaybackRate.allCases
|
||||
|
||||
Reference in New Issue
Block a user