Pin view options button to leading toolbar edge on macOS

Place the view options control on the leading (`.navigation`) edge on
macOS so it is consistently the first/leftmost toolbar button across all
views, instead of sitting on the right next to the search field in
search views and on the left in non-search views.

Each affected view gains a computed `viewOptionsPlacement` (`.navigation`
on macOS, `.primaryAction` elsewhere) so iOS/iPadOS/tvOS keep the
button trailing. Search-style views (Search, InstanceBrowse) declare the
view options item first so it renders left of the search-filters button;
their flexible spacer is kept to right-pin the search field. Channel's
fixed spacer between view options and the channel menu is now iOS-only.
This commit is contained in:
Arkadiusz Fal
2026-06-14 16:03:10 +02:00
parent ad14c0129c
commit 77720ccea1
10 changed files with 139 additions and 41 deletions

View File

@@ -154,6 +154,15 @@ struct ChannelView: View {
)
}
/// View options button lives on the leading edge on macOS, trailing elsewhere.
private var viewOptionsPlacement: ToolbarItemPlacement {
#if os(macOS)
.navigation
#else
.primaryAction
#endif
}
var body: some View {
// The search modifier is hoisted above this state-switching Group so the
// search bar is present in every load state (loading spinner / cached header
@@ -387,7 +396,7 @@ struct ChannelView: View {
}
#endif
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: viewOptionsPlacement) {
Button {
showViewOptions = true
} label: {
@@ -401,8 +410,11 @@ struct ChannelView: View {
#endif
}
#if !os(tvOS)
if #available(iOS 26, macOS 26, *) {
// iOS keeps a fixed gap between the trailing view options and channel
// menu buttons; on macOS view options moves to the leading edge, so no
// gap is needed here.
#if os(iOS)
if #available(iOS 26, *) {
ToolbarSpacer(.fixed, placement: .primaryAction)
}
#endif
@@ -509,7 +521,7 @@ struct ChannelView: View {
}
#endif
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: viewOptionsPlacement) {
Button {
showViewOptions = true
} label: {
@@ -523,8 +535,11 @@ struct ChannelView: View {
#endif
}
#if !os(tvOS)
if #available(iOS 26, macOS 26, *) {
// iOS keeps a fixed gap between the trailing view options and channel
// menu buttons; on macOS view options moves to the leading edge, so no
// gap is needed here.
#if os(iOS)
if #available(iOS 26, *) {
ToolbarSpacer(.fixed, placement: .primaryAction)
}
#endif