1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 13:50:32 +05:30
yattee/Model/Player/ControlsOverlayModel.swift

33 lines
903 B
Swift
Raw Normal View History

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