I'm dealing with some extra space at the top of a view when using NavigationView, which appears is because you only need to use NavigationView once within all the views in the navigation stack. The problem is that the view with this issue only sometimes is loaded via a parent view that has NavigationView. It is also seen by itself directly loaded in the sheet() without the user having come through the parent view that has NavigationView.
How can I approach this? I guess I could pass in a value from the ParentView to the DetailView and detect if it exists and if/else using NavigationView there.. but that seems hacky?
There are 3 views. All are displayed inside sheets:
ParentView - has a wrapping NavigationView and the content is a loop of NavigationLinks in a list. (they load the destination with .navigationBarTitle("")
.navigationBarHidden(true))
DetailView - This view is sometimes accessed directly, and sometimes by coming in via ParentView. This is the view where I have the issue. If I use NavigationView, that's the only way I can get a NavigationLink to let me navigate to DetailChildView. But doing so gives me a big gap at the top of my view (which I don't want to hack away with offset etc). If I don't use NavigationView - there is no gap of course, but I am unable to tap on a NavigationLink I have in this view.
DetailChildView - Just a basic destination view with no NavigationView or NavigationLink.
Edit:... I think I got this working by keeping the NavigationView inside my DetailView but placing .navigationBarHidden(true) and .navigationBarTitle("") after my inner ZStack, not on the NavigationView.. Will test more and see if that was indeed the fix