From 5136b79f49d7629ff3f5441c76d7289a0dd13bd6 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 13 Sep 2026 18:56:18 +0200 Subject: [PATCH] Let the user hide the account pickers outside Settings --- Yattee/Core/Settings/SettingsKey.swift | 3 +++ .../Settings/SettingsManager+General.swift | 15 ++++++++++++ Yattee/Core/SettingsManager.swift | 4 ++++ Yattee/Localizable.xcstrings | 22 +++++++++++++++++ Yattee/Views/Home/HistoryListView.swift | 10 +++++--- Yattee/Views/Home/HomeView.swift | 6 +++-- Yattee/Views/Home/PlaylistsListView.swift | 10 +++++--- Yattee/Views/Navigation/UnifiedTabView.swift | 14 ++++++----- Yattee/Views/Settings/AccountsListView.swift | 24 +++++++++++++++++++ .../Subscriptions/SubscriptionsView.swift | 10 +++++--- 10 files changed, 101 insertions(+), 17 deletions(-) diff --git a/Yattee/Core/Settings/SettingsKey.swift b/Yattee/Core/Settings/SettingsKey.swift index 69fa0691..7ce3e53d 100644 --- a/Yattee/Core/Settings/SettingsKey.swift +++ b/Yattee/Core/Settings/SettingsKey.swift @@ -19,6 +19,9 @@ enum SettingsKey: String, CaseIterable { case useSeparateDarkAccentColor case showWatchedCheckmark + // Accounts + case showAccountPickers + // Playback case preferredQuality case cellularQuality diff --git a/Yattee/Core/Settings/SettingsManager+General.swift b/Yattee/Core/Settings/SettingsManager+General.swift index d8acd704..6d979225 100644 --- a/Yattee/Core/Settings/SettingsManager+General.swift +++ b/Yattee/Core/Settings/SettingsManager+General.swift @@ -220,6 +220,21 @@ extension SettingsManager { } } + /// Whether the account switcher is offered outside Settings — the toolbar + /// menus, the tvOS buttons, the macOS sidebar row. The switcher on the + /// accounts settings screen stays regardless: it is where this is turned + /// back on. Default is true (visible). + var showAccountPickers: Bool { + get { + if let cached = _showAccountPickers { return cached } + return bool(for: .showAccountPickers, default: true) + } + set { + _showAccountPickers = newValue + set(newValue, for: .showAccountPickers) + } + } + // MARK: - Feed Settings /// Feed cache validity duration in minutes. Default is 30 minutes. diff --git a/Yattee/Core/SettingsManager.swift b/Yattee/Core/SettingsManager.swift index e203dff1..d9bb13d2 100644 --- a/Yattee/Core/SettingsManager.swift +++ b/Yattee/Core/SettingsManager.swift @@ -34,6 +34,9 @@ final class SettingsManager { var _useSeparateDarkAccentColor: Bool? var _showWatchedCheckmark: Bool? + // Accounts + var _showAccountPickers: Bool? + // Playback var _preferredQuality: VideoQuality? var _cellularQuality: VideoQuality? @@ -424,6 +427,7 @@ final class SettingsManager { _customAccentColorDark = nil _useSeparateDarkAccentColor = nil _showWatchedCheckmark = nil + _showAccountPickers = nil _preferredQuality = nil _cellularQuality = nil _backgroundPlaybackEnabled = nil diff --git a/Yattee/Localizable.xcstrings b/Yattee/Localizable.xcstrings index 01a806b8..7f0e98dc 100644 --- a/Yattee/Localizable.xcstrings +++ b/Yattee/Localizable.xcstrings @@ -350,6 +350,28 @@ } } }, + "accounts.showPickers" : { + "comment" : "Toggle on the accounts screen controlling whether account switchers appear outside Settings", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Show Account Pickers" + } + } + } + }, + "accounts.showPickers.footer" : { + "comment" : "Footer of the account pickers visibility toggle", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Show buttons for switching accounts outside of Settings, such as in toolbars." + } + } + } + }, "accounts.signIn.identityChanged" : { "localizations" : { "en" : { diff --git a/Yattee/Views/Home/HistoryListView.swift b/Yattee/Views/Home/HistoryListView.swift index 68b3bb45..0bb89ada 100644 --- a/Yattee/Views/Home/HistoryListView.swift +++ b/Yattee/Views/Home/HistoryListView.swift @@ -289,7 +289,9 @@ struct HistoryListView: View { } } - DataContextSwitcherButton() + if appEnvironment?.settingsManager.showAccountPickers ?? true { + DataContextSwitcherButton() + } } .focusSection() .padding(.horizontal, 48) @@ -329,8 +331,10 @@ struct HistoryListView: View { ToolbarSpacer(.flexible, placement: .primaryAction) } #endif - ToolbarItem(placement: viewOptionsPlacement) { - DataContextSwitcherMenu() + if appEnvironment?.settingsManager.showAccountPickers ?? true { + ToolbarItem(placement: viewOptionsPlacement) { + DataContextSwitcherMenu() + } } // View options button (always visible) ToolbarItem(placement: viewOptionsPlacement) { diff --git a/Yattee/Views/Home/HomeView.swift b/Yattee/Views/Home/HomeView.swift index ecb1227e..9fd3944a 100644 --- a/Yattee/Views/Home/HomeView.swift +++ b/Yattee/Views/Home/HomeView.swift @@ -178,8 +178,10 @@ struct HomeView: View { #endif .toolbar { #if !os(tvOS) - ToolbarItem(placement: switcherPlacement) { - DataContextSwitcherMenu() + if settingsManager?.showAccountPickers ?? true { + ToolbarItem(placement: switcherPlacement) { + DataContextSwitcherMenu() + } } #endif #if !os(tvOS) && !os(macOS) diff --git a/Yattee/Views/Home/PlaylistsListView.swift b/Yattee/Views/Home/PlaylistsListView.swift index aea23b91..fe57b987 100644 --- a/Yattee/Views/Home/PlaylistsListView.swift +++ b/Yattee/Views/Home/PlaylistsListView.swift @@ -229,8 +229,10 @@ struct PlaylistsListView: View { ToolbarSpacer(.flexible, placement: .primaryAction) } #endif - ToolbarItem(placement: viewOptionsPlacement) { - DataContextSwitcherMenu() + if appEnvironment?.settingsManager.showAccountPickers ?? true { + ToolbarItem(placement: viewOptionsPlacement) { + DataContextSwitcherMenu() + } } ToolbarItem(placement: viewOptionsPlacement) { Button { @@ -425,7 +427,9 @@ struct PlaylistsListView: View { Label(String(localized: "viewOptions.title"), systemImage: "slider.horizontal.3") } - DataContextSwitcherButton() + if appEnvironment?.settingsManager.showAccountPickers ?? true { + DataContextSwitcherButton() + } } .focusSection() .padding(.horizontal, 48) diff --git a/Yattee/Views/Navigation/UnifiedTabView.swift b/Yattee/Views/Navigation/UnifiedTabView.swift index 4406e6ad..6aa19f82 100644 --- a/Yattee/Views/Navigation/UnifiedTabView.swift +++ b/Yattee/Views/Navigation/UnifiedTabView.swift @@ -427,12 +427,14 @@ struct UnifiedTabView: View { VStack(spacing: 0) { sidebarList - Divider() - // The window has no toolbar of its own to hang this off, and the - // sidebar is the one chrome every tab shares. - DataContextSwitcherSettingsRow() - .padding(.horizontal, 12) - .padding(.vertical, 8) + if settingsManager?.showAccountPickers ?? true { + Divider() + // The window has no toolbar of its own to hang this off, and the + // sidebar is the one chrome every tab shares. + DataContextSwitcherSettingsRow() + .padding(.horizontal, 12) + .padding(.vertical, 8) + } } #else sidebarList diff --git a/Yattee/Views/Settings/AccountsListView.swift b/Yattee/Views/Settings/AccountsListView.swift index 05b30a60..6cdf87d4 100644 --- a/Yattee/Views/Settings/AccountsListView.swift +++ b/Yattee/Views/Settings/AccountsListView.swift @@ -138,6 +138,8 @@ struct AccountsListView: View { } orphanSection + + pickerVisibilitySection } #if os(macOS) .formStyle(.grouped) @@ -221,6 +223,28 @@ struct AccountsListView: View { } } + /// Whether the switcher is offered outside this screen at all — the + /// toolbar menus, the tvOS buttons, the macOS sidebar row. Lives at the + /// bottom of this screen because this screen keeps its own switcher either + /// way: turning the pickers off must leave a place to turn them back on. + @ViewBuilder + private var pickerVisibilitySection: some View { + if let settings = appEnvironment?.settingsManager { + @Bindable var settings = settings + + Section { + Toggle(isOn: $settings.showAccountPickers) { + Label( + String(localized: "accounts.showPickers"), + systemImage: "person.crop.circle.badge.checkmark" + ) + } + } footer: { + Text(String(localized: "accounts.showPickers.footer")) + } + } + } + // MARK: - Rows @ViewBuilder diff --git a/Yattee/Views/Subscriptions/SubscriptionsView.swift b/Yattee/Views/Subscriptions/SubscriptionsView.swift index 82d4f5a7..3ef6d6d1 100644 --- a/Yattee/Views/Subscriptions/SubscriptionsView.swift +++ b/Yattee/Views/Subscriptions/SubscriptionsView.swift @@ -492,8 +492,10 @@ struct SubscriptionsView: View { .toolbarTitleDisplayMode(.inlineLarge) #endif .toolbar { - ToolbarItem(placement: viewOptionsPlacement) { - DataContextSwitcherMenu() + if appEnvironment?.settingsManager.showAccountPickers ?? true { + ToolbarItem(placement: viewOptionsPlacement) { + DataContextSwitcherMenu() + } } ToolbarItem(placement: viewOptionsPlacement) { Button { @@ -907,7 +909,9 @@ struct SubscriptionsView: View { } .buttonStyle(.bordered) - DataContextSwitcherButton() + if appEnvironment?.settingsManager.showAccountPickers ?? true { + DataContextSwitcherButton() + } } }