BLACK FRIDAY SALE: Save 50% on all my Swift books and bundles! >>

MacOS SwifUI - View/Window size control with 2 sidebars (Left and right sides)

Forums > macOS

I want to layout a window that works in the same way Xcode works. By this I mean it has a sidebar on both sides and a document view in the middle.

The left sidebar is the "master" and the document and right sidebar will display data based on the master item selected.

That all works, and the user can adjust the size of the two side bars.

The problem is the size of the side bars as set by the user dragging is overridden when a new master item is selected or when the window is resized by the user.

The left side bar is working as expected, the right side bar is self adjusting when the window size is changed by the user.

I have implemented it with a NavigationView on the left side bar and a second navigation view on the center document view and the left sidebar displayed in it.

And I have tried using a NavigationView around the left sidebar with HSplitview around the Document and right side view.

How do I get the window width adjustment to ONLY affect the document view, and the size of the sidebars to be adjustable by the User only, the way it works in XCode.

Here is the project on GitHub if anyone would like to look and make suggestions:





Maybe a clearer way to state this is - I want the user to be able to adjust the width of the rightside sidebar, and I do not want a change in the window width to affect it. The only document (center view) should expand or shrink in response to changes in the window width.

ANY suggestions will be appreciated.


Save 50% in my Black Friday sale.

SAVE 50% To celebrate Black Friday, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.