I have two apps written in SwiftUI. Both use a NavigationSplitView as their primary content with a list-based sidebar. Both apps have a few toolbar items offering functionality relevant to the application purpose. Both sidebars have toolbar items, declared using the .toolbar view modifier, that add ToolbarItems to their view (a "filter" menu). Both the apps' main content view use .toolbar to add some ToolbarItems to the main content toolbar as well. Both also include the SidebarCommands() command group.
My question is this: in one app, when I click the Hide Sidebar button, the toolbar items that were attached to the sidebar move to the main toolbar. In my second app, the toolbar items move to the "More" disclosure menu at the end of the toolbar.
Video showing sidebar leading
Video showing sidebar trailing
I want behavior like the first app (where the toolbar items end up in the leading edge of the main toolbar) in the second app, but I've scrubbed through both applications' toolbar code, I've had coding assistants compare the two, I've tried stripping down the toolbar items to remove all but the Hide Sidebar. Nothing I can discover shows me why one app moves the toolbar items to the main toolbar up front, while the other moves them to the back.
Am I missing something about how to declare toolbar items? Is there some visibility priority thing I’m missing?
Topic:
UI Frameworks
SubTopic:
SwiftUI
4
0
81