mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 04:04:07 +00:00
Initial functionality of player items queue
Fix environment objects Hide video player placeholder on tvOS Queue improvements
This commit is contained in:
81
tvOS/NowPlayingView.swift
Normal file
81
tvOS/NowPlayingView.swift
Normal file
@@ -0,0 +1,81 @@
|
||||
import SwiftUI
|
||||
|
||||
struct NowPlayingView: View {
|
||||
var infoViewController = false
|
||||
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
|
||||
var body: some View {
|
||||
if infoViewController {
|
||||
content
|
||||
.background(.thinMaterial)
|
||||
.mask(RoundedRectangle(cornerRadius: 24))
|
||||
} else {
|
||||
content
|
||||
}
|
||||
}
|
||||
|
||||
var content: some View {
|
||||
ScrollView(.vertical) {
|
||||
VStack(alignment: .leading) {
|
||||
if !infoViewController, let item = player.currentItem {
|
||||
Group {
|
||||
header("Now Playing")
|
||||
|
||||
Button {
|
||||
player.presentPlayer()
|
||||
} label: {
|
||||
VideoBanner(video: item.video)
|
||||
}
|
||||
}
|
||||
.onPlayPauseCommand(perform: player.togglePlay)
|
||||
|
||||
.padding(.bottom, 20)
|
||||
}
|
||||
|
||||
if !infoViewController {
|
||||
header("Playing Next")
|
||||
}
|
||||
|
||||
if player.queue.isEmpty {
|
||||
Spacer()
|
||||
|
||||
Text("Playback queue is empty")
|
||||
.padding(.leading, 40)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
ForEach(player.queue) { item in
|
||||
Button {
|
||||
player.advanceToItem(item)
|
||||
player.presentPlayer()
|
||||
} label: {
|
||||
VideoBanner(video: item.video)
|
||||
}
|
||||
.contextMenu {
|
||||
Button("Delete", role: .destructive) {
|
||||
player.remove(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.vertical)
|
||||
.padding(.horizontal, 40)
|
||||
}
|
||||
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 260, maxHeight: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
func header(_ text: String) -> some View {
|
||||
Text(text)
|
||||
.font(.title3.bold())
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.leading, 40)
|
||||
}
|
||||
}
|
||||
|
||||
struct NowPlayingView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NowPlayingView()
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
}
|
@@ -2,8 +2,8 @@ import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct TVNavigationView: View {
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
@EnvironmentObject<NavigationModel> private var navigation
|
||||
@EnvironmentObject<PlaybackModel> private var playback
|
||||
@EnvironmentObject<RecentsModel> private var recents
|
||||
@EnvironmentObject<SearchModel> private var search
|
||||
|
||||
@@ -29,6 +29,10 @@ struct TVNavigationView: View {
|
||||
.tabItem { Text("Playlists") }
|
||||
.tag(TabSelection.playlists)
|
||||
|
||||
NowPlayingView()
|
||||
.tabItem { Text("Now Playing") }
|
||||
.tag(TabSelection.nowPlaying)
|
||||
|
||||
SearchView()
|
||||
.tabItem { Image(systemName: "magnifyingglass") }
|
||||
.tag(TabSelection.search)
|
||||
@@ -39,11 +43,8 @@ struct TVNavigationView: View {
|
||||
AddToPlaylistView(video: video)
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $navigation.showingVideo) {
|
||||
if let video = navigation.video {
|
||||
VideoPlayerView(video)
|
||||
.environmentObject(playback)
|
||||
}
|
||||
.fullScreenCover(isPresented: $player.presentingPlayer) {
|
||||
VideoPlayerView()
|
||||
}
|
||||
.fullScreenCover(isPresented: $navigation.isChannelOpen) {
|
||||
if let channel = recents.presentedChannel {
|
||||
|
Reference in New Issue
Block a user