I’m writing a fairly simple SwiftUI app about movies and I have this issue where the new .searchable
modifier on NavigationView
is always being shown, whereas it should be hidden, unless you pull down on the List
.
It hides it correctly if I scroll a bit up, and if I scroll down it also hides it correctly, but other than that, it’s always being shown. See gif for clarification. (basically it should behave the same as in Messages app)
My code for using the searchable is fairly simple:
var body: some View { NavigationView { List { ForEach(/*** movie stuff ***/) { movie in ///// row here } } .listStyle(GroupedListStyle()) .onAppear { // load movies } .navigationTitle("Discover") .searchable(text: $moviesRepository.searchText, placement: .toolbar, prompt: "Search...") } } }
2
Answers
So, after adding a progress view above the list view, it suddenly started working the way I want it to. The code now is minimally changed and looks like this.
And basically after adding the progress views, it started working the way I described it in my OP and the way it worked for ChrisR
You can set the displayMode to ".automatic" and it will hidden by default.
SearchFieldPlacement.NavigationBarDrawerDisplayMode