yattee/tvOS/TVNavigationView.swift

76 lines
2.6 KiB
Swift
Raw Normal View History

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
@EnvironmentObject<PlayerModel> private var player
2021-09-25 08:18:22 +00:00
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<RecentsModel> private var recents
2021-09-25 08:18:22 +00:00
@EnvironmentObject<SearchModel> private var search
2021-07-11 20:52:49 +00:00
var body: some View {
2021-09-28 23:01:49 +00:00
TabView(selection: navigation.tabSelectionBinding) {
2021-11-01 21:56:18 +00:00
FavoritesView()
.tabItem { Text("Favorites") }
.tag(TabSelection.favorites)
2021-09-18 20:36:42 +00:00
2021-10-20 22:21:50 +00:00
if accounts.app.supportsSubscriptions {
SubscriptionsView()
.tabItem { Text("Subscriptions") }
.tag(TabSelection.subscriptions)
}
2021-08-02 23:13:42 +00:00
2021-10-20 22:21:50 +00:00
if accounts.app.supportsPopular {
PopularView()
.tabItem { Text("Popular") }
.tag(TabSelection.popular)
}
2021-08-02 23:13:42 +00:00
TrendingView()
.tabItem { Text("Trending") }
.tag(TabSelection.trending)
2021-10-20 22:21:50 +00:00
if accounts.app.supportsUserPlaylists {
PlaylistsView()
.tabItem { Text("Playlists") }
.tag(TabSelection.playlists)
}
2021-08-02 23:13:42 +00:00
NowPlayingView()
.tabItem { Text("Now Playing") }
.tag(TabSelection.nowPlaying)
2021-08-02 23:13:42 +00:00
SearchView()
.tabItem { Image(systemName: "magnifyingglass") }
.tag(TabSelection.search)
}
.fullScreenCover(isPresented: $navigation.presentingSettings) { SettingsView() }
.fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) {
if let video = navigation.videoToAddToPlaylist {
AddToPlaylistView(video: video)
}
}
.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-10-22 23:04:03 +00:00
.fullScreenCover(isPresented: $navigation.presentingPlaylist) {
if let playlist = recents.presentedPlaylist {
ChannelPlaylistView(playlist: playlist)
}
}
.onPlayPauseCommand { navigation.presentingSettings.toggle() }
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
}
}