diff --git a/Model/NavigationModel.swift b/Model/NavigationModel.swift index 91299ddf..6c4c81cd 100644 --- a/Model/NavigationModel.swift +++ b/Model/NavigationModel.swift @@ -13,6 +13,9 @@ final class NavigationModel: ObservableObject { case recentlyOpened(String) case nowPlaying case search + #if os(tvOS) + case settings + #endif var stringValue: String { switch self { @@ -34,6 +37,10 @@ final class NavigationModel: ObservableObject { return "recentlyOpened" case .search: return "search" + #if os(tvOS) + case .settings: // swiftlint:disable:this switch_case_alignment + return "settings" + #endif default: return "" } diff --git a/Shared/Settings/SettingsView.swift b/Shared/Settings/SettingsView.swift index 9fd37eb9..9ad36019 100644 --- a/Shared/Settings/SettingsView.swift +++ b/Shared/Settings/SettingsView.swift @@ -79,90 +79,99 @@ struct SettingsView: View { .padding(20) .frame(width: 480, height: windowHeight) #else - NavigationView { - List { - #if os(tvOS) - AccountSelectionView() - #endif - - Section(header: Text("Instances")) { - ForEach(instances) { instance in - AccountsNavigationLink(instance: instance) - } - addInstanceButton + Group { + #if os(tvOS) + settingsList + #else + NavigationView { + settingsList } - - #if os(tvOS) - Divider() - #endif - - Section { - #if os(tvOS) - NavigationLink { - EditFavorites() - } label: { - Label("Favorites", systemImage: "heart.fill") - } - #endif - - NavigationLink { - BrowsingSettings() - } label: { - Label("Browsing", systemImage: "list.and.film") - } - - NavigationLink { - PlayerSettings() - } label: { - Label("Player", systemImage: "play.rectangle") - } - - NavigationLink { - HistorySettings() - } label: { - Label("History", systemImage: "clock.arrow.circlepath") - } - - NavigationLink { - SponsorBlockSettings() - } label: { - Label("SponsorBlock", systemImage: "dollarsign.circle") - } - } - - Section(footer: versionString) { - NavigationLink { - Help() - } label: { - Label("Help", systemImage: "questionmark.circle") - } - } - } - .navigationTitle("Settings") - .toolbar { - ToolbarItem(placement: .navigationBarLeading) { - #if !os(tvOS) - Button("Done") { - presentationMode.wrappedValue.dismiss() - } - .keyboardShortcut(.cancelAction) - #endif - } - } - .frame(maxWidth: 1000) - #if os(iOS) - .listStyle(.insetGrouped) #endif } .sheet(isPresented: $presentingInstanceForm) { InstanceForm(savedInstanceID: $savedFormInstanceID) } - #if os(tvOS) - .background(Color.background(scheme: colorScheme)) - #endif #endif } + #if !os(macOS) + var settingsList: some View { + List { + #if os(tvOS) + AccountSelectionView() + #endif + + Section(header: Text("Instances")) { + ForEach(instances) { instance in + AccountsNavigationLink(instance: instance) + } + addInstanceButton + } + + #if os(tvOS) + Divider() + #endif + + Section { + #if os(tvOS) + NavigationLink { + EditFavorites() + } label: { + Label("Favorites", systemImage: "heart.fill") + } + #endif + + NavigationLink { + BrowsingSettings() + } label: { + Label("Browsing", systemImage: "list.and.film") + } + + NavigationLink { + PlayerSettings() + } label: { + Label("Player", systemImage: "play.rectangle") + } + + NavigationLink { + HistorySettings() + } label: { + Label("History", systemImage: "clock.arrow.circlepath") + } + + NavigationLink { + SponsorBlockSettings() + } label: { + Label("SponsorBlock", systemImage: "dollarsign.circle") + } + } + + Section(footer: versionString) { + NavigationLink { + Help() + } label: { + Label("Help", systemImage: "questionmark.circle") + } + } + } + .navigationTitle("Settings") + .toolbar { + ToolbarItem(placement: .navigationBarLeading) { + #if !os(tvOS) + Button("Done") { + presentationMode.wrappedValue.dismiss() + } + .keyboardShortcut(.cancelAction) + #endif + } + } + .frame(maxWidth: 1000) + #if os(iOS) + .listStyle(.insetGrouped) + #endif + } + #endif + #if os(macOS) private var windowHeight: Double { switch selection { diff --git a/tvOS/TVNavigationView.swift b/tvOS/TVNavigationView.swift index 7adaa941..adf1b42b 100644 --- a/tvOS/TVNavigationView.swift +++ b/tvOS/TVNavigationView.swift @@ -10,44 +10,51 @@ struct TVNavigationView: View { @Default(.visibleSections) private var visibleSections var body: some View { - TabView(selection: navigation.tabSelectionBinding) { - if visibleSections.contains(.favorites) { - FavoritesView() - .tabItem { Text("Favorites") } - .tag(TabSelection.favorites) + NavigationView { + TabView(selection: navigation.tabSelectionBinding) { + if visibleSections.contains(.favorites) { + FavoritesView() + .tabItem { Text("Favorites") } + .tag(TabSelection.favorites) + } + + if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions, accounts.api.signedIn { + SubscriptionsView() + .tabItem { Text("Subscriptions") } + .tag(TabSelection.subscriptions) + } + + if visibleSections.contains(.popular), accounts.app.supportsPopular { + PopularView() + .tabItem { Text("Popular") } + .tag(TabSelection.popular) + } + + if visibleSections.contains(.trending) { + TrendingView() + .tabItem { Text("Trending") } + .tag(TabSelection.trending) + } + + if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists { + PlaylistsView() + .tabItem { Text("Playlists") } + .tag(TabSelection.playlists) + } + + NowPlayingView() + .tabItem { Text("Now Playing") } + .tag(TabSelection.nowPlaying) + + SearchView() + .tabItem { Image(systemName: "magnifyingglass") } + .tag(TabSelection.search) + + SettingsView() + .navigationBarHidden(true) + .tabItem { Image(systemName: "gear") } + .tag(TabSelection.settings) } - - if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions, accounts.api.signedIn { - SubscriptionsView() - .tabItem { Text("Subscriptions") } - .tag(TabSelection.subscriptions) - } - - if visibleSections.contains(.popular), accounts.app.supportsPopular { - PopularView() - .tabItem { Text("Popular") } - .tag(TabSelection.popular) - } - - if visibleSections.contains(.trending) { - TrendingView() - .tabItem { Text("Trending") } - .tag(TabSelection.trending) - } - - if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists { - PlaylistsView() - .tabItem { Text("Playlists") } - .tag(TabSelection.playlists) - } - - NowPlayingView() - .tabItem { Text("Now Playing") } - .tag(TabSelection.nowPlaying) - - SearchView() - .tabItem { Image(systemName: "magnifyingglass") } - .tag(TabSelection.search) } .fullScreenCover(isPresented: $navigation.presentingSettings) { SettingsView() } .fullScreenCover(isPresented: $navigation.presentingAddToPlaylist) { @@ -68,7 +75,6 @@ struct TVNavigationView: View { ChannelPlaylistView(playlist: playlist) } } - .onPlayPauseCommand { navigation.presentingSettings.toggle() } } }