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 report total and alignment #42932

Merged
merged 11 commits into from
Jun 4, 2024
12 changes: 8 additions & 4 deletions src/components/SelectionList/Search/ReportListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function ReportListItem<TItem extends ListItem>({
const totalCell = (
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={CurrencyUtils.convertToDisplayString(reportItem?.total, reportItem?.currency)}
text={CurrencyUtils.convertToDisplayString((reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1) * (reportItem?.total ?? 0), reportItem?.currency)}
style={[styles.optionDisplayName, styles.textNewKansasNormal, styles.pre, styles.justifyContentCenter, isLargeScreenWidth ? undefined : styles.textAlignRight]}
/>
);
Expand Down Expand Up @@ -130,7 +130,7 @@ function ReportListItem<TItem extends ListItem>({
onButtonPress={handleOnButtonPress}
/>
)}
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap3]}>
<View style={[styles.flexRow, styles.flex1, styles.alignItemsCenter, styles.justifyContentBetween]}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.flex2]}>
<View style={[styles.flexShrink1]}>
Expand All @@ -140,9 +140,12 @@ function ReportListItem<TItem extends ListItem>({
</View>
<View style={[styles.flexRow, styles.flex1, styles.justifyContentEnd]}>{totalCell}</View>
</View>
{/** styles.reportListItemActionButtonMargin added here to move the action button by the type column distance */}
{isLargeScreenWidth && (
<View style={[StyleUtils.getSearchTableColumnStyles(CONST.SEARCH_TABLE_COLUMNS.ACTION), styles.reportListItemActionButtonMargin]}>{actionCell}</View>
<>
{/** We add an empty view with type style to align the total with the table header */}
<View style={StyleUtils.getSearchTableColumnStyles(CONST.SEARCH_TABLE_COLUMNS.TYPE)} />
<View style={StyleUtils.getSearchTableColumnStyles(CONST.SEARCH_TABLE_COLUMNS.ACTION)}>{actionCell}</View>
</>
)}
</View>
<View style={[styles.mt3, styles.reportListItemSeparator]} />
Expand All @@ -156,6 +159,7 @@ function ReportListItem<TItem extends ListItem>({
showItemHeaderOnNarrowLayout={false}
containerStyle={styles.mt3}
isHovered={hovered}
isChildListItem
/>
))}
</View>
Expand Down
21 changes: 18 additions & 3 deletions src/components/SelectionList/Search/TransactionListItemRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ type ActionCellProps = {
onButtonPress: () => void;
} & CellProps;

type TotalCellProps = {
isChildListItem: boolean;
} & TransactionCellProps;

type TransactionListItemRowProps = {
item: TransactionListItemType;
showTooltip: boolean;
onButtonPress: () => void;
showItemHeaderOnNarrowLayout?: boolean;
containerStyle?: StyleProp<ViewStyle>;
isHovered?: boolean;
isChildListItem?: boolean;
};

const getTypeIcon = (type?: SearchTransactionType) => {
Expand Down Expand Up @@ -112,15 +117,15 @@ function MerchantCell({transactionItem, showTooltip}: TransactionCellProps) {
);
}

function TotalCell({showTooltip, isLargeScreenWidth, transactionItem}: TransactionCellProps) {
function TotalCell({showTooltip, isLargeScreenWidth, transactionItem, isChildListItem}: TotalCellProps) {
const styles = useThemeStyles();
const currency = TransactionUtils.getCurrency(transactionItem);

return (
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={CurrencyUtils.convertToDisplayString(transactionItem.formattedTotal, currency)}
style={[styles.optionDisplayName, styles.textNewKansasNormal, styles.pre, styles.justifyContentCenter, isLargeScreenWidth ? undefined : styles.textAlignRight]}
style={[styles.optionDisplayName, styles.justifyContentCenter, isLargeScreenWidth ? undefined : styles.textAlignRight, isChildListItem ? styles.label : undefined]}
/>
);
}
Expand Down Expand Up @@ -204,7 +209,15 @@ function TaxCell({transactionItem, showTooltip}: TransactionCellProps) {
);
}

function TransactionListItemRow({item, showTooltip, onButtonPress, showItemHeaderOnNarrowLayout = true, containerStyle, isHovered = false}: TransactionListItemRowProps) {
function TransactionListItemRow({
item,
showTooltip,
onButtonPress,
showItemHeaderOnNarrowLayout = true,
containerStyle,
isHovered = false,
isChildListItem = false,
}: TransactionListItemRowProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isLargeScreenWidth} = useWindowDimensions();
Expand Down Expand Up @@ -255,6 +268,7 @@ function TransactionListItemRow({item, showTooltip, onButtonPress, showItemHeade
showTooltip={showTooltip}
transactionItem={item}
isLargeScreenWidth={isLargeScreenWidth}
isChildListItem={isChildListItem}
/>
<View style={[styles.flexRow, styles.gap1, styles.justifyContentCenter]}>
<TypeCell
Expand Down Expand Up @@ -344,6 +358,7 @@ function TransactionListItemRow({item, showTooltip, onButtonPress, showItemHeade
showTooltip={showTooltip}
transactionItem={item}
isLargeScreenWidth={isLargeScreenWidth}
isChildListItem={isChildListItem}
/>
</View>
<View style={[StyleUtils.getSearchTableColumnStyles(CONST.SEARCH_TABLE_COLUMNS.TYPE)]}>
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ export default {
action: 'Acción',
expenses: 'Gastos',
tax: 'Impuesto',
shared: 'Compartido',
shared: 'Compartidos',
drafts: 'Borradores',
finished: 'Finalizado',
finished: 'Finalizados',
},
connectionComplete: {
title: 'Conexión Completa',
Expand Down
4 changes: 0 additions & 4 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4946,10 +4946,6 @@ const styles = (theme: ThemeColors) =>
fontSize: variables.fontSizeNormal,
fontWeight: FontUtils.fontWeight.bold,
},

reportListItemActionButtonMargin: {
marginLeft: variables.searchTypeColumnWidth,
},
} satisfies Styles);

type ThemeStyles = ReturnType<typeof styles>;
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type SearchReport = {
/** The report currency */
currency?: string;

/** The report type */
type?: string;

/** The action that can be performed for the report */
action?: string;
};
Expand Down
Loading