From 013ef19ba79448c11b0432af5de344e0a9b76985 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 26 Aug 2026 15:16:19 +0200 Subject: [PATCH] After confirming the succes withdrawal --- .../transaction_history_screen.dart | 28 +++++++++- .../presentation/wallet_overview_screen.dart | 42 +++++++++++--- .../wallet/components/TransactionList.tsx | 55 +++++++++++++++---- prediqo_web/src/shared/i18n/locales/en.ts | 3 + prediqo_web/src/shared/i18n/locales/fr.ts | 3 + 5 files changed, 112 insertions(+), 19 deletions(-) diff --git a/prediqo_mobile/lib/features/wallet/presentation/transaction_history_screen.dart b/prediqo_mobile/lib/features/wallet/presentation/transaction_history_screen.dart index 87b056aa..6cb8a31d 100644 --- a/prediqo_mobile/lib/features/wallet/presentation/transaction_history_screen.dart +++ b/prediqo_mobile/lib/features/wallet/presentation/transaction_history_screen.dart @@ -175,6 +175,7 @@ class _TransactionHistoryScreenState extends State { 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; + } + } } diff --git a/prediqo_mobile/lib/features/wallet/presentation/wallet_overview_screen.dart b/prediqo_mobile/lib/features/wallet/presentation/wallet_overview_screen.dart index d70ac2f4..9e2497c3 100644 --- a/prediqo_mobile/lib/features/wallet/presentation/wallet_overview_screen.dart +++ b/prediqo_mobile/lib/features/wallet/presentation/wallet_overview_screen.dart @@ -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), diff --git a/prediqo_web/src/features/wallet/components/TransactionList.tsx b/prediqo_web/src/features/wallet/components/TransactionList.tsx index 1e88c7f4..00a9fae9 100644 --- a/prediqo_web/src/features/wallet/components/TransactionList.tsx +++ b/prediqo_web/src/features/wallet/components/TransactionList.tsx @@ -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({ {txLabel(tx)} + {showWithdrawalFee && ( + + {t('wallet.transactions.withdrawalAmount', { amount: `${human} USDT` })} + {' · '} + {t('wallet.transactions.withdrawalFee', { fee: `${feeHuman} USDT` })} + + )} - - {credit ? '+' : '−'} - {human} - + + + {credit ? '+' : '−'} + {showWithdrawalFee ? `${totalHuman} USDT` : human} + + {showWithdrawalFee && ( + + {t('wallet.transactions.withdrawalTotal', { + total: `${totalHuman} USDT`, + })} + + )} + {shareButton} diff --git a/prediqo_web/src/shared/i18n/locales/en.ts b/prediqo_web/src/shared/i18n/locales/en.ts index 014e8d1b..9588ef5a 100644 --- a/prediqo_web/src/shared/i18n/locales/en.ts +++ b/prediqo_web/src/shared/i18n/locales/en.ts @@ -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', diff --git a/prediqo_web/src/shared/i18n/locales/fr.ts b/prediqo_web/src/shared/i18n/locales/fr.ts index 7a0e7e62..9257716e 100644 --- a/prediqo_web/src/shared/i18n/locales/fr.ts +++ b/prediqo_web/src/shared/i18n/locales/fr.ts @@ -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',