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