diff --git a/src/components/SelectionList/BaseListItem.tsx b/src/components/SelectionList/BaseListItem.tsx index 5f43f8088fc3..b95865b37d02 100644 --- a/src/components/SelectionList/BaseListItem.tsx +++ b/src/components/SelectionList/BaseListItem.tsx @@ -4,13 +4,11 @@ import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; -import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useHover from '@hooks/useHover'; import {useMouseContext} from '@hooks/useMouseContext'; import useSyncFocus from '@hooks/useSyncFocus'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import variables from '@styles/variables'; import CONST from '@src/CONST'; import type {BaseListItemProps, ListItem} from './types'; @@ -18,6 +16,7 @@ function BaseListItem({ item, pressableStyle, wrapperStyle, + pressableWrapperStyle, containerStyle, isDisabled = false, shouldPreventEnterKeySubmit = false, @@ -36,7 +35,6 @@ function BaseListItem({ onFocus = () => {}, hoverStyle, onLongPressRow, - hasAnimateInHighlightStyle = false, }: BaseListItemProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -64,13 +62,6 @@ function BaseListItem({ return rightHandSideComponent; }; - const animatedHighlightStyle = useAnimatedHighlightStyle({ - borderRadius: variables.componentBorderRadius, - shouldHighlight: item?.shouldAnimateInHighlight ?? false, - highlightColor: theme.messageHighlightBG, - backgroundColor: theme.highlightBG, - }); - return ( onDismissError(item)} @@ -109,7 +100,7 @@ function BaseListItem({ onFocus={onFocus} onMouseLeave={handleMouseLeave} tabIndex={item.tabIndex} - wrapperStyle={hasAnimateInHighlightStyle ? [styles.mh5, animatedHighlightStyle] : []} + wrapperStyle={pressableWrapperStyle} > {typeof children === 'function' ? children(hovered) : children} diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index ea36ba44ccca..9b6cf6045b17 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -5,11 +5,14 @@ import BaseListItem from '@components/SelectionList/BaseListItem'; import type {ListItem, ReportListItemProps, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types'; import Text from '@components/Text'; import TextWithTooltip from '@components/TextWithTooltip'; +import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useStyleUtils from '@hooks/useStyleUtils'; +import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; +import variables from '@styles/variables'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import ActionCell from './ActionCell'; @@ -62,10 +65,18 @@ function ReportListItem({ }: ReportListItemProps) { const reportItem = item as unknown as ReportListItemType; + const theme = useTheme(); const styles = useThemeStyles(); const {isLargeScreenWidth} = useResponsiveLayout(); const StyleUtils = useStyleUtils(); + const animatedHighlightStyle = useAnimatedHighlightStyle({ + borderRadius: variables.componentBorderRadius, + shouldHighlight: item?.shouldAnimateInHighlight ?? false, + highlightColor: theme.messageHighlightBG, + backgroundColor: theme.highlightBG, + }); + if (reportItem.transactions.length === 0) { return; } @@ -143,7 +154,7 @@ function ReportListItem({ onFocus={onFocus} shouldSyncFocus={shouldSyncFocus} hoverStyle={item.isSelected && styles.activeComponentBG} - hasAnimateInHighlightStyle + pressableWrapperStyle={[styles.mh5, animatedHighlightStyle]} > {!isLargeScreenWidth && ( diff --git a/src/components/SelectionList/Search/TransactionListItem.tsx b/src/components/SelectionList/Search/TransactionListItem.tsx index 39172711516e..a9bbdf1d1a65 100644 --- a/src/components/SelectionList/Search/TransactionListItem.tsx +++ b/src/components/SelectionList/Search/TransactionListItem.tsx @@ -1,8 +1,11 @@ import React from 'react'; import BaseListItem from '@components/SelectionList/BaseListItem'; import type {ListItem, TransactionListItemProps, TransactionListItemType} from '@components/SelectionList/types'; +import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import variables from '@styles/variables'; import TransactionListItemRow from './TransactionListItemRow'; function TransactionListItem({ @@ -20,6 +23,7 @@ function TransactionListItem({ }: TransactionListItemProps) { const transactionItem = item as unknown as TransactionListItemType; const styles = useThemeStyles(); + const theme = useTheme(); const {isLargeScreenWidth} = useResponsiveLayout(); @@ -40,6 +44,13 @@ function TransactionListItem({ isLargeScreenWidth ? {...styles.flexRow, ...styles.justifyContentBetween, ...styles.alignItemsCenter} : {...styles.flexColumn, ...styles.alignItemsStretch}, ]; + const animatedHighlightStyle = useAnimatedHighlightStyle({ + borderRadius: variables.componentBorderRadius, + shouldHighlight: item?.shouldAnimateInHighlight ?? false, + highlightColor: theme.messageHighlightBG, + backgroundColor: theme.highlightBG, + }); + return ( ({ onLongPressRow={onLongPressRow} shouldSyncFocus={shouldSyncFocus} hoverStyle={item.isSelected && styles.activeComponentBG} - hasAnimateInHighlightStyle + pressableWrapperStyle={[styles.mh5, animatedHighlightStyle]} > = { /** Styles for the pressable component */ pressableStyle?: StyleProp; + /** Styles for the pressable component wrapper view */ + pressableWrapperStyle?: StyleProp>; + /** Styles for the wrapper view */ wrapperStyle?: StyleProp; @@ -291,7 +295,6 @@ type BaseListItemProps = CommonListItemProps & { children?: ReactElement> | ((hovered: boolean) => ReactElement>); shouldSyncFocus?: boolean; hoverStyle?: StyleProp; - hasAnimateInHighlightStyle?: boolean; /** Errors that this user may contain */ shouldDisplayRBR?: boolean; };