InstantSearch provides the FilterToggleState as a state model,
which is an implementation of the FilterToggleView interface.
You need to connect FilterToggleState to the FilterToggleConnector or FilterToggleViewModel like any other FilterToggleView implementation.
Kotlin
import com.algolia.instantsearch.filter.Filterclass MyActivity : AppCompatActivity() { val searcher = HitsSearcher( applicationID = "YourApplicationID", apiKey = "YourSearchOnlyAPIKey", indexName = "YourIndexName" ) val filterState = FilterState() val attributeSize = "size" val filterSize = Filter.Numeric(attributeSize, NumericOperator.Greater, 40) val filterToggleState = FilterToggleState() val filterToggle = FilterToggleConnector(filterState, filterSize) val connections = ConnectionHandler(filterToggle) init { connections += searcher.connectFilterState(filterState) connections += filterToggle.connectView(filterToggleState) } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MyFilterToggle(filterToggleState) // your own UI composable to display filter toggle } searcher.searchAsync() } override fun onDestroy() { super.onDestroy() searcher.cancel() connections.disconnect() }}
When specified, the filter is grouped under this ID and composed with this operator.
Defaults to the used attribute, applying FilterOperator.And with any other filters of this group.
val view = FilterToggleViewCompoundButton(compoundButton) // with your own `CompoundButton` viewval presenter = object : FilterPresenter { // Implement the interface here}filterToggle.connectView(view, presenter)