2021-07-11 20:52:49 +00:00
|
|
|
import Defaults
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct TVNavigationView: View {
|
2021-10-20 22:21:50 +00:00
|
|
|
@EnvironmentObject<AccountsModel> private var accounts
|
2021-09-25 08:18:22 +00:00
|
|
|
@EnvironmentObject<NavigationModel> private var navigation
|
2021-12-02 20:19:10 +00:00
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
2021-09-26 17:40:25 +00:00
|
|
|
@EnvironmentObject<RecentsModel> private var recents
|
2022-07-01 21:28:32 +00:00
|
|
|
@EnvironmentObject<SettingsModel> private var settings
|
2021-07-11 20:52:49 +00:00
|
|
|
|
2021-12-01 11:22:19 +00:00
|
|
|
@Default(.visibleSections) private var visibleSections
|
2022-01-06 16:06:03 +00:00
|
|
|
|
2021-07-11 20:52:49 +00:00
|
|
|
var body: some View {
|
2022-06-26 13:17:18 +00:00
|
|
|
NavigationView {
|
|
|
|
TabView(selection: navigation.tabSelectionBinding) {
|
2022-11-11 20:28:40 +00:00
|
|
|
LazyView(HomeView())
|
|
|
|
.tabItem { Text("Home") }
|
|
|
|
.tag(TabSelection.home)
|
2021-09-18 20:36:42 +00:00
|
|
|
|
2022-11-15 14:27:23 +00:00
|
|
|
if !accounts.isEmpty {
|
|
|
|
if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions, accounts.api.signedIn {
|
|
|
|
LazyView(SubscriptionsView())
|
|
|
|
.tabItem { Text("Subscriptions") }
|
|
|
|
.tag(TabSelection.subscriptions)
|
|
|
|
}
|
2022-11-17 21:49:08 +00:00
|
|
|
|
2022-11-15 14:27:23 +00:00
|
|
|
if visibleSections.contains(.popular), accounts.app.supportsPopular {
|
|
|
|
LazyView(PopularView())
|
|
|
|
.tabItem { Text("Popular") }
|
|
|
|
.tag(TabSelection.popular)
|
|
|
|
}
|
2022-11-17 21:49:08 +00:00
|
|
|
|
2022-11-15 14:27:23 +00:00
|
|
|
if visibleSections.contains(.trending) {
|
|
|
|
LazyView(TrendingView())
|
|
|
|
.tabItem { Text("Trending") }
|
|
|
|
.tag(TabSelection.trending)
|
|
|
|
}
|
2022-11-17 21:49:08 +00:00
|
|
|
|
2022-11-15 14:27:23 +00:00
|
|
|
if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists, accounts.signedIn {
|
|
|
|
LazyView(PlaylistsView())
|
|
|
|
.tabItem { Text("Playlists") }
|
|
|
|
.tag(TabSelection.playlists)
|
|
|
|
}
|
2022-06-26 13:17:18 +00:00
|
|
|
}
|
|
|
|
|
2022-09-04 15:19:22 +00:00
|
|
|
LazyView(NowPlayingView())
|
2022-06-26 13:17:18 +00:00
|
|
|
.tabItem { Text("Now Playing") }
|
|
|
|
.tag(TabSelection.nowPlaying)
|
2021-08-02 23:13:42 +00:00
|
|
|
|
2022-11-11 19:34:20 +00:00
|
|
|
if !accounts.isEmpty {
|
|
|
|
LazyView(SearchView())
|
|
|
|
.tabItem { Image(systemName: "magnifyingglass") }
|
|
|
|
.tag(TabSelection.search)
|
|
|
|
}
|
2022-06-26 13:17:18 +00:00
|
|
|
}
|
2021-08-02 23:13:42 +00:00
|
|
|
}
|
2021-09-28 18:06:05 +00:00
|
|
|
.fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) {
|
|
|
|
if let video = navigation.videoToAddToPlaylist {
|
|
|
|
AddToPlaylistView(video: video)
|
|
|
|
}
|
|
|
|
}
|
2021-10-05 20:20:09 +00:00
|
|
|
.fullScreenCover(isPresented: $player.presentingPlayer) {
|
|
|
|
VideoPlayerView()
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
2021-10-22 23:04:03 +00:00
|
|
|
.fullScreenCover(isPresented: $navigation.presentingChannel) {
|
2021-09-19 11:06:54 +00:00
|
|
|
if let channel = recents.presentedChannel {
|
2021-09-25 08:18:22 +00:00
|
|
|
ChannelVideosView(channel: channel)
|
2021-08-31 21:17:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-10-22 23:04:03 +00:00
|
|
|
.fullScreenCover(isPresented: $navigation.presentingPlaylist) {
|
|
|
|
if let playlist = recents.presentedPlaylist {
|
|
|
|
ChannelPlaylistView(playlist: playlist)
|
|
|
|
}
|
|
|
|
}
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TVNavigationView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
TVNavigationView()
|
2021-09-29 11:45:00 +00:00
|
|
|
.injectFixtureEnvironmentObjects()
|
2021-07-11 20:52:49 +00:00
|
|
|
}
|
|
|
|
}
|