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

83 lines
3.1 KiB
Swift
Raw Normal View History

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