mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Player bar visibility modes and settings
This commit is contained in:
@@ -1,11 +1,38 @@
|
||||
import Defaults
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct PlayerOverlayModifier: ViewModifier {
|
||||
@ObservedObject private var player = PlayerModel.shared
|
||||
@State private var expansionState = ControlsBar.ExpansionState.mini
|
||||
|
||||
@Environment(\.navigationStyle) private var navigationStyle
|
||||
|
||||
@Default(.playerButtonShowsControlButtonsWhenMinimized) private var controlsWhenMinimized
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
#if !os(tvOS)
|
||||
.overlay(ControlsBar(fullScreen: .constant(false)), alignment: .bottom)
|
||||
.overlay(overlay, alignment: .bottomTrailing)
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder var overlay: some View {
|
||||
Group {
|
||||
if player.currentItem != nil {
|
||||
ControlsBar(fullScreen: .constant(false), expansionState: $expansionState, playerBar: true)
|
||||
.offset(x: expansionState == .mini && !controlsWhenMinimized ? 10 : 0, y: 0)
|
||||
.transition(.opacity)
|
||||
}
|
||||
}
|
||||
.animation(.default, value: player.currentItem)
|
||||
}
|
||||
}
|
||||
|
||||
struct PlayerOverlayModifier_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
HStack {}
|
||||
.frame(maxWidth: .infinity, maxHeight: 100)
|
||||
.modifier(PlayerOverlayModifier())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user