1- import React , { useCallback , useMemo , useRef } from 'react' ;
1+ import React , { useMemo } from 'react' ;
22import { View } from 'react-native' ;
33import type { ValueOf } from 'type-fest' ;
4- import { getButtonRole } from '@components/Button/utils' ;
5- import OfflineWithFeedback from '@components/OfflineWithFeedback' ;
6- import { PressableWithFeedback } from '@components/Pressable' ;
74import type { SearchGroupBy } from '@components/Search/types' ;
5+ import BaseListItem from '@components/SelectionList/BaseListItem' ;
86import type {
97 ListItem ,
108 TransactionCardGroupListItemType ,
@@ -17,11 +15,8 @@ import type {
1715import Text from '@components/Text' ;
1816import TransactionItemRow from '@components/TransactionItemRow' ;
1917import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle' ;
20- import useHover from '@hooks/useHover' ;
2118import useLocalize from '@hooks/useLocalize' ;
2219import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
23- import useStyleUtils from '@hooks/useStyleUtils' ;
24- import useSyncFocus from '@hooks/useSyncFocus' ;
2520import useTheme from '@hooks/useTheme' ;
2621import useThemeStyles from '@hooks/useThemeStyles' ;
2722import { getReportIDForTransaction } from '@libs/MoneyRequestReportUtils' ;
@@ -76,7 +71,16 @@ function TransactionGroupListItem<TItem extends ListItem>({
7671 backgroundColor : theme . highlightBG ,
7772 } ) ;
7873
79- const pressableStyle = [ styles . transactionGroupListItemStyle , item . isSelected && styles . activeComponentBG ] ;
74+ const listItemPressableStyle = [
75+ styles . selectionListPressableItemWrapper ,
76+ styles . pv2 ,
77+ styles . ph0 ,
78+ styles . overflowHidden ,
79+ // Removing background style because they are added to the parent OpacityView via animatedHighlightStyle
80+ styles . bgTransparent ,
81+ item . isSelected && styles . activeComponentBG ,
82+ styles . mh0 ,
83+ ] ;
8084
8185 const openReportInRHP = ( transactionItem : TransactionListItemType ) => {
8286 const backTo = Navigation . getActiveRoute ( ) ;
@@ -108,7 +112,7 @@ function TransactionGroupListItem<TItem extends ListItem>({
108112 COLUMNS . ACTION ,
109113 ] satisfies Array < ValueOf < typeof COLUMNS > > ;
110114
111- const getHeader = useMemo ( ( ) => {
115+ const getHeader = ( isHovered : boolean ) => {
112116 const headers : Record < SearchGroupBy , React . JSX . Element > = {
113117 [ CONST . SEARCH . GROUP_BY . REPORTS ] : (
114118 < ReportListItemHeader
@@ -117,6 +121,7 @@ function TransactionGroupListItem<TItem extends ListItem>({
117121 onSelectRow = { onSelectRow }
118122 onCheckboxPress = { onCheckboxPress }
119123 isDisabled = { isDisabledOrEmpty }
124+ isHovered = { isHovered }
120125 isFocused = { isFocused }
121126 canSelectMultiple = { canSelectMultiple }
122127 />
@@ -134,6 +139,7 @@ function TransactionGroupListItem<TItem extends ListItem>({
134139 card = { groupItem as TransactionCardGroupListItemType }
135140 onCheckboxPress = { onCheckboxPress }
136141 isDisabled = { isDisabledOrEmpty }
142+ isHovered = { isHovered }
137143 isFocused = { isFocused }
138144 canSelectMultiple = { canSelectMultiple }
139145 />
@@ -145,46 +151,31 @@ function TransactionGroupListItem<TItem extends ListItem>({
145151 }
146152
147153 return headers [ groupBy ] ;
148- } , [ groupItem , policy , onSelectRow , onCheckboxPress , isDisabledOrEmpty , isFocused , canSelectMultiple , groupBy ] ) ;
149-
150- const StyleUtils = useStyleUtils ( ) ;
151- const { hovered, bind} = useHover ( ) ;
152- const pressableRef = useRef < View > ( null ) ;
153-
154- const onPress = useCallback ( ( ) => {
155- onSelectRow ( item ) ;
156- } , [ item , onSelectRow ] ) ;
157-
158- const onLongPress = useCallback ( ( ) => {
159- onLongPressRow ?.( item ) ;
160- } , [ item , onLongPressRow ] ) ;
161-
162- useSyncFocus ( pressableRef , ! ! isFocused , shouldSyncFocus ) ;
154+ } ;
163155
164156 return (
165- < OfflineWithFeedback pendingAction = { item . pendingAction } >
166- < PressableWithFeedback
167- onMouseEnter = { bind . onMouseEnter }
168- onMouseLeave = { bind . onMouseLeave }
169- ref = { pressableRef }
170- onLongPress = { onLongPress }
171- onPress = { onPress }
172- disabled = { isDisabled && ! item . isSelected }
173- accessibilityLabel = { item . text ?? '' }
174- role = { getButtonRole ( true ) }
175- isNested
176- hoverStyle = { [ ! item . isDisabled && styles . hoveredComponentBG , item . isSelected && styles . activeComponentBG ] }
177- dataSet = { { [ CONST . SELECTION_SCRAPER_HIDDEN_ELEMENT ] : true , [ CONST . INNER_BOX_SHADOW_ELEMENT ] : false } }
178- id = { item . keyForList ?? '' }
179- style = { [
180- pressableStyle ,
181- isFocused && StyleUtils . getItemBackgroundColorStyle ( ! ! item . isSelected , ! ! isFocused , ! ! item . isDisabled , theme . activeComponentBG , theme . hoverComponentBG ) ,
182- ] }
183- onFocus = { onFocus }
184- wrapperStyle = { [ styles . mb2 , styles . mh5 , animatedHighlightStyle , styles . userSelectNone ] }
185- >
186- < View style = { styles . flex1 } >
187- { getHeader }
157+ < BaseListItem
158+ item = { item }
159+ pressableStyle = { listItemPressableStyle }
160+ wrapperStyle = { [ styles . flexRow , styles . flex1 , styles . justifyContentBetween , styles . userSelectNone , styles . alignItemsCenter ] }
161+ containerStyle = { [ styles . mb2 ] }
162+ isFocused = { isFocused }
163+ isDisabled = { isDisabled }
164+ showTooltip = { showTooltip }
165+ canSelectMultiple = { canSelectMultiple }
166+ onSelectRow = { onSelectRow }
167+ onLongPressRow = { onLongPressRow }
168+ pendingAction = { item . pendingAction }
169+ keyForList = { item . keyForList }
170+ onFocus = { onFocus }
171+ shouldShowBlueBorderOnFocus
172+ shouldSyncFocus = { shouldSyncFocus }
173+ hoverStyle = { item . isSelected && styles . activeComponentBG }
174+ pressableWrapperStyle = { [ styles . mh5 , animatedHighlightStyle ] }
175+ >
176+ { ( hovered ) => (
177+ < View style = { [ styles . flex1 ] } >
178+ { getHeader ( hovered ) }
188179 { isEmpty ? (
189180 < View style = { [ styles . alignItemsCenter , styles . justifyContentCenter , styles . mnh13 ] } >
190181 < Text
@@ -196,31 +187,32 @@ function TransactionGroupListItem<TItem extends ListItem>({
196187 </ View >
197188 ) : (
198189 groupItem . transactions . map ( ( transaction ) => (
199- < TransactionItemRow
200- key = { transaction . transactionID }
201- transactionItem = { transaction }
202- isSelected = { ! ! transaction . isSelected }
203- dateColumnSize = { dateColumnSize }
204- amountColumnSize = { amountColumnSize }
205- taxAmountColumnSize = { taxAmountColumnSize }
206- shouldShowTooltip = { showTooltip }
207- shouldUseNarrowLayout = { ! isLargeScreenWidth }
208- shouldShowCheckbox = { ! ! canSelectMultiple }
209- onCheckboxPress = { ( ) => onCheckboxPress ?.( transaction as unknown as TItem ) }
210- columns = { columns }
211- onButtonPress = { ( ) => {
212- openReportInRHP ( transaction ) ;
213- } }
214- isParentHovered = { hovered }
215- columnWrapperStyles = { [ styles . ph3 , styles . pv1Half ] }
216- isReportItemChild
217- isInSingleTransactionReport = { groupItem . transactions . length === 1 }
218- />
190+ < View key = { transaction . transactionID } >
191+ < TransactionItemRow
192+ transactionItem = { transaction }
193+ isSelected = { ! ! transaction . isSelected }
194+ dateColumnSize = { dateColumnSize }
195+ amountColumnSize = { amountColumnSize }
196+ taxAmountColumnSize = { taxAmountColumnSize }
197+ shouldShowTooltip = { showTooltip }
198+ shouldUseNarrowLayout = { ! isLargeScreenWidth }
199+ shouldShowCheckbox = { ! ! canSelectMultiple }
200+ onCheckboxPress = { ( ) => onCheckboxPress ?.( transaction as unknown as TItem ) }
201+ columns = { columns }
202+ onButtonPress = { ( ) => {
203+ openReportInRHP ( transaction ) ;
204+ } }
205+ isParentHovered = { hovered }
206+ columnWrapperStyles = { [ styles . ph3 , styles . pv1Half ] }
207+ isReportItemChild
208+ isInSingleTransactionReport = { groupItem . transactions . length === 1 }
209+ />
210+ </ View >
219211 ) )
220212 ) }
221213 </ View >
222- </ PressableWithFeedback >
223- </ OfflineWithFeedback >
214+ ) }
215+ </ BaseListItem >
224216 ) ;
225217}
226218
0 commit comments