You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed Algolia's SwiftUI instructions in creating the ContentView.swift file below. What is the recommended way to set automaticallyShowsCancelButton to False?
import SwiftUI
import InstantSearchSwiftUI
import InstantSearchCore
struct StockItem: Codable {
let business: String
}
class AlgoliaController {
let searcher: HitsSearcher
let searchBoxInteractor: SearchBoxInteractor
let searchBoxController: SearchBoxObservableController
let hitsInteractor: HitsInteractor<StockItem>
let hitsController: HitsObservableController<StockItem>
init() {
self.searcher = HitsSearcher(appID: "adfadfadfadf",
apiKey: "23232323",
indexName: "adfadfadf")
self.searchBoxInteractor = .init()
self.searchBoxController = .init()
self.hitsInteractor = .init()
self.hitsController = .init()
self.searchBoxInteractor.automaticallyShowsCancelButton = false
setupConnections()
}
func setupConnections() {
searchBoxInteractor.connectSearcher(searcher)
searchBoxInteractor.connectController(searchBoxController)
hitsInteractor.connectSearcher(searcher)
hitsInteractor.connectController(hitsController)
}
}
struct ContentView: View {
@ObservedObject var searchBoxController: SearchBoxObservableController
@ObservedObject var hitsController: HitsObservableController<StockItem>
@State private var isEditing = false
var body: some View {
VStack(spacing: 7) {
SearchBar(text: $searchBoxController.query,
isEditing: $isEditing,
onSubmit: searchBoxController.submit)
HitsList(hitsController) { (hit, _) in
VStack(alignment: .leading, spacing: 10) {
Text(hit?.business ?? "")
.padding(.all, 10)
Divider()
}
} noResults: {
Text("No Results")
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
.navigationBarTitle("Algolia & SwiftUI")
}
}
struct ContentView_Previews: PreviewProvider {
static let algoliaController = AlgoliaController()
static var previews: some View {
NavigationView {
ContentView(searchBoxController: algoliaController.searchBoxController,
hitsController: algoliaController.hitsController)
}.onAppear {
algoliaController.searcher.search()
}
}
}
The text was updated successfully, but these errors were encountered:
After going through your code seems like there is no way with searchbar . You can use the textfield object and set searchboxcontroller to it. I do have an issue - how can i fetch all the filters for a particular searched word ?
I followed Algolia's SwiftUI instructions in creating the ContentView.swift file below. What is the recommended way to set
automaticallyShowsCancelButton
toFalse
?The text was updated successfully, but these errors were encountered: