redisign multiple payouts for better ux and small fixes

This commit is contained in:
Arseni
2026-02-12 18:48:57 +03:00
parent ea68d161d6
commit 45d3c3145c
19 changed files with 226 additions and 262 deletions

View File

@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:pshared/controllers/balance_mask/wallets.dart';
import 'package:pshared/models/payment/wallet.dart';
import 'package:pshared/utils/currency.dart';
import 'package:pweb/generated/i18n/app_localizations.dart';
class SourceWalletSelector extends StatelessWidget {
const SourceWalletSelector({
super.key,
required this.walletsController,
this.isBusy = false,
this.onChanged,
});
final WalletsController walletsController;
final bool isBusy;
final ValueChanged<Wallet>? onChanged;
@override
Widget build(BuildContext context) {
final wallets = walletsController.wallets;
final selectedWalletRef = walletsController.selectedWalletRef;
final theme = Theme.of(context);
final l10n = AppLocalizations.of(context)!;
if (wallets.isEmpty) {
return Text(l10n.noWalletsAvailable, style: theme.textTheme.bodySmall);
}
return DropdownButtonFormField<String>(
initialValue: selectedWalletRef,
isExpanded: true,
decoration: InputDecoration(
labelText: l10n.whereGetMoney,
border: const OutlineInputBorder(),
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 10,
),
),
items: wallets
.map(
(wallet) => DropdownMenuItem<String>(
value: wallet.id,
child: Text(
'${_walletLabel(wallet)} - ${currencyCodeToSymbol(wallet.currency)} ${amountToString(wallet.balance)}',
overflow: TextOverflow.ellipsis,
),
),
)
.toList(growable: false),
onChanged: isBusy
? null
: (value) {
if (value == null) return;
walletsController.selectWalletByRef(value);
final selected = walletsController.selectedWallet;
if (selected != null) {
onChanged?.call(selected);
}
},
);
}
String _walletLabel(Wallet wallet) {
final description = wallet.description?.trim();
if (description != null && description.isNotEmpty) {
return description;
}
final name = wallet.name.trim();
if (name.isNotEmpty && !_looksLikeId(name)) {
return name;
}
final token = wallet.tokenSymbol?.trim();
if (token != null && token.isNotEmpty) {
return '$token wallet';
}
return '${currencyCodeToString(wallet.currency)} wallet';
}
bool _looksLikeId(String value) {
return RegExp(r'^[a-f0-9]{12,}$', caseSensitive: false)
.hasMatch(value);
}
}