Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: grey line SpacerView same padding as green line UnreadActionIndicator #39297

Merged
merged 21 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions src/components/ReportActionItem/MoneyReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import SpacerView from '@components/SpacerView';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
Expand All @@ -29,12 +28,9 @@ type MoneyReportViewProps = {

/** Policy that the report belongs to */
policy: OnyxEntry<Policy>;

/** Whether we should display the horizontal rule below the component */
shouldShowHorizontalRule: boolean;
};

function MoneyReportView({report, policy, shouldShowHorizontalRule}: MoneyReportViewProps) {
function MoneyReportView({report, policy}: MoneyReportViewProps) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -168,10 +164,6 @@ function MoneyReportView({report, policy, shouldShowHorizontalRule}: MoneyReport
</View>
</>
)}
<SpacerView
shouldShow={shouldShowHorizontalRule}
style={[shouldShowHorizontalRule && styles.reportHorizontalRule]}
/>
</>
)}
</View>
Expand Down
9 changes: 0 additions & 9 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import {useSession} from '@components/OnyxProvider';
import {ReceiptAuditHeader, ReceiptAuditMessages} from '@components/ReceiptAudit';
import ReceiptEmptyState from '@components/ReceiptEmptyState';
import SpacerView from '@components/SpacerView';
import Switch from '@components/Switch';
import Text from '@components/Text';
import ViolationMessages from '@components/ViolationMessages';
Expand Down Expand Up @@ -77,9 +76,6 @@ type MoneyRequestViewPropsWithoutTransaction = MoneyRequestViewOnyxPropsWithoutT
/** The report currently being looked at */
report: OnyxTypes.Report;

/** Whether we should display the horizontal rule below the component */
shouldShowHorizontalRule: boolean;

/** Whether we should display the animated banner above the component */
shouldShowAnimatedBackground: boolean;
};
Expand All @@ -91,7 +87,6 @@ function MoneyRequestView({
parentReport,
parentReportActions,
policyCategories,
shouldShowHorizontalRule,
transaction,
policyTagList,
policy,
Expand Down Expand Up @@ -560,10 +555,6 @@ function MoneyRequestView({
</View>
)}
</View>
<SpacerView
shouldShow={shouldShowHorizontalRule}
style={[shouldShowHorizontalRule ? styles.reportHorizontalRule : {}]}
/>
</View>
);
}
Expand Down
10 changes: 1 addition & 9 deletions src/components/ReportActionItem/TaskView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import {usePersonalDetails} from '@components/OnyxProvider';
import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction';
import SpacerView from '@components/SpacerView';
import Text from '@components/Text';
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails';
Expand Down Expand Up @@ -39,12 +38,9 @@ type TaskViewProps = TaskViewOnyxProps &
WithCurrentUserPersonalDetailsProps & {
/** The report currently being looked at */
report: Report;

/** Whether we should display the horizontal rule below the component */
shouldShowHorizontalRule: boolean;
};

