yattee/tvOS/TVNavigationView.swift

67 lines
2.3 KiB
Swift
Raw Normal View History

2021-07-11 20:52:49 +00:00
import Defaults
import SwiftUI
struct TVNavigationView: View {
2021-09-25 08:18:22 +00:00
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlaybackModel> private var playback
@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-09-18 20:36:42 +00:00
WatchNowView()
.tabItem { Text("Watch Now") }
.tag(TabSelection.watchNow)
2021-08-02 23:13:42 +00:00
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: $navigation.presentingSettings) { SettingsView() }
.fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) {
if let video = navigation.videoToAddToPlaylist {
AddToPlaylistView(video: video)
}
}
2021-09-25 08:18:22 +00:00
.fullScreenCover(isPresented: $navigation.showingVideo) {
if let video = navigation.video {
2021-08-02 23:13:42 +00:00
VideoPlayerView(video)
2021-09-25 08:18:22 +00:00
.environmentObject(playback)
}
2021-07-11 20:52:49 +00:00
}
2021-09-25 08:18:22 +00:00
.fullScreenCover(isPresented: $navigation.isChannelOpen) {
2021-09-19 11:06:54 +00:00
if let channel = recents.presentedChannel {
2021-09-25 08:18:22 +00:00
ChannelVideosView(channel: channel)
}
}
.onPlayPauseCommand { navigation.presentingSettings.toggle() }
2021-07-11 20:52:49 +00:00
}
}
struct TVNavigationView_Previews: PreviewProvider {
static var previews: some View {
TVNavigationView()
.environmentObject(InvidiousAPI())
.environmentObject(NavigationModel())
.environmentObject(SearchModel())
.environmentObject(InstancesModel())
.environmentObject(SubscriptionsModel())
2021-07-11 20:52:49 +00:00
}
}