Files
sendico/frontend/pweb/lib/pages/dashboard/payouts/summary/widget.dart
2026-02-04 02:01:22 +03:00

55 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pshared/controllers/payment/source.dart';
import 'package:pshared/models/currency.dart';
import 'package:pshared/models/payment/source.dart';
import 'package:pshared/utils/currency.dart';
import 'package:pweb/pages/dashboard/payouts/summary/fee.dart';
import 'package:pweb/pages/dashboard/payouts/summary/recipient_receives.dart';
import 'package:pweb/pages/dashboard/payouts/summary/sent_amount.dart';
import 'package:pweb/pages/dashboard/payouts/summary/total.dart';
class PaymentSummary extends StatelessWidget {
final double spacing;
const PaymentSummary({super.key, required this.spacing});
Currency _currencyForSource(PaymentSource? source) {
if (source == null) return Currency.usdt;
return switch (source.type) {
PaymentSourceType.wallet => source.wallet!.currency,
PaymentSourceType.ledger => () {
final code = source.ledgerAccount?.currency.trim().toUpperCase() ?? '';
try {
return currencyStringToCode(code);
} catch (_) {
return Currency.rub;
}
}(),
};
}
@override
Widget build(BuildContext context) {
final source = context.watch<PaymentSourceController>().selectedSource;
final sentCurrency = _currencyForSource(source);
return Align(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
PaymentSentAmountRow(currency: sentCurrency),
const PaymentFeeRow(),
const PaymentRecipientReceivesRow(),
SizedBox(height: spacing),
const PaymentTotalRow(),
],
),
);
}
}