1 min read
Customisations
Add custom data to Listing
To add custom data to the Listing model you need to:
- Receive your custom data in the network model
NetworkListing. - Create a new implementation of
Mapper<Any, Map<String, Any>>. - Provide your new mapper via Koin using the name
productListingCustomMapToAnyMapperName.
Add custom data to Filter
To add extra data to a specific Filter type model:
- Receive your custom data in the network model
NetworkFilter. - Create a new implementation of
Mapper<Any, Map<String, Any>>. - Provide your new mapper via Koin for the specific Filter type using the appropriate name:
- Filter price:
customDataFilterPriceMapperName - Filter toggle:
customDataFilterToggleMapperName - Filter multi selection:
customDataFilterMultiSelectionMapperName
- Filter price:
Add custom Filter type
To add extra data Filter types to your filter screen:
- Receive your custom type in the network model
NetworkFilter. - Provide a new implementation of
Mapper<Filter.Custom?, NetworkFilter?>. - Provide your new mapper via Koin using the name
networkToDomainFilterCustomMapperName. - Provide a new implementation of
DomainToUiFilterCustomMapperif you support more than 1 new custom Filter type. - Provide a new implementation of
UiFilterCustomViewHolderFactorywhere you can create as many view holders as custom Filter types you support.
Custom SearchType
Adding a custom SearchType allows you to send different information to your backend from the one that the SDK does.
To add a custom SearchType:
- Define a new model
CustomSearchTypethat represents your extra fields. - Provide a new implementation of
Mapper<Map<String, String>, SearchType.Custom>returning a map with the query paramenters that your new SearchType requires. - Provide your new mapper via Koin using the name
domainToNetworkSearchTypeCustomMapperNamefactory<Mapper<Map<String, String>, SearchType.Custom>>(named(domainToNetworkSearchTypeCustomMapperName), override = true) {CustomSearchTypeMapper()} - Call
ProductListViewModel.loadProductListwith your new SearchType