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,36 +133,86 @@ class TransactionTile extends ConsumerWidget {
], ],
), ),
), ),
transaction.currencyCode == 'BYN' Column(
? Row( crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center, children: [
children: [ transaction.currencyCode == 'BYN'
Text( ? Row(
isIncome ? '+ ' : '- ', mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
isIncome ? '+ ' : '- ',
style: Theme.of(context).textTheme.bodyMedium
?.copyWith(
color: color,
fontWeight: FontWeight.w700,
),
),
BynSign(fontSize: 14, color: color),
const SizedBox(width: 2),
Text(
formatAmount('', transaction.amount, fmt),
style: Theme.of(context).textTheme.bodyMedium
?.copyWith(
color: color,
fontWeight: FontWeight.w700,
),
),
],
)
: Text(
'${isIncome ? '+ ' : '- '}${formatAmount(transaction.currency, 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,
), ),
), ),
BynSign(fontSize: 14, color: color), if (showConverted) ...[
const SizedBox(width: 2), if (displayCurrency == 'BYN')
Text( Row(
formatAmount('', transaction.amount, fmt), mainAxisSize: MainAxisSize.min,
style: Theme.of(context).textTheme.bodyMedium?.copyWith( crossAxisAlignment: CrossAxisAlignment.center,
color: color, children: [
fontWeight: FontWeight.w700, 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,
), ),
],
)
: Text(
'${isIncome ? '+ ' : '- '}${formatAmount(transaction.currency, transaction.amount, fmt)}',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: color,
fontWeight: FontWeight.w700,
), ),
), ],
],
),
], ],
), ),
), ),