2022-09-01 23:05:31 +00:00
|
|
|
import Defaults
|
|
|
|
import Foundation
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
final class ControlOverlaysModel: ObservableObject {
|
2022-12-03 14:33:32 +00:00
|
|
|
static let animation = Animation.easeInOut(duration: 0.1)
|
2022-09-01 23:05:31 +00:00
|
|
|
static let shared = ControlOverlaysModel()
|
2022-11-17 21:47:45 +00:00
|
|
|
@Published private(set) var presenting = false { didSet { handlePresentationChange() } }
|
2022-09-01 23:05:31 +00:00
|
|
|
|
|
|
|
private lazy var controls = PlayerControlsModel.shared
|
|
|
|
private lazy var player: PlayerModel! = PlayerModel.shared
|
|
|
|
|
|
|
|
func toggle() {
|
|
|
|
presenting.toggle()
|
|
|
|
controls.objectWillChange.send()
|
|
|
|
}
|
|
|
|
|
2022-11-17 21:47:45 +00:00
|
|
|
func hide() {
|
|
|
|
presenting = false
|
|
|
|
controls.objectWillChange.send()
|
|
|
|
}
|
|
|
|
|
|
|
|
func show() {
|
|
|
|
presenting = true
|
|
|
|
controls.objectWillChange.send()
|
|
|
|
}
|
|
|
|
|
2022-09-01 23:05:31 +00:00
|
|
|
private func handlePresentationChange() {
|
2022-09-28 14:27:01 +00:00
|
|
|
guard let player else { return }
|
2022-09-01 23:05:31 +00:00
|
|
|
player.backend.setNeedsNetworkStateUpdates(presenting && Defaults[.showMPVPlaybackStats])
|
|
|
|
}
|
|
|
|
}
|