2021-07-12 02:22:49 +05:30
|
|
|
import Defaults
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct TVNavigationView: View {
|
2021-10-21 03:51:50 +05:30
|
|
|
@EnvironmentObject<AccountsModel> private var accounts
|
2021-09-25 13:48:22 +05:30
|
|
|
@EnvironmentObject<NavigationModel> private var navigation
|
2021-12-03 01:49:10 +05:30
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
2021-09-26 23:10:25 +05:30
|
|
|
@EnvironmentObject<RecentsModel> private var recents
|
2022-07-02 02:58:32 +05:30
|
|
|
@EnvironmentObject<SettingsModel> private var settings
|
2021-07-12 02:22:49 +05:30
|
|
|
|
2021-12-01 16:52:19 +05:30
|
|
|
@Default(.visibleSections) private var visibleSections
|
2022-01-06 21:36:03 +05:30
|
|
|
|
2022-08-14 22:29:04 +05:30
|
|
|
@State private var playerInitialized = false
|
|
|
|
|
2021-07-12 02:22:49 +05:30
|
|
|
var body: some View {
|
2022-06-26 18:47:18 +05:30
|
|
|
NavigationView {
|
|
|
|
TabView(selection: navigation.tabSelectionBinding) {
|
|
|
|
if visibleSections.contains(.favorites) {
|
|
|
|
FavoritesView()
|
|
|
|
.tabItem { Text("Favorites") }
|
|
|
|
.tag(TabSelection.favorites)
|
|
|
|
}
|
2021-09-19 02:06:42 +05:30
|
|
|
|
2022-06-26 18:47:18 +05:30
|
|
|
if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions, accounts.api.signedIn {
|
|
|
|
SubscriptionsView()
|
|
|
|
.tabItem { Text("Subscriptions") }
|
|
|
|
.tag(TabSelection.subscriptions)
|
|
|
|
}
|
2021-08-03 04:43:42 +05:30
|
|
|
|
2022-06-26 18:47:18 +05:30
|
|
|
if visibleSections.contains(.popular), accounts.app.supportsPopular {
|
|
|
|
PopularView()
|
|
|
|
.tabItem { Text("Popular") }
|
|
|
|
.tag(TabSelection.popular)
|
|
|
|
}
|
2021-08-03 04:43:42 +05:30
|
|
|
|
2022-06-26 18:47:18 +05:30
|
|
|
if visibleSections.contains(.trending) {
|
|
|
|
TrendingView()
|
|
|
|
.tabItem { Text("Trending") }
|
|
|
|
.tag(TabSelection.trending)
|
|
|
|
}
|
2021-08-03 04:43:42 +05:30
|
|
|
|
2022-07-02 02:58:32 +05:30
|
|
|
if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists, accounts.signedIn {
|
2022-06-26 18:47:18 +05:30
|
|
|
PlaylistsView()
|
|
|
|
.tabItem { Text("Playlists") }
|
|
|
|
.tag(TabSelection.playlists)
|
|
|
|
}
|
|
|
|
|
|
|
|
NowPlayingView()
|
|
|
|
.tabItem { Text("Now Playing") }
|
|
|
|
.tag(TabSelection.nowPlaying)
|
2021-08-03 04:43:42 +05:30
|
|
|
|
2022-06-26 18:47:18 +05:30
|
|
|
SearchView()
|
|
|
|
.tabItem { Image(systemName: "magnifyingglass") }
|
|
|
|
.tag(TabSelection.search)
|
2021-10-06 01:50:09 +05:30
|
|
|
|
2022-06-26 18:47:18 +05:30
|
|
|
SettingsView()
|
|
|
|
.tabItem { Image(systemName: "gear") }
|
|
|
|
.tag(TabSelection.settings)
|
|
|
|
}
|
2021-08-03 04:43:42 +05:30
|
|
|
}
|
2022-08-14 22:29:04 +05:30
|
|
|
.background(videoPlayerInitialize)
|
2021-09-28 23:36:05 +05:30
|
|
|
.fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) {
|
|
|
|
if let video = navigation.videoToAddToPlaylist {
|
|
|
|
AddToPlaylistView(video: video)
|
|
|
|
}
|
|
|
|
}
|
2021-10-06 01:50:09 +05:30
|
|
|
.fullScreenCover(isPresented: $player.presentingPlayer) {
|
|
|
|
VideoPlayerView()
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
2021-10-23 04:34:03 +05:30
|
|
|
.fullScreenCover(isPresented: $navigation.presentingChannel) {
|
2021-09-19 16:36:54 +05:30
|
|
|
if let channel = recents.presentedChannel {
|
2021-09-25 13:48:22 +05:30
|
|
|
ChannelVideosView(channel: channel)
|
2021-09-01 02:47:50 +05:30
|
|
|
}
|
|
|
|
}
|
2021-10-23 04:34:03 +05:30
|
|
|
.fullScreenCover(isPresented: $navigation.presentingPlaylist) {
|
|
|
|
if let playlist = recents.presentedPlaylist {
|
|
|
|
ChannelPlaylistView(playlist: playlist)
|
|
|
|
}
|
|
|
|
}
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
2022-08-14 22:29:04 +05:30
|
|
|
|
|
|
|
@ViewBuilder var videoPlayerInitialize: some View {
|
|
|
|
if !playerInitialized {
|
|
|
|
VideoPlayerView()
|
|
|
|
.scaleEffect(0.00001)
|
|
|
|
.onAppear {
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
|
|
playerInitialized = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
struct TVNavigationView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
TVNavigationView()
|
2021-09-29 17:15:00 +05:30
|
|
|
.injectFixtureEnvironmentObjects()
|
2021-07-12 02:22:49 +05:30
|
|
|
}
|
|
|
|
}
|