Animations improvements

This commit is contained in:
Arkadiusz Fal
2022-08-25 19:09:55 +02:00
parent 5f50797b54
commit 08ed810b9e
17 changed files with 205 additions and 103 deletions

View File

@@ -9,7 +9,7 @@ import SwiftUI
final class MPVBackend: PlayerBackend {
static var controlsUpdateInterval = 0.5
static var networkStateUpdateInterval = 0.3
static var networkStateUpdateInterval = 1.0
private var logger = Logger(label: "mpv-backend")

View File

@@ -225,15 +225,13 @@ final class PlayerModel: ObservableObject {
}
#endif
navigation.hideKeyboard()
if !presentingPlayer {
DispatchQueue.main.async { [weak self] in
withAnimation(.linear(duration: 0.25)) {
self?.presentingPlayer = true
}
#if os(iOS)
Delay.by(0.5) {
self.navigation.hideKeyboard()
}
}
#endif
if !presentingPlayer { presentingPlayer = true }
#if os(macOS)
Windows.player.open()
@@ -241,13 +239,17 @@ final class PlayerModel: ObservableObject {
#endif
}
func hide() {
withAnimation(.linear(duration: 0.25)) {
func hide(animate: Bool = true) {
if animate {
withAnimation(.easeOut(duration: 0.2)) {
presentingPlayer = false
}
} else {
presentingPlayer = false
}
DispatchQueue.main.async { [weak self] in
self?.playingFullScreen = false
self?.exitFullScreen(showControls: false)
}
#if os(iOS)
@@ -591,9 +593,7 @@ final class PlayerModel: ObservableObject {
exitFullScreen()
#if !os(macOS)
if closePlayerOnItemClose {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in self?.hide() }
}
if closePlayerOnItemClose { Delay.by(0.2) { self.hide() } }
#endif
}