GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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 RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's all new Paywall Editor allow you to remotely configure your paywall view without any code changes or app updates.

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.