I'm having problems related to .searchable
and am wondering if it's related to my application's view hierarchy. The examples I can find for using Searchable say to use it on the NavigationView directly, and show it like so:
var body: some View {
NavigationView {
List {
...some list content here...
}
.navigationTitle("My List")
}
.searchable(text: $queryString)
}
My NavigationView is a couple of views up from the list where I want to use .searchable. My hierarchy:
HomeView
(has the NavigationView) -> LocationsView
-> LocationListView
I want to use .searchable in the LocationListView, and I can - but it's not optimal. The Search bar is always visible, and it causes the navigation bar in my LocationDetailView
(the next view down the hierarchy) to "jump" down when the view loads, and crowd the rest of my view, with a gap at the top.
I theorize that this is because I'm using .searchable in the LocationListView, which is inside the NavigationView. If I comment out .searchable in the List view, the Detail view does not have this behavior.
I'm wondering if there is a good recommendation for how to deal with this. I know I can't use a second NavigationView in the ListView, because then it's nested inside the first navigation view and has all of the associated issues. (Although it does fix the .searchable implementation!) Is there another way to solve this?