WIP: integration with ledger
This commit is contained in:
@@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/controllers/balance_mask/wallets.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';
|
||||
@@ -10,24 +12,43 @@ 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) => Align(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
PaymentSentAmountRow(currency: currencyStringToCode(context.read<WalletsController>().selectedWallet?.tokenSymbol ?? 'USDT')),
|
||||
const PaymentFeeRow(),
|
||||
const PaymentRecipientReceivesRow(),
|
||||
SizedBox(height: spacing),
|
||||
const PaymentTotalRow(),
|
||||
],
|
||||
),
|
||||
);
|
||||
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(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user