[Mobile] Click on income category balance to show transactions (#4621)

* [Mobile] Click on income category balance to show transactions

* Release notes
This commit is contained in:
Joel Jeremy Marquez
2025-03-13 10:49:14 -07:00
committed by GitHub
parent 2523c091c3
commit 606e39252f
3 changed files with 61 additions and 32 deletions

View File

@@ -523,6 +523,7 @@ export function IncomeCategoryMonth({
className={css({ className={css({
cursor: 'pointer', cursor: 'pointer',
':hover': { textDecoration: 'underline' }, ':hover': { textDecoration: 'underline' },
...makeAmountGrey(props.value),
})} })}
/> />
)} )}

View File

@@ -1,4 +1,4 @@
import { type ComponentPropsWithoutRef, useRef } from 'react'; import { type ComponentPropsWithoutRef, useCallback, useRef } from 'react';
import { type DragItem } from 'react-aria'; import { type DragItem } from 'react-aria';
import { import {
DropIndicator, DropIndicator,
@@ -22,14 +22,16 @@ import { moveCategory } from 'loot-core/client/queries/queriesSlice';
import * as monthUtils from 'loot-core/shared/months'; import * as monthUtils from 'loot-core/shared/months';
import { type CategoryEntity } from 'loot-core/types/models'; import { type CategoryEntity } from 'loot-core/types/models';
import { useNavigate } from '../../../hooks/useNavigate';
import { useSyncedPref } from '../../../hooks/useSyncedPref'; import { useSyncedPref } from '../../../hooks/useSyncedPref';
import { useDispatch } from '../../../redux'; import { useDispatch } from '../../../redux';
import { makeAmountGrey } from '../../budget/util';
import { PrivacyFilter } from '../../PrivacyFilter'; import { PrivacyFilter } from '../../PrivacyFilter';
import { CellValue } from '../../spreadsheet/CellValue'; import { CellValue } from '../../spreadsheet/CellValue';
import { useFormat } from '../../spreadsheet/useFormat'; import { useFormat } from '../../spreadsheet/useFormat';
import { BudgetCell } from './BudgetCell'; import { BudgetCell } from './BudgetCell';
import { getColumnWidth } from './BudgetTable'; import { getColumnWidth, PILL_STYLE } from './BudgetTable';
type IncomeCategoryListProps = { type IncomeCategoryListProps = {
categories: CategoryEntity[]; categories: CategoryEntity[];
@@ -225,6 +227,11 @@ function IncomeCategoryCells({
? trackingBudget.catSumAmount(category.id) ? trackingBudget.catSumAmount(category.id)
: envelopeBudget.catSumAmount(category.id); : envelopeBudget.catSumAmount(category.id);
const navigate = useNavigate();
const onShowActivity = useCallback(() => {
navigate(`/categories/${category.id}?month=${month}`);
}, [category.id, month, navigate]);
return ( return (
<View <View
style={{ style={{
@@ -250,37 +257,52 @@ function IncomeCategoryCells({
/> />
</View> </View>
)} )}
<CellValue<'envelope-budget' | 'tracking-budget', 'sum-amount'> <View
binding={balance} style={{
type="financial" width: columnWidth,
aria-label={t('Balance for {{categoryName}} category', { justifyContent: 'center',
categoryName: category.name, alignItems: 'flex-end',
})} // Translated aria-label }}
> >
{({ type, value }) => ( <CellValue<'envelope-budget' | 'tracking-budget', 'sum-amount'>
<View> binding={balance}
<PrivacyFilter> type="financial"
<AutoTextSize aria-label={t('Balance for {{categoryName}} category', {
key={value} categoryName: category.name,
as={Text} })} // Translated aria-label
minFontSizePx={6} >
maxFontSizePx={12} {({ type, value }) => (
mode="oneline" <Button
style={{ variant="bare"
width: columnWidth, style={{
justifyContent: 'center', ...PILL_STYLE,
alignItems: 'flex-end', }}
textAlign: 'right', onPress={onShowActivity}
fontSize: 12, aria-label={t('Show transactions for {{categoryName}} category', {
paddingRight: 5, categoryName: category.name,
}} })} // Translated aria-label
> >
{format(value, type)} <PrivacyFilter>
</AutoTextSize> <AutoTextSize
</PrivacyFilter> key={value}
</View> as={Text}
)} minFontSizePx={6}
</CellValue> maxFontSizePx={12}
mode="oneline"
style={{
...makeAmountGrey(value),
maxWidth: columnWidth,
textAlign: 'right',
fontSize: 12,
}}
>
{format(value, type)}
</AutoTextSize>
</PrivacyFilter>
</Button>
)}
</CellValue>
</View>
</View> </View>
); );
} }

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [joel-jeremy]
---
[Mobile] Click on income category balance to show transactions