mirror of
https://github.com/yattee/yattee.git
synced 2025-01-08 22:07:10 +00:00
Fix toggling full screen details
This commit is contained in:
parent
17787fa69c
commit
69209ff771
@ -6,7 +6,7 @@ import SwiftUI
|
||||
struct PlayerQueueRow: View {
|
||||
let item: PlayerQueueItem
|
||||
var history = false
|
||||
var fullScreen: Bool
|
||||
@Binding var fullScreen: Bool
|
||||
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
|
||||
@ -14,10 +14,10 @@ struct PlayerQueueRow: View {
|
||||
|
||||
@FetchRequest private var watchRequest: FetchedResults<Watch>
|
||||
|
||||
init(item: PlayerQueueItem, history: Bool = false, fullScreen: Bool = false) {
|
||||
init(item: PlayerQueueItem, history: Bool = false, fullScreen: Binding<Bool> = .constant(false)) {
|
||||
self.item = item
|
||||
self.history = history
|
||||
self.fullScreen = fullScreen
|
||||
_fullScreen = fullScreen
|
||||
_watchRequest = FetchRequest<Watch>(
|
||||
entity: Watch.entity(),
|
||||
sortDescriptors: [],
|
||||
@ -41,9 +41,9 @@ struct PlayerQueueRow: View {
|
||||
}
|
||||
|
||||
if fullScreen {
|
||||
// withAnimation {
|
||||
// fullScreen = false
|
||||
// }
|
||||
withAnimation {
|
||||
fullScreen = false
|
||||
}
|
||||
}
|
||||
|
||||
if closePiPOnNavigation, player.playingInPictureInPicture {
|
||||
|
@ -4,7 +4,7 @@ import SwiftUI
|
||||
|
||||
struct PlayerQueueView: View {
|
||||
var sidebarQueue: Bool
|
||||
var fullScreen: Bool
|
||||
@Binding var fullScreen: Bool
|
||||
|
||||
@FetchRequest(sortDescriptors: [.init(key: "watchedAt", ascending: false)])
|
||||
var watches: FetchedResults<Watch>
|
||||
@ -49,7 +49,10 @@ struct PlayerQueueView: View {
|
||||
}
|
||||
|
||||
ForEach(player.queue) { item in
|
||||
PlayerQueueRow(item: item, fullScreen: fullScreen)
|
||||
PlayerQueueRow(item: item, fullScreen: $fullScreen)
|
||||
.onAppear {
|
||||
player.loadQueueVideoDetails(item)
|
||||
}
|
||||
.contextMenu {
|
||||
removeButton(item)
|
||||
removeAllButton()
|
||||
@ -70,7 +73,7 @@ struct PlayerQueueView: View {
|
||||
PlayerQueueRow(
|
||||
item: PlayerQueueItem.from(watch, video: player.historyVideo(watch.videoID)),
|
||||
history: true,
|
||||
fullScreen: fullScreen
|
||||
fullScreen: $fullScreen
|
||||
)
|
||||
.onAppear {
|
||||
player.loadHistoryVideoDetails(watch.videoID)
|
||||
@ -89,7 +92,7 @@ struct PlayerQueueView: View {
|
||||
if !player.currentVideo.isNil, !player.currentVideo!.related.isEmpty {
|
||||
Section(header: Text("Related")) {
|
||||
ForEach(player.currentVideo!.related) { video in
|
||||
PlayerQueueRow(item: PlayerQueueItem(video), fullScreen: fullScreen)
|
||||
PlayerQueueRow(item: PlayerQueueItem(video), fullScreen: $fullScreen)
|
||||
.contextMenu {
|
||||
Button {
|
||||
player.playNext(video)
|
||||
@ -137,7 +140,7 @@ struct PlayerQueueView: View {
|
||||
struct PlayerQueueView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack {
|
||||
PlayerQueueView(sidebarQueue: true, fullScreen: true)
|
||||
PlayerQueueView(sidebarQueue: true, fullScreen: .constant(true))
|
||||
}
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ struct VideoDetails: View {
|
||||
}
|
||||
|
||||
var sidebarQueue: Bool
|
||||
var fullScreen: Bool
|
||||
@Binding var fullScreen: Bool
|
||||
|
||||
@State private var subscribed = false
|
||||
@State private var subscriptionToggleButtonDisabled = false
|
||||
@ -58,7 +58,9 @@ struct VideoDetails: View {
|
||||
presentingControls: false,
|
||||
backgroundEnabled: false,
|
||||
borderTop: false,
|
||||
detailsTogglePlayer: false
|
||||
detailsTogglePlayer: false,
|
||||
detailsToggleFullScreen: true,
|
||||
fullScreen: $fullScreen
|
||||
)
|
||||
|
||||
HStack(spacing: 4) {
|
||||
@ -175,7 +177,7 @@ struct VideoDetails: View {
|
||||
.edgesIgnoringSafeArea(.horizontal)
|
||||
|
||||
case .queue:
|
||||
PlayerQueueView(sidebarQueue: sidebarQueue, fullScreen: fullScreen)
|
||||
PlayerQueueView(sidebarQueue: sidebarQueue, fullScreen: $fullScreen)
|
||||
.edgesIgnoringSafeArea(.horizontal)
|
||||
|
||||
case .related:
|
||||
@ -325,7 +327,7 @@ struct VideoDetails: View {
|
||||
|
||||
struct VideoDetails_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VideoDetails(sidebarQueue: true, fullScreen: false)
|
||||
VideoDetails(sidebarQueue: true, fullScreen: .constant(false))
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ struct VideoPlayerView: View {
|
||||
@EnvironmentObject<AccountsModel> private var accounts
|
||||
@EnvironmentObject<NavigationModel> private var navigation
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
@EnvironmentObject<PlayerControlsModel> private var playerControls
|
||||
@EnvironmentObject<RecentsModel> private var recents
|
||||
@EnvironmentObject<SearchModel> private var search
|
||||
@EnvironmentObject<ThumbnailsModel> private var thumbnails
|
||||
@ -179,7 +180,7 @@ struct VideoPlayerView: View {
|
||||
.frame(maxWidth: fullScreenLayout ? .infinity : nil, maxHeight: fullScreenLayout ? .infinity : nil)
|
||||
.onHover { hovering in
|
||||
hoveringPlayer = hovering
|
||||
// hovering ? playerControls.show() : playerControls.hide()
|
||||
hovering ? playerControls.show() : playerControls.hide()
|
||||
}
|
||||
#if !os(macOS)
|
||||
.gesture(
|
||||
@ -210,30 +211,30 @@ struct VideoPlayerView: View {
|
||||
}
|
||||
)
|
||||
#else
|
||||
// .onAppear(perform: {
|
||||
// NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
|
||||
// if hoveringPlayer {
|
||||
// playerControls.resetTimer()
|
||||
// }
|
||||
//
|
||||
// return $0
|
||||
// }
|
||||
// })
|
||||
.onAppear(perform: {
|
||||
NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved]) {
|
||||
if hoveringPlayer {
|
||||
playerControls.resetTimer()
|
||||
}
|
||||
|
||||
return $0
|
||||
}
|
||||
})
|
||||
#endif
|
||||
|
||||
.background(Color.black)
|
||||
.background(Color.black)
|
||||
|
||||
#if !os(tvOS)
|
||||
if !player.playingFullScreen {
|
||||
VStack(spacing: 0) {
|
||||
#if os(iOS)
|
||||
if verticalSizeClass == .regular {
|
||||
VideoDetails(sidebarQueue: sidebarQueue, fullScreen: fullScreenDetails)
|
||||
VideoDetails(sidebarQueue: sidebarQueue, fullScreen: $fullScreenDetails)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
}
|
||||
|
||||
#else
|
||||
VideoDetails(sidebarQueue: sidebarQueue, fullScreen: fullScreenDetails)
|
||||
VideoDetails(sidebarQueue: sidebarQueue, fullScreen: $fullScreenDetails)
|
||||
|
||||
#endif
|
||||
}
|
||||
@ -255,12 +256,12 @@ struct VideoPlayerView: View {
|
||||
if !player.playingFullScreen {
|
||||
#if os(iOS)
|
||||
if sidebarQueue {
|
||||
PlayerQueueView(sidebarQueue: true, fullScreen: fullScreenDetails)
|
||||
PlayerQueueView(sidebarQueue: true, fullScreen: $fullScreenDetails)
|
||||
.frame(maxWidth: 350)
|
||||
}
|
||||
#elseif os(macOS)
|
||||
if Defaults[.playerSidebar] != .never {
|
||||
PlayerQueueView(sidebarQueue: true, fullScreen: fullScreenDetails)
|
||||
PlayerQueueView(sidebarQueue: true, fullScreen: $fullScreenDetails)
|
||||
.frame(minWidth: 300)
|
||||
}
|
||||
#endif
|
||||
|
@ -42,7 +42,7 @@ struct BrowserPlayerControls<Content: View, Toolbar: View>: View {
|
||||
toolbar
|
||||
.borderTop(height: 0.4, color: Color("ControlsBorderColor"))
|
||||
.modifier(ControlBackgroundModifier())
|
||||
ControlsBar()
|
||||
ControlsBar(fullScreen: .constant(false))
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
}
|
||||
#endif
|
||||
|
@ -19,6 +19,9 @@ struct ControlsBar: View {
|
||||
var borderTop = true
|
||||
var borderBottom = true
|
||||
var detailsTogglePlayer = true
|
||||
var detailsToggleFullScreen = false
|
||||
|
||||
@Binding var fullScreen: Bool
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
@ -55,6 +58,16 @@ struct ControlsBar: View {
|
||||
details
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
} else if detailsToggleFullScreen {
|
||||
Button {
|
||||
withAnimation {
|
||||
fullScreen.toggle()
|
||||
}
|
||||
} label: {
|
||||
details
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.keyboardShortcut("t")
|
||||
} else {
|
||||
details
|
||||
}
|
||||
@ -250,7 +263,7 @@ struct ControlsBar: View {
|
||||
|
||||
struct ControlsBar_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ControlsBar()
|
||||
ControlsBar(fullScreen: .constant(false))
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user