Let the user hide the account pickers outside Settings

This commit is contained in:
Arkadiusz Fal
2026-09-13 18:56:18 +02:00
parent ce97aa1031
commit 5136b79f49
10 changed files with 101 additions and 17 deletions

View File

@@ -19,6 +19,9 @@ enum SettingsKey: String, CaseIterable {
case useSeparateDarkAccentColor
case showWatchedCheckmark
// Accounts
case showAccountPickers
// Playback
case preferredQuality
case cellularQuality

View File

@@ -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.

View File

@@ -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

View File

@@ -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" : {

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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()
}
}
}