import React from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; import Badge from '../Badge'; import type { IconName } from '../Icon'; import Icon from '../Icon'; import { StyledBadge, StyledFilterWrapper, StyledText, } from './StyledFilterTrigger'; export interface FilterTriggerProps { /** * The label of the FilterTrigger. */ label?: string; /** * Whether the filter is currently active */ active?: boolean; /** * The number of active filters */ filterCount?: number; /** * The testID of the FilterTrigger. */ testID?: string; /** * The style of the FilterTrigger. */ style?: StyleProp; /** * The onPress callback */ onPress?: () => void; /** * The variant of the FilterTrigger. */ variant?: 'filled' | 'outlined' | 'ghost'; /** * The suffix of the FilterTrigger. */ suffix?: IconName; } const FilterTrigger = ({ label, active = false, filterCount = 0, variant = 'filled', suffix, onPress, testID, style, }: FilterTriggerProps) => { const shouldShowBadge = filterCount > 0 && active; return ( {label ? ( <> {suffix && ( )} {label} {shouldShowBadge && ( )} ) : ( <> {suffix && ( )} {shouldShowBadge && ( )} )} ); }; export default FilterTrigger;