Files
yattee/Model/NetworkStateModel.swift
Arkadiusz Fal 5758417293 Fix SwiftLint and SwiftFormat violations
- Run SwiftFormat to fix indentation, spacing, and formatting issues
- Replace CGFloat with Double and NSRect with CGRect per style guide
- Remove redundant .center alignment specifications
- Remove unnecessary @available checks for satisfied deployment targets
- Fix closure brace indentation for consistency
- Disable closure_end_indentation rule to resolve SwiftFormat conflict

All linting checks now pass with zero errors and warnings.
2025-11-15 19:42:37 +01:00

51 lines
1.5 KiB
Swift

import Foundation
final class NetworkStateModel: ObservableObject {
static var shared = NetworkStateModel()
@Published var pausedForCache = false
@Published var cacheDuration = 0.0
@Published var bufferingState = 0.0
private var player: PlayerModel! { .shared }
private let controlsOverlayModel = ControlOverlaysModel.shared
var osdVisible: Bool {
guard let player else { return false }
return player.isPlaying && ((player.activeBackend == .mpv && pausedForCache) || player.isSeeking) && bufferingState < 100.0
}
var fullStateText: String? {
guard let bufferingStateText,
let cacheDurationText
else {
return nil
}
return "\(bufferingStateText) (\(cacheDurationText))"
}
var bufferingStateText: String? {
guard detailsAvailable, player.hasStarted else { return nil }
return String(format: "%.0f%%", bufferingState)
}
var cacheDurationText: String? {
guard detailsAvailable else { return nil }
return String(format: "%.2fs", cacheDuration)
}
var detailsAvailable: Bool {
guard let player else { return false }
return player.activeBackend.supportsNetworkStateBufferingDetails
}
var needsUpdates: Bool {
if let player {
return !player.currentItem.isNil && (pausedForCache || player.isSeeking || player.isLoadingVideo || controlsOverlayModel.presenting)
}
return false
}
}