mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Add overlay model visibility methods
This commit is contained in:
parent
daaf2417b7
commit
09de2cbbab
@ -3,8 +3,9 @@ import Foundation
|
||||
import SwiftUI
|
||||
|
||||
final class ControlOverlaysModel: ObservableObject {
|
||||
static let animation = Animation.easeInOut(duration: 0.2)
|
||||
static let shared = ControlOverlaysModel()
|
||||
@Published var presenting = false { didSet { handlePresentationChange() } }
|
||||
@Published private(set) var presenting = false { didSet { handlePresentationChange() } }
|
||||
|
||||
private lazy var controls = PlayerControlsModel.shared
|
||||
private lazy var player: PlayerModel! = PlayerModel.shared
|
||||
@ -14,6 +15,16 @@ final class ControlOverlaysModel: ObservableObject {
|
||||
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])
|
||||
|
@ -70,7 +70,7 @@ final class PlayerControlsModel: ObservableObject {
|
||||
|
||||
func hideOverlays() {
|
||||
presentingDetailsOverlay = false
|
||||
controlsOverlayModel.presenting = false
|
||||
controlsOverlayModel.hide()
|
||||
}
|
||||
|
||||
func show() {
|
||||
|
@ -195,7 +195,7 @@ struct PlayerControls: View {
|
||||
guard player.presentingPlayer else { return }
|
||||
if value == "swipe down", !model.presentingControls, !model.presentingOverlays {
|
||||
withAnimation(Self.animation) {
|
||||
controlsOverlayModel.presenting = false
|
||||
controlsOverlayModel.hide()
|
||||
}
|
||||
} else {
|
||||
model.show()
|
||||
|
@ -367,7 +367,7 @@ struct VideoPlayerView: View {
|
||||
player.controls.show()
|
||||
} else if direction == .down, !controlsOverlayModel.presenting, !player.controls.presentingControls {
|
||||
withAnimation(PlayerControls.animation) {
|
||||
controlsOverlayModel.presenting = true
|
||||
controlsOverlayModel.hide()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ struct ControlsBar: View {
|
||||
}
|
||||
} else if detailsToggleFullScreen {
|
||||
Button {
|
||||
controlsOverlayModel.presenting = false
|
||||
controlsOverlayModel.hide()
|
||||
controls.presentingControls = false
|
||||
withAnimation {
|
||||
fullScreen.toggle()
|
||||
|
Loading…
Reference in New Issue
Block a user