This commit is contained in:
2026-03-26 01:10:15 +03:00
parent b67dd5b9f6
commit 87431a9fc9
@@ -10,6 +10,7 @@ import '../../../shared/models/transaction.dart';
import '../../../shared/providers/amount_format_provider.dart'; import '../../../shared/providers/amount_format_provider.dart';
import '../../../shared/utils/currency_utils.dart'; import '../../../shared/utils/currency_utils.dart';
import '../../../shared/widgets/byn_sign.dart'; import '../../../shared/widgets/byn_sign.dart';
import '../../settings/provider.dart';
import '../provider.dart'; import '../provider.dart';
class TransactionTile extends ConsumerWidget { class TransactionTile extends ConsumerWidget {
@@ -37,6 +38,20 @@ class TransactionTile extends ConsumerWidget {
// Check if we're on Total Balance page // Check if we're on Total Balance page
final activeAccount = ref.watch(activeAccountProvider); final activeAccount = ref.watch(activeAccountProvider);
final displayCurrency = activeAccount?.currency ??
ref.watch(currencyProvider).code;
final showConverted =
transaction.currencyCode != displayCurrency;
final exchangeService = ref.watch(exchangeRateServiceProvider);
final convertedAmount = showConverted
? exchangeService.convert(
transaction.amount,
transaction.currencyCode,
displayCurrency,
)
: 0.0;
final displaySymbol =
currencyMap[displayCurrency]?.symbol ?? '';
// Look up the account name by matching transaction.accountId // Look up the account name by matching transaction.accountId
final accounts = ref.watch(accountsProvider).valueOrNull ?? []; final accounts = ref.watch(accountsProvider).valueOrNull ?? [];
@@ -118,6 +133,10 @@ class TransactionTile extends ConsumerWidget {
], ],
), ),
), ),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
transaction.currencyCode == 'BYN' transaction.currencyCode == 'BYN'
? Row( ? Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -125,7 +144,8 @@ class TransactionTile extends ConsumerWidget {
children: [ children: [
Text( Text(
isIncome ? '+ ' : '- ', isIncome ? '+ ' : '- ',
style: Theme.of(context).textTheme.bodyMedium?.copyWith( style: Theme.of(context).textTheme.bodyMedium
?.copyWith(
color: color, color: color,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
), ),
@@ -134,7 +154,8 @@ class TransactionTile extends ConsumerWidget {
const SizedBox(width: 2), const SizedBox(width: 2),
Text( Text(
formatAmount('', transaction.amount, fmt), formatAmount('', transaction.amount, fmt),
style: Theme.of(context).textTheme.bodyMedium?.copyWith( style: Theme.of(context).textTheme.bodyMedium
?.copyWith(
color: color, color: color,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
), ),
@@ -148,6 +169,50 @@ class TransactionTile extends ConsumerWidget {
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
), ),
), ),
if (showConverted) ...[
if (displayCurrency == 'BYN')
Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'',
style: TextStyle(
fontSize: 11,
color: color.withOpacity(0.5),
fontWeight: FontWeight.w400,
height: 1.3,
),
),
BynSign(
fontSize: 11,
color: color.withOpacity(0.5),
),
const SizedBox(width: 2),
Text(
formatAmount('', convertedAmount, fmt),
style: TextStyle(
fontSize: 11,
color: color.withOpacity(0.5),
fontWeight: FontWeight.w400,
height: 1.3,
),
),
],
)
else
Text(
'${formatAmount(displaySymbol, convertedAmount, fmt)}',
style: TextStyle(
fontSize: 11,
color: color.withOpacity(0.5),
fontWeight: FontWeight.w400,
height: 1.3,
),
),
],
],
),
], ],
), ),
), ),