UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SwiftUi, hiding the sidebar and program state.

Forums > SwiftUI

This may be a relatively beginners question, but I have a Mac app that displays some items in its details view when you click on the library option in the sidebar. All well and good. However the sidebar isnt really that important to the app. It has the Library link, a FAQ link, settings, logout, and preferences. The library is automatically selected and its where the user is going to be 90% of the time.

I want to stick with standard SwiftUI flow nevertheles, everything in a NavigationView., so I dont really want a single document based page with those options on a toolbar or a menu.

Questions:

1) Can I open with the sidebar closed on first launch? 2) Program state is not being preserved in any case so if I close the sidebar it comes back. How to fix this?

Any thoughts?

2      

You could consider .navlgationViewStyle(.stack), then programmatically have a method to select whether to see the stacked or unstacked view, using Group to collect the views.

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.