diff --git a/src/components/ReportActionItem/TaskPreview.tsx b/src/components/ReportActionItem/TaskPreview.tsx index a2ea7487df02..95528286d1e1 100644 --- a/src/components/ReportActionItem/TaskPreview.tsx +++ b/src/components/ReportActionItem/TaskPreview.tsx @@ -1,6 +1,7 @@ import {Str} from 'expensify-common'; import React from 'react'; import {View} from 'react-native'; +import type {StyleProp, ViewStyle} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import Avatar from '@components/Avatar'; @@ -11,6 +12,7 @@ import {usePersonalDetails} from '@components/OnyxProvider'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import RenderHTML from '@components/RenderHTML'; import {showContextMenuForReport} from '@components/ShowContextMenuContext'; +import Text from '@components/Text'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; @@ -53,9 +55,12 @@ type TaskPreviewProps = WithCurrentUserPersonalDetailsProps & { /** Callback for updating context menu active state, used for showing context menu */ checkIfContextMenuActive: () => void; + + /** Style for the task preview container */ + style: StyleProp; }; -function TaskPreview({taskReportID, action, contextMenuAnchor, chatReportID, checkIfContextMenuActive, currentUserPersonalDetails, isHovered = false}: TaskPreviewProps) { +function TaskPreview({taskReportID, action, contextMenuAnchor, chatReportID, checkIfContextMenuActive, currentUserPersonalDetails, isHovered = false, style}: TaskPreviewProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); @@ -70,29 +75,33 @@ function TaskPreview({taskReportID, action, contextMenuAnchor, chatReportID, che : action?.childStateNum === CONST.REPORT.STATE_NUM.APPROVED && action?.childStatusNum === CONST.REPORT.STATUS_NUM.APPROVED; const taskTitle = Str.htmlEncode(TaskUtils.getTaskTitle(taskReportID, action?.childReportName ?? '')); const taskAssigneeAccountID = Task.getTaskAssigneeAccountID(taskReport) ?? action?.childManagerAccountID ?? -1; + const hasAssignee = taskAssigneeAccountID > 0; const personalDetails = usePersonalDetails(); const avatar = personalDetails?.[taskAssigneeAccountID]?.avatar ?? Expensicons.FallbackAvatar; - const htmlForTaskPreview = `${taskTitle}`; + const avatarSize = CONST.AVATAR_SIZE.SMALL; const isDeletedParentAction = ReportUtils.isCanceledTaskReport(taskReport, action); + const iconWrapperStyle = StyleUtils.getTaskPreviewIconWrapper(hasAssignee ? avatarSize : undefined); + const titleStyle = StyleUtils.getTaskPreviewTitleStyle(iconWrapperStyle.height, isTaskCompleted); + const shouldShowGreenDotIndicator = ReportUtils.isOpenTaskReport(taskReport, action) && ReportUtils.isReportManager(taskReport); if (isDeletedParentAction) { return ${translate('parentReportAction.deletedTask')}`} />; } return ( - + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(taskReportID))} onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} onLongPress={(event) => showContextMenuForReport(event, contextMenuAnchor, chatReportID, action, checkIfContextMenuActive)} shouldUseHapticsOnLongPress - style={[styles.flexRow, styles.justifyContentBetween]} + style={[styles.flexRow, styles.justifyContentBetween, style]} role={CONST.ROLE.BUTTON} accessibilityLabel={translate('task.task')} > - - + + - {taskAssigneeAccountID > 0 && ( + {hasAssignee && ( )} - - ${htmlForTaskPreview}` : htmlForTaskPreview} /> - + {taskTitle} {shouldShowGreenDotIndicator && ( @@ -131,6 +138,7 @@ function TaskPreview({taskReportID, action, contextMenuAnchor, chatReportID, che diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 2e7260d2e384..a04a3a4f7bc6 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -568,6 +568,7 @@ function ReportActionItem({ children = ( width: 1, }, - taskCheckboxWrapper: { - height: variables.fontSizeNormalHeight, - ...flex.justifyContentCenter, - }, - taskTitleMenuItem: { ...writingDirection.ltr, ...headlineFont, diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index c7665fc1e3dd..9eeced6de5a6 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1667,6 +1667,17 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ alignItems: 'center', justifyContent: 'center', }), + + getTaskPreviewIconWrapper: (avatarSize?: AvatarSizeName) => ({ + height: avatarSize ? getAvatarSize(avatarSize) : variables.fontSizeNormalHeight, + ...styles.justifyContentCenter, + }), + + getTaskPreviewTitleStyle: (iconHeight: number, isTaskCompleted: boolean): StyleProp => [ + styles.flex1, + isTaskCompleted ? [styles.textSupporting, styles.textLineThrough] : [], + {marginTop: (iconHeight - variables.fontSizeNormalHeight) / 2}, + ], }); type StyleUtilsType = ReturnType;