1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 13:50:32 +05:30
yattee/tvOS/TVNavigationView.swift
2021-09-29 13:45:00 +02:00

63 lines
2.1 KiB
Swift

import Defaults
import SwiftUI
struct TVNavigationView: View {
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlaybackModel> private var playback
@EnvironmentObject<RecentsModel> private var recents
@EnvironmentObject<SearchModel> private var search
var body: some View {
TabView(selection: navigation.tabSelectionBinding) {
WatchNowView()
.tabItem { Text("Watch Now") }
.tag(TabSelection.watchNow)
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)
}
}
.fullScreenCover(isPresented: $navigation.showingVideo) {
if let video = navigation.video {
VideoPlayerView(video)
.environmentObject(playback)
}
}
.fullScreenCover(isPresented: $navigation.isChannelOpen) {
if let channel = recents.presentedChannel {
ChannelVideosView(channel: channel)
}
}
.onPlayPauseCommand { navigation.presentingSettings.toggle() }
}
}
struct TVNavigationView_Previews: PreviewProvider {
static var previews: some View {
TVNavigationView()
.injectFixtureEnvironmentObjects()
}
}