refactoring for recipient addition page

This commit is contained in:
Arseni
2026-01-29 19:22:30 +03:00
parent da8da04ae9
commit efa69b43b2
47 changed files with 1376 additions and 532 deletions

View File

@@ -0,0 +1,26 @@
import 'package:pshared/models/payment/methods/data.dart';
import 'package:pshared/models/payment/type.dart';
const List<PaymentType> enabledPaymentTypes = [
PaymentType.card,
PaymentType.ledger,
PaymentType.externalChain,
];
const List<PaymentType> previewPaymentTypes = [
PaymentType.bankAccount,
];
const List<PaymentType> visiblePaymentTypes = [
...enabledPaymentTypes,
...previewPaymentTypes,
];
const Set<PaymentType> disabledPaymentTypes = {
PaymentType.bankAccount,
};
MethodMap filterVisiblePaymentTypes(MethodMap source) => {
for (final type in visiblePaymentTypes)
if (source.containsKey(type)) type: source[type],
};

View File

@@ -10,12 +10,14 @@ class PaymentTypeSelector extends StatelessWidget {
final MethodMap availableTypes;
final PaymentType selectedType;
final ValueChanged<PaymentType> onSelected;
final Set<PaymentType> disabledTypes;
const PaymentTypeSelector({
super.key,
required this.availableTypes,
required this.selectedType,
required this.onSelected,
this.disabledTypes = const {},
});
static const double _chipSpacing = 12.0;
@@ -30,14 +32,16 @@ class PaymentTypeSelector extends StatelessWidget {
runSpacing: _chipSpacing,
children: availableTypes.keys.map((type) {
final isSelected = selectedType == type;
final isDisabled = disabledTypes.contains(type);
final labelColor = isSelected
? theme.colorScheme.onPrimary
: theme.colorScheme.onSurface.withValues(alpha: isDisabled ? 0.55 : 1.0);
return ChoiceChip(
label: Text(
getPaymentTypeLabel(context, type),
style: theme.textTheme.titleMedium!.copyWith(
color: isSelected
? theme.colorScheme.onPrimary
: theme.colorScheme.onSurface,
color: labelColor,
),
),
selected: isSelected,
@@ -47,7 +51,7 @@ class PaymentTypeSelector extends StatelessWidget {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(_chipBorderRadius),
),
onSelected: (_) => onSelected(type),
onSelected: isDisabled ? null : (_) => onSelected(type),
);
}).toList(),
);