|
| 1 | +import React from 'react'; |
| 2 | +import {View} from 'react-native'; |
| 3 | +import useTheme from '@hooks/useTheme'; |
| 4 | +import useThemeStyles from '@hooks/useThemeStyles'; |
| 5 | +import variables from '@styles/variables'; |
| 6 | +import type IconAsset from '@src/types/utils/IconAsset'; |
| 7 | +import CaretWrapper from './CaretWrapper'; |
| 8 | +import Icon from './Icon'; |
| 9 | +import * as Expensicons from './Icon/Expensicons'; |
| 10 | +import {PressableWithFeedback} from './Pressable'; |
| 11 | +import Text from './Text'; |
| 12 | + |
| 13 | +type Props = { |
| 14 | + /** Function to call when the feed is selected */ |
| 15 | + onFeedSelect: () => void; |
| 16 | + |
| 17 | + /** Icon for the card */ |
| 18 | + cardIcon: IconAsset; |
| 19 | + |
| 20 | + /** Whether to show assign card button */ |
| 21 | + shouldChangeLayout?: boolean; |
| 22 | + |
| 23 | + /** Feed name */ |
| 24 | + feedName?: string; |
| 25 | + |
| 26 | + /** Supporting text */ |
| 27 | + supportingText?: string; |
| 28 | + |
| 29 | + /** Whether the RBR indicator should be shown */ |
| 30 | + shouldShowRBR?: boolean; |
| 31 | +}; |
| 32 | + |
| 33 | +function FeedSelector({onFeedSelect, cardIcon, shouldChangeLayout, feedName, supportingText, shouldShowRBR = false}: Props) { |
| 34 | + const styles = useThemeStyles(); |
| 35 | + const theme = useTheme(); |
| 36 | + |
| 37 | + return ( |
| 38 | + <PressableWithFeedback |
| 39 | + onPress={onFeedSelect} |
| 40 | + style={[styles.flexRow, styles.alignItemsCenter, styles.gap3, shouldChangeLayout && styles.mb3]} |
| 41 | + accessibilityLabel={feedName ?? ''} |
| 42 | + > |
| 43 | + <Icon |
| 44 | + src={cardIcon} |
| 45 | + height={variables.cardIconHeight} |
| 46 | + width={variables.cardIconWidth} |
| 47 | + additionalStyles={styles.cardIcon} |
| 48 | + /> |
| 49 | + <View style={styles.flex1}> |
| 50 | + <View style={[styles.flexRow, styles.gap1]}> |
| 51 | + <CaretWrapper style={styles.flex1}> |
| 52 | + <Text style={[styles.textStrong, styles.flexShrink1]}>{feedName}</Text> |
| 53 | + </CaretWrapper> |
| 54 | + {shouldShowRBR && ( |
| 55 | + <Icon |
| 56 | + src={Expensicons.DotIndicator} |
| 57 | + fill={theme.danger} |
| 58 | + /> |
| 59 | + )} |
| 60 | + </View> |
| 61 | + <Text style={styles.textLabelSupporting}>{supportingText}</Text> |
| 62 | + </View> |
| 63 | + </PressableWithFeedback> |
| 64 | + ); |
| 65 | +} |
| 66 | + |
| 67 | +export default FeedSelector; |
0 commit comments