156 lines
5.9 KiB
Dart
156 lines
5.9 KiB
Dart
import 'package:design_system/design_system.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:sf_shared/sf_shared.dart';
|
|
import 'package:sf_localizations/sf_localizations.dart';
|
|
|
|
class TransactionTile extends ConsumerWidget {
|
|
final WalletTransactionEntity transaction;
|
|
|
|
const TransactionTile({super.key, required this.transaction});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final theme = ref.watch(themePortProvider);
|
|
final color = _color(transaction.transactionType);
|
|
final icon = _icon(transaction.transactionType);
|
|
final label = context.translate(_i18nKey(transaction.transactionType));
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
|
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
|
border: Border(left: BorderSide(color: color, width: 6)),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Icon(icon, color: color, size: 24),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
color: theme.getColorFor(ThemeCode.textPrimary),
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
'${transaction.amount} ${transaction.currency}',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 16,
|
|
color: theme.getColorFor(ThemeCode.textPrimary),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (transaction.name.isNotEmpty) ...[
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
transaction.name,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: theme.getColorFor(ThemeCode.textPrimary),
|
|
),
|
|
),
|
|
],
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
transaction.executionDate,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: theme.getColorFor(ThemeCode.textPrimary),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
static IconData _icon(TransactionType type) => switch (type) {
|
|
TransactionType.payin ||
|
|
TransactionType.payinAcquiring ||
|
|
TransactionType.checkPayin => Icons.arrow_downward,
|
|
TransactionType.payout ||
|
|
TransactionType.payoutSctInstantEmit => Icons.arrow_upward,
|
|
TransactionType.payinRefund ||
|
|
TransactionType.payoutRefund ||
|
|
TransactionType.payinRefundAcquiring ||
|
|
TransactionType.checkRefund => Icons.replay,
|
|
TransactionType.transfer ||
|
|
TransactionType.sctr ||
|
|
TransactionType.sctrInst ||
|
|
TransactionType.creditInternationalTransfer => Icons.swap_horiz,
|
|
TransactionType.cardTransaction => Icons.credit_card,
|
|
TransactionType.sdde || TransactionType.sddr => Icons.account_balance,
|
|
TransactionType.creditTransferReturned ||
|
|
TransactionType.payinSctInstantRecall ||
|
|
TransactionType.payinSctInstantEmitRecall ||
|
|
TransactionType.sctrRecall ||
|
|
TransactionType.sddrReversal => Icons.undo,
|
|
TransactionType.unknown => Icons.help_outline,
|
|
};
|
|
|
|
static Color _color(TransactionType type) => switch (type) {
|
|
TransactionType.payin ||
|
|
TransactionType.payinAcquiring ||
|
|
TransactionType.checkPayin => Colors.green,
|
|
TransactionType.payout ||
|
|
TransactionType.payoutSctInstantEmit => Colors.red,
|
|
TransactionType.payinRefund ||
|
|
TransactionType.payoutRefund ||
|
|
TransactionType.payinRefundAcquiring ||
|
|
TransactionType.checkRefund ||
|
|
TransactionType.creditTransferReturned ||
|
|
TransactionType.payinSctInstantRecall ||
|
|
TransactionType.payinSctInstantEmitRecall ||
|
|
TransactionType.sctrRecall ||
|
|
TransactionType.sddrReversal => Colors.orange,
|
|
TransactionType.transfer ||
|
|
TransactionType.sctr ||
|
|
TransactionType.sctrInst ||
|
|
TransactionType.creditInternationalTransfer ||
|
|
TransactionType.sdde ||
|
|
TransactionType.sddr => Colors.blue,
|
|
TransactionType.cardTransaction => Colors.purple,
|
|
TransactionType.unknown => Colors.grey,
|
|
};
|
|
|
|
static String _i18nKey(TransactionType type) => switch (type) {
|
|
TransactionType.payin => I18n.transactionPayin,
|
|
TransactionType.payout => I18n.transactionPayout,
|
|
TransactionType.transfer => I18n.transactionTransfer,
|
|
TransactionType.payinRefund => I18n.transactionPayinRefund,
|
|
TransactionType.payoutRefund => I18n.transactionPayoutRefund,
|
|
TransactionType.cardTransaction => I18n.transactionCardPayment,
|
|
TransactionType.payinAcquiring => I18n.transactionPayinAcquiring,
|
|
TransactionType.payinRefundAcquiring =>
|
|
I18n.transactionPayinRefundAcquiring,
|
|
TransactionType.sctrInst => I18n.transactionSctrInst,
|
|
TransactionType.payinSctInstantRecall =>
|
|
I18n.transactionPayinSctInstantRecall,
|
|
TransactionType.payoutSctInstantEmit =>
|
|
I18n.transactionPayoutSctInstantEmit,
|
|
TransactionType.payinSctInstantEmitRecall =>
|
|
I18n.transactionPayinSctInstantEmitRecall,
|
|
TransactionType.creditTransferReturned =>
|
|
I18n.transactionCreditTransferReturned,
|
|
TransactionType.checkPayin => I18n.transactionCheckPayin,
|
|
TransactionType.sdde => I18n.transactionSdde,
|
|
TransactionType.sddr => I18n.transactionSddr,
|
|
TransactionType.sddrReversal => I18n.transactionSddrReversal,
|
|
TransactionType.sctrRecall => I18n.transactionSctrRecall,
|
|
TransactionType.checkRefund => I18n.transactionCheckRefund,
|
|
TransactionType.sctr => I18n.transactionSctr,
|
|
TransactionType.creditInternationalTransfer =>
|
|
I18n.transactionCreditInternationalTransfer,
|
|
TransactionType.unknown => I18n.transactionUnknown,
|
|
};
|
|
}
|