mirror of
https://github.com/yattee/yattee.git
synced 2025-08-08 19:54:07 +00:00
Recently opened for sidebar navigation
This commit is contained in:
@@ -4,6 +4,7 @@ import SwiftUI
|
||||
struct TVNavigationView: View {
|
||||
@EnvironmentObject<NavigationState> private var navigationState
|
||||
@EnvironmentObject<PlaybackState> private var playbackState
|
||||
@EnvironmentObject<Recents> private var recents
|
||||
@EnvironmentObject<SearchState> private var searchState
|
||||
|
||||
@State private var showingOptions = false
|
||||
@@ -47,31 +48,20 @@ struct TVNavigationView: View {
|
||||
}
|
||||
.fullScreenCover(isPresented: $showingOptions) { OptionsView() }
|
||||
.fullScreenCover(isPresented: $showingAddToPlaylist) { AddToPlaylistView() }
|
||||
.fullScreenCover(isPresented: $navigationState.showingVideoDetails) {
|
||||
if let video = navigationState.video {
|
||||
VideoDetailsView(video)
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $navigationState.showingVideo) {
|
||||
if let video = navigationState.video {
|
||||
VideoPlayerView(video)
|
||||
.environmentObject(playbackState)
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $navigationState.isChannelOpen, onDismiss: {
|
||||
navigationState.closeChannel(presentedChannel)
|
||||
}) {
|
||||
if presentedChannel != nil {
|
||||
ChannelVideosView(presentedChannel)
|
||||
.fullScreenCover(isPresented: $navigationState.isChannelOpen) {
|
||||
if let channel = recents.presentedChannel {
|
||||
ChannelVideosView(channel)
|
||||
.background(.thickMaterial)
|
||||
}
|
||||
}
|
||||
.onPlayPauseCommand { showingOptions.toggle() }
|
||||
}
|
||||
|
||||
fileprivate var presentedChannel: Channel! {
|
||||
navigationState.openChannels.first
|
||||
}
|
||||
}
|
||||
|
||||
struct TVNavigationView_Previews: PreviewProvider {
|
||||
|
@@ -1,113 +0,0 @@
|
||||
import Defaults
|
||||
import Siesta
|
||||
import SwiftUI
|
||||
|
||||
struct VideoDetailsView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
@EnvironmentObject<NavigationState> private var navigationState
|
||||
|
||||
@ObservedObject private var store = Store<Video>()
|
||||
|
||||
@State private var playVideoLinkActive = false
|
||||
|
||||
var resource: Resource {
|
||||
InvidiousAPI.shared.video(video.id)
|
||||
}
|
||||
|
||||
var video: Video
|
||||
|
||||
init(_ video: Video) {
|
||||
self.video = video
|
||||
resource.addObserver(store)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
HStack {
|
||||
Spacer()
|
||||
|
||||
VStack {
|
||||
Spacer()
|
||||
|
||||
ScrollView(.vertical, showsIndicators: false) {
|
||||
if let video = store.item {
|
||||
VStack(alignment: .center) {
|
||||
ZStack(alignment: .bottom) {
|
||||
Group {
|
||||
if let url = video.thumbnailURL(quality: .maxres) {
|
||||
AsyncImage(url: url) { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: 1600, height: 800)
|
||||
} placeholder: {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(width: 1600, height: 800)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text(video.title)
|
||||
.font(.system(size: 40))
|
||||
|
||||
HStack {
|
||||
playVideoButton
|
||||
|
||||
openChannelButton
|
||||
}
|
||||
}
|
||||
.padding(40)
|
||||
.frame(width: 1600, alignment: .leading)
|
||||
.background(.thinMaterial)
|
||||
}
|
||||
.mask(RoundedRectangle(cornerRadius: 20))
|
||||
VStack {
|
||||
Text(video.description)
|
||||
.lineLimit(nil)
|
||||
.focusable()
|
||||
}.frame(width: 1600, alignment: .leading)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.background(.thinMaterial)
|
||||
|
||||
.onAppear {
|
||||
resource.loadIfNeeded()
|
||||
}
|
||||
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
|
||||
var playVideoButton: some View {
|
||||
Button(action: {
|
||||
navigationState.returnToDetails = true
|
||||
playVideoLinkActive = true
|
||||
}) {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "play.rectangle.fill")
|
||||
Text("Play")
|
||||
}
|
||||
}
|
||||
.background(NavigationLink(destination: VideoPlayerView(video), isActive: $playVideoLinkActive) { EmptyView() }.hidden())
|
||||
}
|
||||
|
||||
var openChannelButton: some View {
|
||||
let channel = video.channel
|
||||
|
||||
return Button("Open \(channel.name) channel") {
|
||||
navigationState.openChannel(channel)
|
||||
navigationState.tabSelection = .channel(channel.id)
|
||||
navigationState.returnToDetails = true
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user