Methods
# setActiveSubFilters(activeSubFilters)
You can use this hook to set the active sub filters in the list screens.
Parameters:
Name | Type | Description |
---|---|---|
activeSubFilters |
ActiveSubFiltersProps |
Example
externalCodeSetup.filterScreenApiHooks.setActiveSubFilters((defaultSubFilters) => {
const groupSubFilters = {
type: "active",
group_type: "company"
};
return groupSubFilters;
});
# setAfterFilterComponent(AfterFilterComponent)
It is used to add a component after the filter row component. For example, you can add a component below the filter row.
Parameters:
Name | Type | Description |
---|---|---|
AfterFilterComponent |
React.ComponentType.<AfterFilterComponent> |
Example
...
import FastImage from "react-native-fast-image";
import {CommonActions} from "@react-navigation/native";
export const applyCustomCode = externalCodeSetup => {
const CustomAfterFilterComponent = (props) => {
const navigateToCourse = () => {
const courseId = 162;
setTimeout(() => {
props.navigation.dispatch(
CommonActions.navigate({
name: "CoursesSingleScreen",
params: {
id: courseId
},
key: courseId.toString()
})
);
}, 0);
};
return (
<>
<TouchableWithoutFeedback onPress={navigateToCourse}>
<FastImage
style={{ width: "auto", height: 200 }}
source={{
uri: 'https://link-to-image.png',
}}
/>
</TouchableWithoutFeedback>
<Text>Tap the image above to find out our recommended course for you!</Text>
</>)
}
externalCodeSetup.filterScreenApiHooks.setAfterFilterComponent(CustomAfterFilterComponent)
}
# setBeforeFilterComponent(BeforeFilterComponent)
It is used to add a component before the filter row component. For example, you can place a component above the filter row.
Parameters:
Name | Type | Description |
---|---|---|
BeforeFilterComponent |
React.ComponentType.<BeforeFilterComponent> |
Example
...
import FastImage from "react-native-fast-image";
import {CommonActions} from "@react-navigation/native";
export const applyCustomCode = externalCodeSetup => {
const CustomBeforeFilterComponent = (props) => {
const navigateToCourse = () => {
const courseId = 162;
setTimeout(() => {
props.navigation.dispatch(
CommonActions.navigate({
name: "CoursesSingleScreen",
params: {
id: courseId
},
key: courseId.toString()
})
);
}, 0);
};
return (
<>
<TouchableWithoutFeedback onPress={navigateToCourse}>
<FastImage
style={{ width: "auto", height: 200 }}
source={{
uri: 'https://link-to-image.png',
}}
/>
</TouchableWithoutFeedback>
<Text>Tap the image above to find out our recommended course for you!</Text>
</>)
}
externalCodeSetup.filterScreenApiHooks.setBeforeFilterComponent(CustomBeforeFilterComponent)
}
# setFilterAllButtonHidden(filterAllHidden)
You can use this hook to hide the 'Filter All' button on screens such as courses, groups, or members screen.
Parameters:
Name | Type | Description |
---|---|---|
filterAllHidden |
FilterAllButtonHiddenCallback |
Example
...
export const applyCustomCode = externalCodeSetup => {
externalCodeSetup.filterScreenApiHooks.setFilterAllButtonHidden(filterType => {
if (filterType === "courses"){
return false;
}
return true;
});
}
# setFilterComponent(FilterComponentnullable)
You can use it to replace the default filter row component with your custom filter component.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
FilterComponent |
React.ComponentType.<FilterComponent> |
<nullable> |
Example
//In custom_code/components/FilterRow.js
import React, {useState} from 'react';
import { useSelector } from 'react-redux';
import FilterListHeaderInner from "@src/components/Filter/FilterListHeader"; //Use BuddyBoss component for generating filter row
const FilterRow = (props) => {
const courseCount = useSelector((state) => state.courses.all.count); //Get courses count from redux
const {
details,
filter,
initialTab,
filters,
subfilters,
activeSubFilters,
global,
colors,
t,
labels,
filterType } = props;
const [activeFilter, setActiveFilter] = useState(initialTab || filters[0]);
//Pass all props required by FilterListHeaderInner
return <FilterListHeaderInner
{...{
showFilterArrow: true,
details,
disableFilter: false,
disableSubFilters: false,
count: filterType === "courses" ? courseCount : undefined,
filter: activeFilter,
subfilters,
activeSubFilters,
global,
colors,
t,
labels,
filterType,
containerStyle: {
backgroundColor: colors.bodyFrontBg
}
}}
/>
}
export default FilterRow;
//In custom_code/index.js
...
import FilterRow from "./components/FilterRow";
export const applyCustomCode = externalCodeSetup => {
externalCodeSetup.filterScreenApiHooks.setFilterComponent(props => {
return <FilterRow {...props} />
})
}
# setFilterItemComponent(FilterItemComponentnullable)
It can set a custom Filter Item (from the filters list) Component.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
FilterItemComponent |
React.ComponentType.<FilterItemComponentProps> |
<nullable> |
Example
...
externalCodeSetup.filterScreenApiHooks.setFilterItemComponent(props => {
const {style, global, icon, text, isSelected, index, onPress } = props;
return <TouchableOpacity
style={styles.container}
onPress={onPress}
>
<View style={styles.inner}>
<View style={styles.labelContainer}>
{!!icon && <Icon styles={styles.icon} icon={icon} tintColor="black"/>}
<Text
style={styles.label}
>
{text}
</Text>
</View>
{isSelected && (
<Icon
tintColor={global.link.color}
icon={{fontIconName: "check", weight: 300}}
styles={{height: 22, width: 22}}
/>
)}
</View>
</TouchableOpacity>
});