function TaskView({report, shouldShowHorizontalRule, ...props}: TaskViewProps) {
function TaskView({report, ...props}: TaskViewProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
useEffect(() => {
Expand Down Expand Up @@ -182,10 +178,6 @@ function TaskView({report, shouldShowHorizontalRule, ...props}: TaskViewProps) {
)}
</OfflineWithFeedback>
</OfflineWithFeedback>
<SpacerView
shouldShow={shouldShowHorizontalRule}
style={shouldShowHorizontalRule && styles.reportHorizontalRule}
/>
</View>
);
}
Expand Down
10 changes: 8 additions & 2 deletions src/components/UnreadActionIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@ import CONST from '@src/CONST';
import Text from './Text';

type UnreadActionIndicatorProps = {
/** The ID of the report action */
reportActionID: string;

/** Whether we should hide thread divider line */
shouldHideThreadDividerLine?: boolean;
dragnoir marked this conversation as resolved.
Show resolved Hide resolved
};

function UnreadActionIndicator({reportActionID}: UnreadActionIndicatorProps) {
function UnreadActionIndicator({reportActionID, shouldHideThreadDividerLine}: UnreadActionIndicatorProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();

const containerStyle = shouldHideThreadDividerLine ? styles.topUnreadIndicatorContainer : styles.unreadIndicatorContainer;

return (
<View
accessibilityLabel={translate('accessibilityHints.newMessageLineIndicator')}
data-action-id={reportActionID}
style={[styles.unreadIndicatorContainer, styles.userSelectNone, styles.pointerEventsNone]}
style={[containerStyle, styles.userSelectNone, styles.pointerEventsNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<View style={styles.unreadIndicatorLine} />
Expand Down
81 changes: 56 additions & 25 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import TaskAction from '@components/ReportActionItem/TaskAction';
import TaskPreview from '@components/ReportActionItem/TaskPreview';
import TaskView from '@components/ReportActionItem/TaskView';
import {ShowContextMenuContext} from '@components/ShowContextMenuContext';
import SpacerView from '@components/SpacerView';
import Text from '@components/Text';
import UnreadActionIndicator from '@components/UnreadActionIndicator';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -151,6 +152,12 @@ type ReportActionItemProps = {

/** Callback to be called on onPress */
onPress?: () => void;

/** If this is the first visible report action */
isFirstVisibleReportAction: boolean;

/** IF the thread divider line will be used */
shouldUseThreadDividerLine?: boolean;
} & ReportActionItemOnyxProps;

const isIOUReport = (actionObj: OnyxEntry<OnyxTypes.ReportAction>): actionObj is OnyxTypes.ReportActionBase & OnyxTypes.OriginalMessageIOU =>
Expand All @@ -175,6 +182,8 @@ function ReportActionItem({
policy,
transaction,
onPress = undefined,
isFirstVisibleReportAction = false,
shouldUseThreadDividerLine = false,
}: ReportActionItemProps) {
const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
Expand Down Expand Up @@ -460,6 +469,22 @@ function ReportActionItem({
];
}, [action, report.reportID]);

const renderThreadDivider = useMemo(
() =>
shouldHideThreadDividerLine ? (
<UnreadActionIndicator
reportActionID={report.reportID}
shouldHideThreadDividerLine={shouldHideThreadDividerLine}
/>
) : (
<SpacerView
shouldShow={!shouldHideThreadDividerLine}
style={[!shouldHideThreadDividerLine ? styles.reportHorizontalRule : {}]}
/>
),
[shouldHideThreadDividerLine, styles.reportHorizontalRule, report.reportID],
);

/**
* Get the content of ReportActionItem
* @param hovered whether the ReportActionItem is hovered
Expand Down Expand Up @@ -765,11 +790,13 @@ function ReportActionItem({
}
return (
<ShowContextMenuContext.Provider value={contextValue}>
<MoneyRequestView
report={report}
shouldShowHorizontalRule={!shouldHideThreadDividerLine}
shouldShowAnimatedBackground
/>
<View>
<MoneyRequestView
report={report}
shouldShowAnimatedBackground
/>
{renderThreadDivider}
</View>
</ShowContextMenuContext.Provider>
);
}
Expand Down Expand Up @@ -797,10 +824,8 @@ function ReportActionItem({
<View>
<AnimatedEmptyStateBackground />
<View style={[StyleUtils.getReportWelcomeTopMarginStyle(isSmallScreenWidth)]}>
<TaskView
report={report}
shouldShowHorizontalRule={!shouldHideThreadDividerLine}
/>
<TaskView report={report} />
{renderThreadDivider}
</View>
</View>
);
Expand All @@ -811,26 +836,32 @@ function ReportActionItem({
{transactionThreadReport && !isEmptyObject(transactionThreadReport) ? (
<>
{transactionCurrency !== report.currency && (
<MoneyReportView
report={report}
policy={policy}
shouldShowHorizontalRule={!shouldHideThreadDividerLine}
/>
<>
<MoneyReportView
report={report}
policy={policy}
/>
{renderThreadDivider}
</>
)}
<ShowContextMenuContext.Provider value={contextValue}>
<MoneyRequestView
report={transactionThreadReport}
shouldShowHorizontalRule={!shouldHideThreadDividerLine}
shouldShowAnimatedBackground={transactionCurrency === report.currency}
/>
<View>
<MoneyRequestView
report={transactionThreadReport}
shouldShowAnimatedBackground={transactionCurrency === report.currency}
/>
{renderThreadDivider}
</View>
</ShowContextMenuContext.Provider>
</>
) : (
<MoneyReportView
report={report}
policy={policy}
shouldShowHorizontalRule={!shouldHideThreadDividerLine}
/>
<>
<MoneyReportView
report={report}
policy={policy}
/>
{renderThreadDivider}
</>
)}
</OfflineWithFeedback>
);
Expand Down Expand Up @@ -907,7 +938,7 @@ function ReportActionItem({
>
{(hovered) => (
<View style={highlightedBackgroundColorIfNeeded}>
{shouldDisplayNewMarker && <UnreadActionIndicator reportActionID={action.reportActionID} />}
{shouldDisplayNewMarker && (!shouldUseThreadDividerLine || !isFirstVisibleReportAction) && <UnreadActionIndicator reportActionID={action.reportActionID} />}
<MiniReportActionContextMenu
reportID={report.reportID}
reportActionID={action.reportActionID}
Expand Down
10 changes: 10 additions & 0 deletions src/pages/home/report/ReportActionItemParentAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ type ReportActionItemParentActionProps = {

/** Whether we should display "Replies" divider */
shouldDisplayReplyDivider: boolean;

/** If this is the first visible report action */
isFirstVisibleReportAction: boolean;

/** If the thread divider line will be used */
shouldUseThreadDividerLine?: boolean;
};

function ReportActionItemParentAction({
Expand All @@ -54,6 +60,8 @@ function ReportActionItemParentAction({
index = 0,
shouldHideThreadDividerLine = false,
shouldDisplayReplyDivider,
isFirstVisibleReportAction = false,
shouldUseThreadDividerLine = false,
}: ReportActionItemParentActionProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -124,6 +132,8 @@ function ReportActionItemParentAction({
isMostRecentIOUReportAction={false}
shouldDisplayNewMarker={ancestor.shouldDisplayNewMarker}
index={index}
isFirstVisibleReportAction={isFirstVisibleReportAction}
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
/>
</OfflineWithFeedback>
))}
Expand Down
24 changes: 24 additions & 0 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ function ReportActionsList({
[sortedReportActions, isOffline, currentUnreadMarker],
);

const firstVisibleReportActionID = useMemo(() => ReportActionsUtils.getFirstVisibleReportActionID(sortedReportActions, isOffline), [sortedReportActions, isOffline]);

/**
* Evaluate new unread marker visibility for each of the report actions.
*/
Expand Down Expand Up @@ -453,6 +455,24 @@ function ReportActionsList({
[currentUnreadMarker, sortedVisibleReportActions, report.reportID, messageManuallyMarkedUnread],
);

const shouldUseThreadDividerLine = useMemo(() => {
const topReport = sortedVisibleReportActions[sortedVisibleReportActions.length - 1];

if (topReport.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED) {
return false;
}

if (ReportActionsUtils.isTransactionThread(parentReportAction)) {
return !ReportActionsUtils.isDeletedParentAction(parentReportAction) && !ReportActionsUtils.isReversedTransaction(parentReportAction);
}

if (ReportUtils.isTaskReport(report)) {
return !ReportUtils.isCanceledTaskReport(report, parentReportAction);
}

return ReportUtils.isExpenseReport(report) || ReportUtils.isIOUReport(report);
}, [parentReportAction, report, sortedVisibleReportActions]);

const calculateUnreadMarker = useCallback(() => {
// Iterate through the report actions and set appropriate unread marker.
// This is to avoid a warning of:
Expand Down Expand Up @@ -538,6 +558,8 @@ function ReportActionsList({
shouldHideThreadDividerLine={shouldHideThreadDividerLine}
shouldDisplayNewMarker={shouldDisplayNewMarker(reportAction, index)}
shouldDisplayReplyDivider={sortedReportActions.length > 1}
isFirstVisibleReportAction={firstVisibleReportActionID === reportAction.reportActionID}
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
/>
),
[
Expand All @@ -552,6 +574,8 @@ function ReportActionsList({
reportActions,
transactionThreadReport,
parentReportActionForTransactionThread,
shouldUseThreadDividerLine,
firstVisibleReportActionID,
],
);

Expand Down
12 changes: 12 additions & 0 deletions src/pages/home/report/ReportActionsListItemRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ type ReportActionsListItemRendererProps = {

/** Whether we should display "Replies" divider */
shouldDisplayReplyDivider: boolean;

/** If this is the first visible report action */
isFirstVisibleReportAction: boolean;

/** If the thread divider line will be used */
shouldUseThreadDividerLine?: boolean;
};

function ReportActionsListItemRenderer({
Expand All @@ -61,6 +67,8 @@ function ReportActionsListItemRenderer({
shouldDisplayNewMarker,
linkedReportActionID = '',
shouldDisplayReplyDivider,
isFirstVisibleReportAction = false,
shouldUseThreadDividerLine = false,
parentReportActionForTransactionThread,
}: ReportActionsListItemRendererProps) {
const shouldDisplayParentAction =
Expand Down Expand Up @@ -144,6 +152,8 @@ function ReportActionsListItemRenderer({
reportActions={reportActions}
transactionThreadReport={transactionThreadReport}
index={index}
isFirstVisibleReportAction={isFirstVisibleReportAction}
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
/>
) : (
<ReportActionItem
Expand All @@ -165,6 +175,8 @@ function ReportActionsListItemRenderer({
}
isMostRecentIOUReportAction={reportAction.reportActionID === mostRecentIOUReportActionID}
index={index}
isFirstVisibleReportAction={isFirstVisibleReportAction}
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
/>
);
}
Expand Down
Loading
Loading