My code is currently seen below. I'm expecting the first tab to have the navigation title "Friends" and the second tab to have the navigation title "Filtered View". However, they both show the navigation title of "Friends" (https://i.stack.imgur.com/WZQ5S.png). I've also tried various alternatives and gotten things like two navigation titles being shown on the same screen (https://i.stack.imgur.com/zAnEs.png). How do I get the first tab to have the title of "Friends" and the second tab to have the title of "Filtered View"? Thank you very much!
struct ContentView: View {
@Binding var friends: [Friend]
var body: some View {
TabView {
DatabaseView(friends: $friends) {
Task {
do {
try await FriendStore.save(friends: friends)
} catch {
print("Try again later.")
}
}
}
.tabItem {
Label("Everyone", systemImage: "person.3")
}
FilteredView()
.tabItem {
Label("Filtered", systemImage: "checkmark.circle")
}
}
}
}
struct DatabaseView: View {
@Binding var friends: [Friend]
var body: some View {
List {
ForEach($friends) { $friend in
NavigationLink(destination: DetailView(friend: $friend)) {
CardView(friend: friend)
}
}
.navigationTitle("Friends")
.sheet(isPresented: $isPresentingNewDatabaseView) {
NavigationView {
DetailEditView(data: $newFriendData)
.toolbar {
...
}
struct FilteredView: View {
var body: some View {
NavigationView {
Text("Hello, World!")
}
.navigationTitle("Filtered View")
}
}