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

63 lines
2.1 KiB
Swift
Raw Normal View History

2021-07-12 02:22:49 +05:30
import Defaults
import SwiftUI
struct TVNavigationView: View {
@EnvironmentObject<NavigationState> private var navigationState
@State private var showingOptions = false
@Default(.showingAddToPlaylist) var showingAddToPlaylist
2021-07-12 02:22:49 +05:30
var body: some View {
NavigationView {
TabView(selection: $navigationState.tabSelection) {
SubscriptionsView()
.tabItem { Text("Subscriptions") }
.tag(TabSelection.subscriptions)
2021-07-28 04:10:04 +05:30
PopularView()
2021-07-12 02:22:49 +05:30
.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: $showingOptions) { OptionsView() }
.fullScreenCover(isPresented: $showingAddToPlaylist) { AddToPlaylistView() }
2021-07-12 02:22:49 +05:30
.fullScreenCover(isPresented: $navigationState.showingVideoDetails) {
if let video = navigationState.video {
VideoDetailsView(video)
}
}
2021-07-19 04:02:46 +05:30
.fullScreenCover(isPresented: $navigationState.showingChannel, onDismiss: {
navigationState.showVideoDetailsIfNeeded()
}) {
2021-07-12 02:22:49 +05:30
if let channel = navigationState.channel {
ChannelView(id: channel.id)
}
}
.fullScreenCover(isPresented: $navigationState.showingVideo) {
if let video = navigationState.video {
VideoPlayerView(video)
}
}
2021-07-12 02:22:49 +05:30
.onPlayPauseCommand { showingOptions.toggle() }
}
}
}
struct TVNavigationView_Previews: PreviewProvider {
static var previews: some View {
TVNavigationView()
}
}