FREE TRIAL: Accelerate your app development career with Hacking with Swift+! >>

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:

Hermes

TIA,

Frank

1      

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.

   

Hacking with Swift is sponsored by Sentry

SPONSORED With Sentry’s error and performance monitoring for iOS you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.

Get started

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

Reply to this topic…

You need to create an account or log in to reply.

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.