1+ import AvatarNamesTooltip from '@components/Avatar/tooltips/AvatarNamesTooltip' ;
2+ import AvatarTooltip from '@components/Avatar/tooltips/AvatarTooltip' ;
13import Text from '@components/Text' ;
2- import Tooltip from '@components/Tooltip' ;
3- import UserDetailsTooltip from '@components/UserDetailsTooltip' ;
44
5- import useLocalize from '@hooks/useLocalize' ;
65import useStyleUtils from '@hooks/useStyleUtils' ;
76import useTheme from '@hooks/useTheme' ;
87import useThemeStyles from '@hooks/useThemeStyles' ;
98
10- import { getUserDetailTooltipText } from '@libs/ReportUtils' ;
11-
129import CONST from '@src/CONST' ;
1310
1411import type { StyleProp , ViewStyle } from 'react-native' ;
@@ -33,17 +30,14 @@ type DiagonalAvatarsProps = MultipleAvatarsProps & {
3330/** `DiagonalAvatars` renders two avatars stacked diagonally — the primary in the top-left and the secondary in the bottom-right.
3431 * When more than two `icons` are passed, the secondary slot shows a "+N" overflow count instead of the second avatar.
3532 */
36- function DiagonalAvatars ( { size, shouldShowTooltip , icons, isInReportAction, secondaryAvatarContainerStyle, isHovered = false , fallbackDisplayName} : DiagonalAvatarsProps ) {
33+ function DiagonalAvatars ( { size, icons, isInReportAction, secondaryAvatarContainerStyle, isHovered = false , fallbackDisplayName} : DiagonalAvatarsProps ) {
3734 const theme = useTheme ( ) ;
3835 const styles = useThemeStyles ( ) ;
3936 const StyleUtils = useStyleUtils ( ) ;
40- const { formatPhoneNumber, translate} = useLocalize ( ) ;
4137
4238 const primaryIcon = icons . at ( 0 ) ;
4339 const secondaryIcon = icons . at ( 1 ) ;
4440
45- const tooltipTexts = shouldShowTooltip ? icons . map ( ( icon ) => getUserDetailTooltipText ( Number ( icon . id ) , formatPhoneNumber , translate , icon . name ) ) : [ '' ] ;
46-
4741 const { avatarSize, singleAvatarStyleKey} = getDiagonalAvatarSizing ( size ) ;
4842 const secondaryAvatarContainerStyles = secondaryAvatarContainerStyle ?? [ StyleUtils . getBackgroundAndBorderStyle ( isHovered ? theme . activeComponentBG : theme . componentBG ) ] ;
4943
@@ -55,61 +49,43 @@ function DiagonalAvatars({size, shouldShowTooltip, icons, isInReportAction, seco
5549 primaryContainerStyle = { primaryIcon ?. type === CONST . ICON_TYPE_WORKSPACE && StyleUtils . getAvatarBorderRadius ( size , primaryIcon . type ) }
5650 secondaryContainerStyle = { [ secondaryAvatarContainerStyles , secondaryIcon ?. type === CONST . ICON_TYPE_WORKSPACE && StyleUtils . getAvatarBorderRadius ( size , secondaryIcon . type ) ] }
5751 primary = {
58- < UserDetailsTooltip
59- accountID = { Number ( primaryIcon ?. id ) }
60- icon = { primaryIcon }
61- fallbackUserDetails = { {
62- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
63- displayName : fallbackDisplayName || primaryIcon ?. name ,
64- } }
65- shouldRender = { shouldShowTooltip }
52+ < AvatarTooltip
53+ avatar = { primaryIcon }
54+ fallbackDisplayName = { fallbackDisplayName }
6655 >
67- { /* View is necessary for tooltip to show for multiple avatars in LHN */ }
68- < View >
69- < Avatar
70- type = { primaryIcon ?. type ?? CONST . ICON_TYPE_AVATAR }
71- source = { primaryIcon ?. source }
72- name = { primaryIcon ?. name ?? '' }
73- avatarID = { primaryIcon ?. id ?? CONST . DEFAULT_NUMBER_ID }
74- fallbackIcon = { primaryIcon ?. fallbackIcon }
75- fill = { primaryIcon ?. fill }
76- size = { avatarSize }
77- imageStyles = { styles [ singleAvatarStyleKey ] }
78- testID = "ReportActionAvatars-MultipleAvatars-MainAvatar"
79- />
80- </ View >
81- </ UserDetailsTooltip >
56+ < Avatar
57+ type = { primaryIcon ?. type ?? CONST . ICON_TYPE_AVATAR }
58+ source = { primaryIcon ?. source }
59+ name = { primaryIcon ?. name ?? '' }
60+ avatarID = { primaryIcon ?. id ?? CONST . DEFAULT_NUMBER_ID }
61+ fallbackIcon = { primaryIcon ?. fallbackIcon }
62+ fill = { primaryIcon ?. fill }
63+ size = { avatarSize }
64+ imageStyles = { styles [ singleAvatarStyleKey ] }
65+ testID = "ReportActionAvatars-MultipleAvatars-MainAvatar"
66+ />
67+ </ AvatarTooltip >
8268 }
8369 secondary = {
8470 icons . length === 2 ? (
85- < UserDetailsTooltip
86- accountID = { Number ( secondaryIcon ?. id ) }
87- icon = { secondaryIcon }
88- fallbackUserDetails = { {
89- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
90- displayName : fallbackDisplayName || secondaryIcon ?. name ,
91- } }
92- shouldRender = { shouldShowTooltip }
71+ < AvatarTooltip
72+ avatar = { secondaryIcon }
73+ fallbackDisplayName = { fallbackDisplayName }
9374 >
94- < View >
95- < Avatar
96- type = { secondaryIcon ?. type ?? CONST . ICON_TYPE_AVATAR }
97- source = { secondaryIcon ?. source }
98- name = { secondaryIcon ?. name ?? '' }
99- avatarID = { secondaryIcon ?. id ?? CONST . DEFAULT_NUMBER_ID }
100- fallbackIcon = { secondaryIcon ?. fallbackIcon }
101- fill = { secondaryIcon ?. fill }
102- size = { avatarSize }
103- imageStyles = { styles [ singleAvatarStyleKey ] }
104- testID = "ReportActionAvatars-MultipleAvatars-SecondaryAvatar"
105- />
106- </ View >
107- </ UserDetailsTooltip >
75+ < Avatar
76+ type = { secondaryIcon ?. type ?? CONST . ICON_TYPE_AVATAR }
77+ source = { secondaryIcon ?. source }
78+ name = { secondaryIcon ?. name ?? '' }
79+ avatarID = { secondaryIcon ?. id ?? CONST . DEFAULT_NUMBER_ID }
80+ fallbackIcon = { secondaryIcon ?. fallbackIcon }
81+ fill = { secondaryIcon ?. fill }
82+ size = { avatarSize }
83+ imageStyles = { styles [ singleAvatarStyleKey ] }
84+ testID = "ReportActionAvatars-MultipleAvatars-SecondaryAvatar"
85+ />
86+ </ AvatarTooltip >
10887 ) : (
109- < Tooltip
110- text = { tooltipTexts . slice ( 1 ) . join ( ', ' ) }
111- shouldRender = { shouldShowTooltip }
112- >
88+ < AvatarNamesTooltip avatars = { icons . slice ( 1 ) } >
11389 < View
11490 style = { [ styles [ singleAvatarStyleKey ] , styles . alignItemsCenter , styles . justifyContentCenter ] }
11591 testID = "ReportActionAvatars-MultipleAvatars-LimitReached"
@@ -121,7 +97,7 @@ function DiagonalAvatars({size, shouldShowTooltip, icons, isInReportAction, seco
12197 { `+${ icons . length - 1 } ` }
12298 </ Text >
12399 </ View >
124- </ Tooltip >
100+ </ AvatarNamesTooltip >
125101 )
126102 }
127103 />
0 commit comments