I have a NaviagtionView with a TabView and 4 TabItems inside. One of the TabItems should display a searchbar. I can make the NavigationView .searchable but I only want that inside the on TabItem where I want to do the search. How can i do that? Here is my code:
var body: some View {
NavigationView {
TabView{
HomeScreen()
.background(Color("BackgroundColor"))
.tabItem{
Image(systemName: "house")
}
PostScreen()
.background(Color("BackgroundColor"))
.tabItem{
Image(systemName: "plus")
}
SearchScreen()
.background(Color("BackgroundColor"))
.tabItem{
Image(systemName: "magnifyingglass")
}
ProfileScreen()
.background(Color("BackgroundColor"))
.tabItem{
Image(systemName: "person")
}
}
.navigationTitle("MyApp")
.navigationBarTitleDisplayMode(.inline)
.searchable(text: $text)
}
}