Signature
About this widget
DynamicFacetList
is a view that displays the ordered list of facets and facet values.
The order of groups and facet values in each group is defined by the corresponding index settings and applied index rules.
You can configure the facet merchandising through the corresponding index setting.
To learn more, see Facet display.
Requirements
You must set the attributes for faceting and configure the facet order, either using the dashboard or with the API parametersattributesForFaceting
and renderingContent
.
You must also set the facets
property of the query with Searcher.request.query.facets
and provide the facet attributes you want to retrieve.
You must use InstantSearch iOS v7.12.0 or later to use Dynamic Facet List.
Examples
Instantiate aDynamicFacetListConnector
, set the query facets and launch an initial search on its searcher.
Swift
Parameters
The
FilterState
that holds your filters.The ordered list of attributed facets.
The mapping between a facet attribute and a set of selected facet values.
The mapping between a facet attribute and a facet values selection mode. If not provided, the default selection mode is
.single
.The mapping between a facet attribute and a descriptor of a filter group where the corresponding facet filters are stored in the filter state.
DynamicFacetListController
implementation to connect.Low-level API
If you want to fully control theDynamicFacetList
components and connect them manually, you can use the following components:
Searcher
: theSearcher
that handles your searches.FilterState
: the current state of the filters.DynamicFacetListInteractor
: dynamic facet list business logicDynamicFacetListController
: controller presenting the ordered list of facets and handling the user interaction
Swift
Customizing your view
UIKit
InstantSearch iOS provides theDynamicFacetListTableViewController
, which is the UITableViewController
subclass that implements the DynamicFacetListController
protocol.
If you want to use another component, such as a UICollectionView
or a third-party view, or if you want to introduce some custom behavior to the already provided UIKit component, you can create your own controller conforming to the DynamicFacetListController
protocol.
Protocol
func setOrderedFacets(_ orderedFacets: [AttributedFacets])
Update the list of the ordered attributed facets
func setSelections(_ selections: [Attribute: Set<String>])
Update the facet selections
var didSelect: ((Attribute, Facet) -> Void)?
Closure to trigger when user selects a facet
SwiftUI
InstantSearch iOS provides theDynamicFacetListObservableController
, an implementation of the DynamicFacetListController
protocol adapted for usage with SwiftUI.
It provides orderedFacets
and selections
properties with convenient toggle
and isSelected
functions which let you implement your own SwiftUI view.
Implementation example
Swift