2021-07-11 20:52:49 +00:00
|
|
|
import Defaults
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct TVNavigationView: View {
|
|
|
|
@EnvironmentObject<NavigationState> private var navigationState
|
2021-08-23 21:31:51 +00:00
|
|
|
@EnvironmentObject<PlaybackState> private var playbackState
|
2021-07-11 20:52:49 +00:00
|
|
|
|
|
|
|
@State private var showingOptions = false
|
|
|
|
|
2021-08-01 21:25:50 +00:00
|
|
|
@Default(.showingAddToPlaylist) var showingAddToPlaylist
|
|
|
|
|
2021-07-11 20:52:49 +00:00
|
|
|
var body: some View {
|
2021-08-02 23:13:42 +00:00
|
|
|
TabView(selection: $navigationState.tabSelection) {
|
|
|
|
SubscriptionsView()
|
|
|
|
.tabItem { Text("Subscriptions") }
|
|
|
|
.tag(TabSelection.subscriptions)
|
|
|
|
|
|
|
|
PopularView()
|
|
|
|
.tabItem { Text("Popular") }
|
|
|
|
.tag(TabSelection.popular)
|
|
|
|
|
|
|
|
TrendingView()
|
|
|
|
.tabItem { Text("Trending") }
|
|
|
|
.tag(TabSelection.trending)
|
|
|
|
|
|
|
|
PlaylistsView()
|
|
|
|
.tabItem { Text("Playlists") }
|
|
|
|
.tag(TabSelection.playlists)
|
|
|
|
|
|
|
|
SearchView()
|
|
|
|
.tabItem { Image(systemName: "magnifyingglass") }
|
|
|
|
.tag(TabSelection.search)
|
|
|
|
}
|
|
|
|
.fullScreenCover(isPresented: $showingOptions) { OptionsView() }
|
|
|
|
.fullScreenCover(isPresented: $showingAddToPlaylist) { AddToPlaylistView() }
|
|
|
|
.fullScreenCover(isPresented: $navigationState.showingVideoDetails) {
|
|
|
|
if let video = navigationState.video {
|
|
|
|
VideoDetailsView(video)
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
2021-08-02 23:13:42 +00:00
|
|
|
}
|
|
|
|
.fullScreenCover(isPresented: $navigationState.showingChannel, onDismiss: {
|
|
|
|
navigationState.showVideoDetailsIfNeeded()
|
|
|
|
}) {
|
|
|
|
if let channel = navigationState.channel {
|
|
|
|
ChannelView(id: channel.id)
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
2021-08-02 23:13:42 +00:00
|
|
|
}
|
|
|
|
.fullScreenCover(isPresented: $navigationState.showingVideo) {
|
|
|
|
if let video = navigationState.video {
|
|
|
|
VideoPlayerView(video)
|
2021-08-23 21:31:51 +00:00
|
|
|
.environmentObject(playbackState)
|
2021-08-01 21:25:50 +00:00
|
|
|
}
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
2021-08-02 23:13:42 +00:00
|
|
|
.onPlayPauseCommand { showingOptions.toggle() }
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TVNavigationView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
TVNavigationView()
|
|
|
|
}
|
|
|
|
}
|