// @flow import * as React from 'react'; import {Card, Chip, List, Text} from 'react-native-paper'; import {StyleSheet, View} from 'react-native'; import i18n from 'i18n-js'; import AnimatedAccordion from '../../Animations/AnimatedAccordion'; import {isItemInCategoryFilter} from '../../../utils/Search'; import type {ClubCategoryType} from '../../../screens/Amicale/Clubs/ClubListScreen'; import type {ListIconPropsType} from '../../../constants/PaperStyles'; type PropsType = { categories: Array, onChipSelect: (id: number) => void, selectedCategories: Array, }; const styles = StyleSheet.create({ card: { margin: 5, }, text: { paddingLeft: 0, marginTop: 5, marginBottom: 10, marginLeft: 'auto', marginRight: 'auto', }, chipContainer: { justifyContent: 'space-around', flexDirection: 'row', flexWrap: 'wrap', paddingLeft: 0, marginBottom: 5, }, }); class ClubListHeader extends React.Component { shouldComponentUpdate(nextProps: PropsType): boolean { const {props} = this; return ( nextProps.selectedCategories.length !== props.selectedCategories.length ); } getChipRender = (category: ClubCategoryType, key: string): React.Node => { const {props} = this; const onPress = (): void => props.onChipSelect(category.id); return ( {category.name} ); }; getCategoriesRender(): React.Node { const {props} = this; const final = []; props.categories.forEach((cat: ClubCategoryType) => { final.push(this.getChipRender(cat, cat.id.toString())); }); return final; } render(): React.Node { return ( ( )} opened> {i18n.t('screens.clubs.categoriesFilterMessage')} {this.getCategoriesRender()} ); } } export default ClubListHeader;