mirror of
https://github.com/yattee/yattee.git
synced 2026-10-31 17:07:18 +00:00
Hide toolbar account switchers where the sidebar already shows one
This commit is contained in:
@@ -256,6 +256,20 @@ enum DataContextSwitcherVisibility {
|
|||||||
guard let appEnvironment else { return false }
|
guard let appEnvironment else { return false }
|
||||||
return appEnvironment.settingsManager.showAccountPickers && showsSwitcher(in: appEnvironment)
|
return appEnvironment.settingsManager.showAccountPickers && showsSwitcher(in: appEnvironment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if os(iOS)
|
||||||
|
/// The iOS toolbar menus: same rule again, minus the regular widths, where
|
||||||
|
/// the sidebar layout already pins the switcher in its bottom bar — a
|
||||||
|
/// toolbar button there would say the same thing twice, the way macOS
|
||||||
|
/// toolbars already leave it to the sidebar row.
|
||||||
|
@MainActor
|
||||||
|
static func showsToolbarPickers(
|
||||||
|
in appEnvironment: AppEnvironment?,
|
||||||
|
horizontalSizeClass: UserInterfaceSizeClass?
|
||||||
|
) -> Bool {
|
||||||
|
horizontalSizeClass == .compact && showsPickers(in: appEnvironment)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Glyph
|
// MARK: - Glyph
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import SwiftUI
|
|||||||
|
|
||||||
struct HistoryListView: View {
|
struct HistoryListView: View {
|
||||||
@Environment(\.appEnvironment) private var appEnvironment
|
@Environment(\.appEnvironment) private var appEnvironment
|
||||||
|
#if os(iOS)
|
||||||
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
|
#endif
|
||||||
@Namespace private var sheetTransition
|
@Namespace private var sheetTransition
|
||||||
|
|
||||||
/// One row, from whichever history the screen is reading.
|
/// One row, from whichever history the screen is reading.
|
||||||
@@ -331,10 +334,11 @@ struct HistoryListView: View {
|
|||||||
ToolbarSpacer(.flexible, placement: .primaryAction)
|
ToolbarSpacer(.flexible, placement: .primaryAction)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// No switcher on macOS: the sidebar row is the one persistent
|
// No switcher wherever a sidebar shows one: the macOS sidebar row
|
||||||
// switcher surface there.
|
// and the iPad sidebar's bottom bar are the persistent switcher
|
||||||
|
// surfaces there, so the toolbar menu is compact-width-only.
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
if DataContextSwitcherVisibility.showsPickers(in: appEnvironment) {
|
if DataContextSwitcherVisibility.showsToolbarPickers(in: appEnvironment, horizontalSizeClass: horizontalSizeClass) {
|
||||||
ToolbarItem(placement: viewOptionsPlacement) {
|
ToolbarItem(placement: viewOptionsPlacement) {
|
||||||
DataContextSwitcherMenu()
|
DataContextSwitcherMenu()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import SwiftUI
|
|||||||
|
|
||||||
struct HomeView: View {
|
struct HomeView: View {
|
||||||
@Environment(\.appEnvironment) private var appEnvironment
|
@Environment(\.appEnvironment) private var appEnvironment
|
||||||
|
#if os(iOS)
|
||||||
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
|
#endif
|
||||||
@Environment(\.scenePhase) private var scenePhase
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
#if !os(tvOS) && !os(macOS)
|
#if !os(tvOS) && !os(macOS)
|
||||||
@Namespace private var sheetTransition
|
@Namespace private var sheetTransition
|
||||||
@@ -166,10 +169,11 @@ struct HomeView: View {
|
|||||||
.toolbarTitleDisplayMode(.inlineLarge)
|
.toolbarTitleDisplayMode(.inlineLarge)
|
||||||
#endif
|
#endif
|
||||||
.toolbar {
|
.toolbar {
|
||||||
// No switcher on macOS: the sidebar row is the one persistent
|
// No switcher wherever a sidebar shows one: the macOS sidebar row
|
||||||
// switcher surface there.
|
// and the iPad sidebar's bottom bar are the persistent switcher
|
||||||
|
// surfaces there, so the toolbar menu is compact-width-only.
|
||||||
#if !os(tvOS) && !os(macOS)
|
#if !os(tvOS) && !os(macOS)
|
||||||
if DataContextSwitcherVisibility.showsPickers(in: appEnvironment) {
|
if DataContextSwitcherVisibility.showsToolbarPickers(in: appEnvironment, horizontalSizeClass: horizontalSizeClass) {
|
||||||
ToolbarItem(placement: .primaryAction) {
|
ToolbarItem(placement: .primaryAction) {
|
||||||
DataContextSwitcherMenu()
|
DataContextSwitcherMenu()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import SwiftUI
|
|||||||
|
|
||||||
struct PlaylistsListView: View {
|
struct PlaylistsListView: View {
|
||||||
@Environment(\.appEnvironment) private var appEnvironment
|
@Environment(\.appEnvironment) private var appEnvironment
|
||||||
|
#if os(iOS)
|
||||||
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||||
|
#endif
|
||||||
@Namespace private var sheetTransition
|
@Namespace private var sheetTransition
|
||||||
@State private var localPlaylists: [LocalPlaylist] = []
|
@State private var localPlaylists: [LocalPlaylist] = []
|
||||||
@State private var searchText = ""
|
@State private var searchText = ""
|
||||||
@@ -229,10 +232,11 @@ struct PlaylistsListView: View {
|
|||||||
ToolbarSpacer(.flexible, placement: .primaryAction)
|
ToolbarSpacer(.flexible, placement: .primaryAction)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// No switcher on macOS: the sidebar row is the one persistent
|
// No switcher wherever a sidebar shows one: the macOS sidebar row
|
||||||
// switcher surface there.
|
// and the iPad sidebar's bottom bar are the persistent switcher
|
||||||
|
// surfaces there, so the toolbar menu is compact-width-only.
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
if DataContextSwitcherVisibility.showsPickers(in: appEnvironment) {
|
if DataContextSwitcherVisibility.showsToolbarPickers(in: appEnvironment, horizontalSizeClass: horizontalSizeClass) {
|
||||||
ToolbarItem(placement: viewOptionsPlacement) {
|
ToolbarItem(placement: viewOptionsPlacement) {
|
||||||
DataContextSwitcherMenu()
|
DataContextSwitcherMenu()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,10 +492,12 @@ struct SubscriptionsView: View {
|
|||||||
.toolbarTitleDisplayMode(.inlineLarge)
|
.toolbarTitleDisplayMode(.inlineLarge)
|
||||||
#endif
|
#endif
|
||||||
.toolbar {
|
.toolbar {
|
||||||
// No switcher on macOS: the sidebar row is the one persistent
|
// No switcher wherever a sidebar shows one: the macOS
|
||||||
// switcher surface there.
|
// sidebar row and the iPad sidebar's bottom bar are the
|
||||||
|
// persistent switcher surfaces there, so the toolbar menu
|
||||||
|
// is compact-width-only.
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
if DataContextSwitcherVisibility.showsPickers(in: appEnvironment) {
|
if DataContextSwitcherVisibility.showsToolbarPickers(in: appEnvironment, horizontalSizeClass: horizontalSizeClass) {
|
||||||
ToolbarItem(placement: viewOptionsPlacement) {
|
ToolbarItem(placement: viewOptionsPlacement) {
|
||||||
DataContextSwitcherMenu()
|
DataContextSwitcherMenu()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user