Trying to display two custom search bars under each other in the top navigation bar using SwiftUI and I can only get one to work in top navigation bar and one in bottom bar.
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
HStack {
TextField("🔍 Enter book title", text: $searchTextTitle)
.font(.system(size: 22, weight: .light, design: .default))
.textFieldStyle(.plain)
.background(Color.gray.opacity(0.2))
.clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous))
Button(action: {
fetchLatestBooks()
}) {
Image(systemName: "line.3.horizontal.decrease")
}
}
.frame(width: 350, height: 26)
} //end toolbaritem
} //end toolbar
.toolbar {
ToolbarItem(placement: .bottomBar) {
HStack {
TextField("🔍 Enter book author", text: $searchTextAuthor)
.font(.system(size: 22, weight: .light, design: .default))
.textFieldStyle(.plain)
.background(Color.gray.opacity(0.2))
.clipShape(RoundedRectangle(cornerRadius: 5, style: .continuous))
}
.frame(width: 350, height: 26)
}//end toolbaritem
} //end toolbar
Using .navigationBarLeading for both places them side by side