solyanka iz fix for payout page design, ledger wallet now clickable
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import 'package:pshared/models/ledger/account.dart';
|
||||
import 'package:pshared/utils/currency.dart';
|
||||
import 'package:pshared/utils/money.dart';
|
||||
|
||||
|
||||
class LedgerBalanceFormatter {
|
||||
const LedgerBalanceFormatter._();
|
||||
|
||||
static String format(LedgerAccount account) {
|
||||
final money = account.balance?.balance;
|
||||
if (money == null) return '--';
|
||||
|
||||
final amount = parseMoneyAmount(money.amount, fallback: double.nan);
|
||||
if (amount.isNaN) {
|
||||
return '${money.amount} ${money.currency}';
|
||||
}
|
||||
|
||||
try {
|
||||
final currency = currencyStringToCode(money.currency);
|
||||
final symbol = currencyCodeToSymbol(currency);
|
||||
if (symbol.trim().isEmpty) {
|
||||
return '${amountToString(amount)} ${money.currency}';
|
||||
}
|
||||
return '${amountToString(amount)} $symbol';
|
||||
} catch (_) {
|
||||
return '${amountToString(amount)} ${money.currency}';
|
||||
}
|
||||
}
|
||||
|
||||
static String formatMasked(LedgerAccount account) {
|
||||
final currency = account.currency.trim();
|
||||
if (currency.isEmpty) return '••••';
|
||||
|
||||
try {
|
||||
final symbol = currencyCodeToSymbol(currencyStringToCode(currency));
|
||||
if (symbol.trim().isEmpty) {
|
||||
return '•••• $currency';
|
||||
}
|
||||
return '•••• $symbol';
|
||||
} catch (_) {
|
||||
return '•••• $currency';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class LedgerBalanceRow extends StatelessWidget {
|
||||
final String balance;
|
||||
final bool isMasked;
|
||||
final VoidCallback onToggleMask;
|
||||
|
||||
const LedgerBalanceRow({
|
||||
super.key,
|
||||
required this.balance,
|
||||
required this.isMasked,
|
||||
required this.onToggleMask,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
balance,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
GestureDetector(
|
||||
onTap: onToggleMask,
|
||||
child: Icon(
|
||||
isMasked ? Icons.visibility_off : Icons.visibility,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/controllers/balance_mask/ledger_accounts.dart';
|
||||
import 'package:pshared/models/ledger/account.dart';
|
||||
|
||||
import 'package:pweb/pages/payout_page/wallet/edit/fields/ledger/balance_formatter.dart';
|
||||
import 'package:pweb/pages/payout_page/wallet/edit/fields/ledger/balance_row.dart';
|
||||
import 'package:pweb/pages/payout_page/wallet/edit/fields/shared/copyable_value_row.dart';
|
||||
import 'package:pweb/widgets/refresh_balance/ledger.dart';
|
||||
|
||||
|
||||
class LedgerSection extends StatelessWidget {
|
||||
final LedgerAccount ledger;
|
||||
|
||||
const LedgerSection({super.key, required this.ledger});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<LedgerBalanceMaskController>(
|
||||
builder: (context, balanceMask, _) {
|
||||
final isMasked = balanceMask.isBalanceMasked(ledger.ledgerAccountRef);
|
||||
final accountCode = ledger.accountCode.trim();
|
||||
final hasAccountCode = accountCode.isNotEmpty;
|
||||
final balance = isMasked
|
||||
? LedgerBalanceFormatter.formatMasked(ledger)
|
||||
: LedgerBalanceFormatter.format(ledger);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: LedgerBalanceRow(
|
||||
balance: balance,
|
||||
isMasked: isMasked,
|
||||
onToggleMask: () {
|
||||
balanceMask.toggleBalanceMask(ledger.ledgerAccountRef);
|
||||
},
|
||||
),
|
||||
),
|
||||
LedgerBalanceRefreshButton(
|
||||
ledgerAccountRef: ledger.ledgerAccountRef,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CopyableValueRow(
|
||||
value: hasAccountCode ? accountCode : '-',
|
||||
canCopy: hasAccountCode,
|
||||
onCopy: hasAccountCode
|
||||
? () {
|
||||
Clipboard.setData(ClipboardData(text: accountCode));
|
||||
}
|
||||
: null,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
wrapValueWithFlexible: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class CopyableValueRow extends StatelessWidget {
|
||||
final String value;
|
||||
final bool canCopy;
|
||||
final VoidCallback? onCopy;
|
||||
final TextOverflow overflow;
|
||||
final bool wrapValueWithFlexible;
|
||||
|
||||
const CopyableValueRow({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.canCopy,
|
||||
required this.onCopy,
|
||||
this.overflow = TextOverflow.visible,
|
||||
this.wrapValueWithFlexible = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final valueText = Text(
|
||||
value,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
overflow: overflow,
|
||||
);
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if (wrapValueWithFlexible) Flexible(child: valueText) else valueText,
|
||||
IconButton(
|
||||
icon: const Icon(Icons.copy),
|
||||
iconSize: 18,
|
||||
onPressed: canCopy ? onCopy : null,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/controllers/balance_mask/wallets.dart';
|
||||
import 'package:pshared/models/payment/wallet.dart';
|
||||
|
||||
import 'package:pweb/pages/dashboard/buttons/balance/amount.dart';
|
||||
import 'package:pweb/pages/payout_page/wallet/edit/fields/shared/copyable_value_row.dart';
|
||||
import 'package:pweb/widgets/refresh_balance/wallet.dart';
|
||||
|
||||
|
||||
class WalletSection extends StatelessWidget {
|
||||
final Wallet wallet;
|
||||
|
||||
const WalletSection({super.key, required this.wallet});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final depositAddress = wallet.depositAddress?.trim();
|
||||
final hasDepositAddress =
|
||||
depositAddress != null && depositAddress.isNotEmpty;
|
||||
final copyAddress = hasDepositAddress ? depositAddress : '';
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: BalanceAmount(
|
||||
wallet: wallet,
|
||||
onToggleMask: () {
|
||||
context.read<WalletsController>().toggleBalanceMask(
|
||||
wallet.id,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
WalletBalanceRefreshButton(walletRef: wallet.id),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CopyableValueRow(
|
||||
value: hasDepositAddress ? depositAddress : '-',
|
||||
canCopy: hasDepositAddress,
|
||||
onCopy: hasDepositAddress
|
||||
? () {
|
||||
Clipboard.setData(ClipboardData(text: copyAddress));
|
||||
}
|
||||
: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user