1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-12 21:30:32 +05:30
yattee/Model/Player/ControlsOverlayModel.swift
2022-12-05 10:13:19 +01:00

33 lines
903 B
Swift

import Defaults
import Foundation
import SwiftUI
final class ControlOverlaysModel: ObservableObject {
static let animation = Animation.easeInOut(duration: 0.1)
static let shared = ControlOverlaysModel()
@Published private(set) var presenting = false { didSet { handlePresentationChange() } }
private lazy var controls = PlayerControlsModel.shared
private lazy var player: PlayerModel! = PlayerModel.shared
func toggle() {
presenting.toggle()
controls.objectWillChange.send()
}
func hide() {
presenting = false
controls.objectWillChange.send()
}
func show() {
presenting = true
controls.objectWillChange.send()
}
private func handlePresentationChange() {
guard let player else { return }
player.backend.setNeedsNetworkStateUpdates(presenting && Defaults[.showMPVPlaybackStats])
}
}