Hi Ziqiao,
the problem is that when you want to use SwiftData for an enterprise app, the user needs proper navigation. In such apps, you usually have more than one screen or form. I did some additional tests with your code and replaced the NavigationStack with a NavigationView. The reason is that I need the automatic two-column split for a sidebar menu and a detail view, not just a single view.
The NavigationSplitView doesn’t seem to work as expected. Using it as a root view with an embedded TabView was my first attempt, but that didn’t work either. That’s why I tried embedding the NavigationSplitViews inside the TabView.
When I replace your NavigationStack with a NavigationView, I get the automatic two-column view on iPad — but with a second navigation view below the DocumentGroup navigation view. This looks bugged.
The NavigationSplitView also has issues with the back button and the document title in sheets.
I’ll file a feedback report for now as you suggested and try to find a workaround for my app, maybe with a custom sidebar built as an HStack.
But thanks for your help with this problem.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: