Reputation: 331
I have in my code a Form which contains multiple conditional sections.
I want the form to be searchable ONLY if one section is included.
if myCondition {
Section {
Text("My Section Contents")
} header: {
Text("My Section Header")
}.searchable(text: $filterText, placement: .navigationBarBrawer(displaymode: .always))
}
This however seems to break the header which renders normally without the searchable.
Any ideas? Is there another way to conditionally include the search bar?
Thanks in advance.
Upvotes: 0
Views: 122
Reputation: 12125
if canSearch {
Section {
Text("Now you can search")
.searchable(text: $filterText, placement: .navigationBarDrawer(displayMode: .always))
} header: {
Text("Search")
}
}
Upvotes: 1