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

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