Use lazy views in TV navigation

This commit is contained in:
Arkadiusz Fal 2022-09-04 17:19:22 +02:00
parent 179455bbc0
commit 07b6649f26

View File

@ -14,44 +14,44 @@ struct TVNavigationView: View {
NavigationView { NavigationView {
TabView(selection: navigation.tabSelectionBinding) { TabView(selection: navigation.tabSelectionBinding) {
if visibleSections.contains(.favorites) { if visibleSections.contains(.favorites) {
FavoritesView() LazyView(FavoritesView())
.tabItem { Text("Favorites") } .tabItem { Text("Favorites") }
.tag(TabSelection.favorites) .tag(TabSelection.favorites)
} }
if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions, accounts.api.signedIn { if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions, accounts.api.signedIn {
SubscriptionsView() LazyView(SubscriptionsView())
.tabItem { Text("Subscriptions") } .tabItem { Text("Subscriptions") }
.tag(TabSelection.subscriptions) .tag(TabSelection.subscriptions)
} }
if visibleSections.contains(.popular), accounts.app.supportsPopular { if visibleSections.contains(.popular), accounts.app.supportsPopular {
PopularView() LazyView(PopularView())
.tabItem { Text("Popular") } .tabItem { Text("Popular") }
.tag(TabSelection.popular) .tag(TabSelection.popular)
} }
if visibleSections.contains(.trending) { if visibleSections.contains(.trending) {
TrendingView() LazyView(TrendingView())
.tabItem { Text("Trending") } .tabItem { Text("Trending") }
.tag(TabSelection.trending) .tag(TabSelection.trending)
} }
if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists, accounts.signedIn { if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists, accounts.signedIn {
PlaylistsView() LazyView(PlaylistsView())
.tabItem { Text("Playlists") } .tabItem { Text("Playlists") }
.tag(TabSelection.playlists) .tag(TabSelection.playlists)
} }
NowPlayingView() LazyView(NowPlayingView())
.tabItem { Text("Now Playing") } .tabItem { Text("Now Playing") }
.tag(TabSelection.nowPlaying) .tag(TabSelection.nowPlaying)
SearchView() LazyView(SearchView())
.tabItem { Image(systemName: "magnifyingglass") } .tabItem { Image(systemName: "magnifyingglass") }
.tag(TabSelection.search) .tag(TabSelection.search)
SettingsView() LazyView(SettingsView())
.tabItem { Image(systemName: "gear") } .tabItem { Image(systemName: "gear") }
.tag(TabSelection.settings) .tag(TabSelection.settings)
} }