nice overview working

This commit is contained in:
davmar
2026-09-08 23:52:54 +02:00
parent e7a7b1a357
commit 2a741c7f2a
16 changed files with 3512 additions and 810 deletions
+65 -56
View File
@@ -9,6 +9,7 @@ import '../providers/bank_provider.dart';
import '../providers/tx_meta_provider.dart';
import '../utils/helpers.dart';
import '../widgets/responsive_body.dart';
import '../widgets/skip_build_when_covered.dart';
import 'transaction_detail_screen.dart';
class LabelTransactionsScreen extends StatelessWidget {
@@ -20,69 +21,77 @@ class LabelTransactionsScreen extends StatelessWidget {
Widget build(BuildContext context) {
final bank = context.watch<BankController>();
final meta = context.watch<TxMetaController>();
final txs = [
for (final tx in bank.transactions)
if (meta.metaFor(tx).labelIds.contains(label.id)) tx,
];
final theme = Theme.of(context);
final colors = theme.colorScheme;
final currency = bank.balance?.currency ??
(txs.isNotEmpty ? txs.first.currency : 'EUR');
var totalOut = 0.0;
for (final tx in txs) {
if (tx.amount < 0) totalOut += tx.amount.abs();
}
return Scaffold(
appBar: AppBar(
title: Text(label.name),
),
body: ResponsiveBody(
child: ListView(
padding: const EdgeInsets.only(top: 8, bottom: 32),
children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: Icon(label.icon, color: label.color),
title: Text('${txs.length} transactions'),
subtitle: Text('Money out ${formatMoney(totalOut, currency)}'),
),
const Divider(),
if (txs.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(vertical: 32),
child: Text(
'No transactions with this label.',
textAlign: TextAlign.center,
style: theme.textTheme.bodyMedium,
),
)
else
for (final tx in txs)
ListTile(
contentPadding: EdgeInsets.zero,
title: Text(
tx.description,
maxLines: 2,
overflow: TextOverflow.ellipsis,
child: SkipBuildWhenCovered(
builder: (context) {
final txs = [
for (final tx in bank.transactions)
if (meta.labelIdsFor(tx).contains(label.id)) tx,
];
final theme = Theme.of(context);
final colors = theme.colorScheme;
final currency = bank.balance?.currency ??
(txs.isNotEmpty ? txs.first.currency : 'EUR');
var totalOut = 0.0;
for (final tx in txs) {
if (tx.amount < 0) totalOut += tx.amount.abs();
}
return ListView(
padding: const EdgeInsets.only(top: 8, bottom: 32),
children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: Icon(label.icon, color: label.color),
title: Text('${txs.length} transactions'),
subtitle:
Text('Money out ${formatMoney(totalOut, currency)}'),
),
subtitle: Text(formatIsoDate(tx.date)),
trailing: Text(
formatMoney(tx.amount, tx.currency),
style: theme.textTheme.titleSmall?.copyWith(
color: tx.amount >= 0 ? colors.primary : colors.error,
),
),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => TransactionDetailScreen(tx: tx),
const Divider(),
if (txs.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(vertical: 32),
child: Text(
'No transactions with this label.',
textAlign: TextAlign.center,
style: theme.textTheme.bodyMedium,
),
);
},
),
],
),
)
else
for (final tx in txs)
ListTile(
contentPadding: EdgeInsets.zero,
title: Text(
tx.description,
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(formatIsoDate(tx.date)),
trailing: Text(
formatMoney(tx.amount, tx.currency),
style: theme.textTheme.titleSmall?.copyWith(
color: tx.amount >= 0
? colors.primary
: colors.error,
),
),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) =>
TransactionDetailScreen(tx: tx),
),
);
},
),
],
);
},
),
),
);
}