Hello trying to add two custom search bars to the navigation bar and can not get the height of the navigation bar to fit the two search bars???
var body: some View {
NavigationView {
List(filteredBooksByAuthor) { book in
NavigationLink(destination: BookDetailView(bookDetail: book, shouldPopToRootView: self.$rootIsActive)) {
BookCard(bookObject: book)
}
.isDetailLink(false)
.listRowBackground(Color(red: 255 / 255, green: 221 / 255, blue: 249 / 255) .opacity(0))
} //end list
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
VStack {
HStack {
TextField("(Image(systemName: "magnifyingglass"))Enter book title", text: $searchTextTitle)
.font(.system(size: 22, weight: .light, design: .default))
.foregroundColor(Color.white)
.textFieldStyle(.plain)
.background(Color.gray.opacity(0.3))
.clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous))
.focused($keyboardFocused)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
keyboardFocused = true
}
}
.frame(minWidth: 300, maxWidth: .infinity)
Button(action: {
searchByTitleButtonHit = true
fetchLatestBooks()}) {
Image(systemName: "text.aligncenter")}
} //end Hstack
HStack {if searchByTitleButtonHit {
TextField("(Image(systemName: "magnifyingglass"))Enter book author", text: $searchTextAuthor)
.font(.system(size: 22, weight: .light, design: .default))
.textFieldStyle(.plain)
.foregroundColor(Color.white)
.background(Color.gray.opacity(0.3))
.focused($keyboardFocused)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
keyboardFocused = true
}
}
.clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous))}}// end hstack
} //end vstack
}//end toolbaritem
} //end toolbar
.scrollContentBackground(.hidden)
.toolbarBackground(skyPurple, for: .navigationBar, .tabBar)
.background(
Image("backImage")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
)
}
.navigationBarHidden(true)
.navigationBarTitleDisplayMode(.large)
.task { try? await fetchLatestBooks() }
} //end view