After confirming the succes withdrawal
This commit is contained in:
parent
209fc22f89
commit
013ef19ba7
@ -175,6 +175,7 @@ class _TransactionHistoryScreenState extends State<TransactionHistoryScreen> {
|
||||
currency: currency,
|
||||
code: code,
|
||||
amount: _formatAmount(tx.amount, decimals),
|
||||
fee: _formatAmount(tx.fee, decimals),
|
||||
date: _formatDate(tx.createdAt),
|
||||
status: tx.status,
|
||||
);
|
||||
@ -193,6 +194,7 @@ class _TxHistoryTile extends StatelessWidget {
|
||||
required this.currency,
|
||||
required this.code,
|
||||
required this.amount,
|
||||
required this.fee,
|
||||
required this.date,
|
||||
required this.status,
|
||||
});
|
||||
@ -202,6 +204,7 @@ class _TxHistoryTile extends StatelessWidget {
|
||||
final String currency;
|
||||
final String code;
|
||||
final String amount;
|
||||
final String fee;
|
||||
final String date;
|
||||
final String status;
|
||||
|
||||
@ -210,6 +213,9 @@ class _TxHistoryTile extends StatelessWidget {
|
||||
final isTransfer = type == 'transfer';
|
||||
final transferIn = isTransfer && metadata?['direction'] == 'in';
|
||||
final isDeposit = type == 'deposit' || transferIn;
|
||||
final feeValue = double.tryParse(fee) ?? 0;
|
||||
final showFee = type == 'withdrawal' && feeValue > 0;
|
||||
final totalDisplay = showFee ? _addHumanAmounts(amount, fee) : amount;
|
||||
final String titleLabel;
|
||||
if (type == 'withdrawal') {
|
||||
titleLabel = 'Withdrawal';
|
||||
@ -226,9 +232,14 @@ class _TxHistoryTile extends StatelessWidget {
|
||||
'$titleLabel · $currency',
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
subtitle: Text('$date · $status'),
|
||||
subtitle: Text(
|
||||
showFee
|
||||
? '$date · $status\nWithdrawn $amount · Fee $fee'
|
||||
: '$date · $status',
|
||||
),
|
||||
isThreeLine: showFee,
|
||||
trailing: Text(
|
||||
'${isDeposit ? '+' : '-'}$amount',
|
||||
'${isDeposit ? '+' : '-'}$totalDisplay',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isDeposit ? Colors.green : Colors.orange,
|
||||
@ -237,4 +248,17 @@ class _TxHistoryTile extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static String _addHumanAmounts(String a, String b) {
|
||||
try {
|
||||
// amounts are decimal strings from _formatAmount
|
||||
final da = double.parse(a);
|
||||
final db = double.parse(b);
|
||||
final sum = da + db;
|
||||
final s = sum.toStringAsFixed(6).replaceAll(RegExp(r'0+$'), '').replaceAll(RegExp(r'\.$'), '');
|
||||
return s;
|
||||
} catch (_) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -997,13 +997,21 @@ class _StatusTxTile extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final credit = isTransactionCredit(tx);
|
||||
final amount = _formatSignedAmount(
|
||||
tx: tx,
|
||||
credit: credit,
|
||||
hideBalance: hideBalance,
|
||||
decimals: decimals,
|
||||
assetCode: assetCode,
|
||||
);
|
||||
final feeRaw = BigInt.tryParse(tx.fee) ?? BigInt.zero;
|
||||
final showWithdrawalFee = tx.type == 'withdrawal' && feeRaw > BigInt.zero;
|
||||
final amountRaw = BigInt.tryParse(tx.amount) ?? BigInt.zero;
|
||||
final totalRaw = amountRaw + feeRaw;
|
||||
final amount = hideBalance
|
||||
? '••••'
|
||||
: showWithdrawalFee
|
||||
? '-${rawAmountToHuman(totalRaw.toString(), decimals)} USDT'
|
||||
: _formatSignedAmount(
|
||||
tx: tx,
|
||||
credit: credit,
|
||||
hideBalance: hideBalance,
|
||||
decimals: decimals,
|
||||
assetCode: assetCode,
|
||||
);
|
||||
final status = transactionStatusLabel(tx.status, strings);
|
||||
final statusColor = _statusColor(tx.status);
|
||||
final canShare = tx.type == 'deposit' ||
|
||||
@ -1059,6 +1067,16 @@ class _StatusTxTile extends StatelessWidget {
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
if (showWithdrawalFee && !hideBalance) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Withdrawn ${rawAmountToHuman(tx.amount, decimals)} USDT · Fee ${rawAmountToHuman(tx.fee, decimals)} USDT',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: AppColors.textSecondary,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -1073,6 +1091,16 @@ class _StatusTxTile extends StatelessWidget {
|
||||
color: credit ? AppColors.success : AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
if (showWithdrawalFee && !hideBalance) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'Total debited',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: AppColors.textSecondary,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
|
||||
@ -162,6 +162,25 @@ export function TransactionList({
|
||||
const credit = isCredit(tx);
|
||||
const [c1, c2] = coinColors(code);
|
||||
const human = rawToHuman(tx.amount, decimals);
|
||||
const feeRaw = (() => {
|
||||
try {
|
||||
return BigInt(tx.fee || '0');
|
||||
} catch {
|
||||
return 0n;
|
||||
}
|
||||
})();
|
||||
const showWithdrawalFee = tx.type === 'withdrawal' && feeRaw > 0n;
|
||||
const totalRaw = showWithdrawalFee
|
||||
? (() => {
|
||||
try {
|
||||
return (BigInt(tx.amount) + feeRaw).toString();
|
||||
} catch {
|
||||
return tx.amount;
|
||||
}
|
||||
})()
|
||||
: tx.amount;
|
||||
const feeHuman = showWithdrawalFee ? rawToHuman(tx.fee, decimals) : null;
|
||||
const totalHuman = showWithdrawalFee ? rawToHuman(totalRaw, decimals) : human;
|
||||
const predictionShare = predictionShareMeta(tx);
|
||||
const walletShare = walletOpShareMeta(tx);
|
||||
const shareButton = predictionShare ? (
|
||||
@ -202,6 +221,13 @@ export function TransactionList({
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Typography variant="body2">{txLabel(tx)}</Typography>
|
||||
{showWithdrawalFee && (
|
||||
<Typography variant="caption" sx={{ display: 'block', opacity: 0.7, mt: 0.25 }}>
|
||||
{t('wallet.transactions.withdrawalAmount', { amount: `${human} USDT` })}
|
||||
{' · '}
|
||||
{t('wallet.transactions.withdrawalFee', { fee: `${feeHuman} USDT` })}
|
||||
</Typography>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell align="right">
|
||||
<Stack
|
||||
@ -209,16 +235,25 @@ export function TransactionList({
|
||||
spacing={0.5}
|
||||
sx={{ alignItems: 'center', justifyContent: 'flex-end' }}
|
||||
>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
color: credit ? 'success.main' : 'warning.main',
|
||||
}}
|
||||
>
|
||||
{credit ? '+' : '−'}
|
||||
{human}
|
||||
</Typography>
|
||||
<Box sx={{ textAlign: 'right' }}>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{
|
||||
fontWeight: 700,
|
||||
color: credit ? 'success.main' : 'warning.main',
|
||||
}}
|
||||
>
|
||||
{credit ? '+' : '−'}
|
||||
{showWithdrawalFee ? `${totalHuman} USDT` : human}
|
||||
</Typography>
|
||||
{showWithdrawalFee && (
|
||||
<Typography variant="caption" sx={{ display: 'block', opacity: 0.65 }}>
|
||||
{t('wallet.transactions.withdrawalTotal', {
|
||||
total: `${totalHuman} USDT`,
|
||||
})}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
{shareButton}
|
||||
</Stack>
|
||||
</TableCell>
|
||||
|
||||
@ -456,6 +456,9 @@ export const en = {
|
||||
bonus: 'Bonus credit',
|
||||
adminAdjustment: 'Balance adjustment',
|
||||
},
|
||||
withdrawalAmount: 'Withdrawn {{amount}}',
|
||||
withdrawalFee: 'Fee {{fee}}',
|
||||
withdrawalTotal: 'Total debited {{total}}',
|
||||
status: {
|
||||
completed: 'Completed',
|
||||
pending: 'Pending',
|
||||
|
||||
@ -464,6 +464,9 @@ export const fr = {
|
||||
bonus: 'Crédit bonus',
|
||||
adminAdjustment: 'Ajustement de solde',
|
||||
},
|
||||
withdrawalAmount: 'Retiré {{amount}}',
|
||||
withdrawalFee: 'Frais {{fee}}',
|
||||
withdrawalTotal: 'Total débité {{total}}',
|
||||
status: {
|
||||
completed: 'Terminé',
|
||||
pending: 'En attente',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user