This commit is contained in:
2026-03-25 01:01:40 +03:00
parent 782c9047f9
commit ceea63812b
2 changed files with 121 additions and 39 deletions
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
@@ -8,6 +9,7 @@ import '../../../core/l10n/locale_provider.dart';
import '../../../shared/models/transaction.dart';
import '../../../shared/providers/amount_format_provider.dart';
import '../../../shared/utils/currency_utils.dart';
import '../provider.dart';
class TransactionTile extends ConsumerWidget {
final Transaction transaction;
@@ -32,6 +34,21 @@ class TransactionTile extends ConsumerWidget {
final catIcon =
AppCategories.icons[transaction.category] ?? Icons.category_rounded;
// Check if we're on Total Balance page
final activeAccount = ref.watch(activeAccountProvider);
// Look up the account name by matching transaction.accountId
final accounts = ref.watch(accountsProvider).valueOrNull ?? [];
final txAccount = accounts.firstWhereOrNull(
(a) => a.id == transaction.accountId,
);
// Build account label with 10-character limit
String accountLabel = txAccount?.name ?? '';
if (accountLabel.length > 10) {
accountLabel = '${accountLabel.substring(0, 10)}...';
}
return GestureDetector(
onTap: () => context.push('/add', extra: transaction),
child: Container(
@@ -56,12 +73,24 @@ class TransactionTile extends ConsumerWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
s.categoryLabel(transaction.category),
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
Row(
children: [
Flexible(
child: Text(
s.categoryLabel(transaction.category),
style: Theme.of(context).textTheme.bodyMedium
?.copyWith(
fontWeight: FontWeight.w600,
color: Theme.of(context).colorScheme.onSurface,
),
overflow: TextOverflow.ellipsis,
),
),
if (activeAccount == null && accountLabel.isNotEmpty) ...[
const SizedBox(width: 6),
_AccountTag(label: accountLabel),
],
],
),
if (transaction.note != null && transaction.note!.isNotEmpty)
Text(
@@ -75,7 +104,10 @@ class TransactionTile extends ConsumerWidget {
)
else
Text(
DateFormat('d MMM yyyy · HH:mm', s.dateLocale).format(transaction.date),
DateFormat(
'd MMM yyyy · HH:mm',
s.dateLocale,
).format(transaction.date),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(
context,
@@ -99,6 +131,44 @@ class TransactionTile extends ConsumerWidget {
}
}
class _AccountTag extends StatelessWidget {
final String label;
const _AccountTag({required this.label});
@override
Widget build(BuildContext context) {
final isDark = Theme.of(context).brightness == Brightness.dark;
return IntrinsicWidth(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 2),
decoration: BoxDecoration(
color: isDark
? Colors.white.withOpacity(0.08)
: const Color(0xFFF0EFFE),
borderRadius: BorderRadius.circular(6),
border: Border.all(
color: isDark
? Colors.white.withOpacity(0.12)
: const Color(0xFFD0CAFF),
width: 1,
),
),
child: Text(
label,
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w500,
color: isDark
? Colors.white.withOpacity(0.55)
: const Color(0xFF7C6DED),
letterSpacing: 0.1,
),
),
),
);
}
}
class EmptyState extends StatelessWidget {
final AppStrings strings;
const EmptyState({super.key, required this.strings});