Setting icon indicating copy to clipboard operation
Setting copied to clipboard

Add opt-in usage of sidebar in NavigationStack/NavigationView

Open orchetect opened this issue 2 years ago • 6 comments

This is a fantastic library and just the thing I was looking for recently.

I am building a macOS app and I'm working on a refactor of Setting to allow the use of the sidebar as the top level, very much like how macOS Ventura's System Settings does:

macos-settings

It started as a small refactor (WIP) of the SettingExample project to use NavigationView with a sidebar instead of TabView:

setting-sidebar

But then I realized it would be much nicer if the sidebar was actually an opt-in feature of Setting. The reason is that right now, the text search function only searches within the scope of the current top-level item selected, not across all of them at once.

Additionally, in macOS Settings, the search bar is positioned within the sidebar (which doesn't really work on macOS) and its text search filters the sidebar contents during searching.

orchetect avatar Feb 24 '23 06:02 orchetect

Good points. The tab bar was supposed to just be for demo purposes — there's 4 tabs that each contain a separate instance of Setting. I was trying to mock up different scenarios where you'd use the library.

Instead, maybe the sidebar should contain the top-level list of settings, like this?

Sidebar on left, detail on right

It'll be a master-detail presentation style. This is possible in iOS 16 / macOS Ventura using NavigationSplitView.

aheze avatar Feb 24 '23 08:02 aheze

I'm trying to maintain current compatibility if possible so I'm using NavigationSplitView for the newer platforms and NavigationView for the older ones.

I have a somewhat workable prototype now, but it's proving challenging to adapt the existing code.

orchetect avatar Feb 24 '23 08:02 orchetect

I'm going to put a pin in this and circle back later - there's other projects needing attention. If you feel inclined to attempt implementing any of this feel free of course. I love the concept of this library and you've done really great work. I think the extra touch of making it truly feel at home on macOS could definitely take it to the next level.

orchetect avatar Feb 24 '23 18:02 orchetect

@orchetect can you share the refactoring work you did? Sounds like a great idea, I'm trying to build something with the same UI right now and also finding it difficult to refactor my own fork.

Happy to look at picking up where you left off if you can share a link.

DanBurkhardt avatar Oct 28 '23 07:10 DanBurkhardt

@DanBurkhardt I didn't get very far at the time. Got pulled onto other projects and also ran into some roadblocks that were making it evident that a proper refactor to add macOS look and feel was going to be a lot more work than it seemed.

I don't think there's anything useful in my old fork honestly. It would be best to just fork and start from scratch.

orchetect avatar Oct 29 '23 05:10 orchetect

I actually figured it out last night, how to force the thing to present as a Swift UI view with NSHostingController, and properly navigate with a back button / maintaining the navigation stack.

Will link to my fork after I clean

it up and ship it, it's a little hacky and tbh I don't fully understand why it works, but it does.

https://github.com/aheze/Setting/assets/14014682/d42e10d7-3c8d-4965-8cf3-746e38862574

DanBurkhardt avatar Oct 29 '23 05:10 DanBurkhardt