refactor of money utils with new money2 package
This commit is contained in:
@@ -36,9 +36,7 @@ class PaymentAmountField extends StatelessWidget {
|
||||
decoration: InputDecoration(
|
||||
labelText: loc.amount,
|
||||
border: const OutlineInputBorder(),
|
||||
prefixText: symbol == null
|
||||
? null
|
||||
: withTrailingNonBreakingSpace(symbol),
|
||||
prefixText: symbol == null ? null : '$symbol ',
|
||||
),
|
||||
onChanged: ui.handleChanged,
|
||||
),
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/utils/currency.dart';
|
||||
|
||||
import 'package:pweb/controllers/payouts/multiple_payouts.dart';
|
||||
import 'package:pweb/models/dashboard/summary_values.dart';
|
||||
import 'package:pweb/pages/dashboard/payouts/summary/widget.dart';
|
||||
@@ -28,21 +26,12 @@ class SourceQuoteSummary extends StatelessWidget {
|
||||
values: PaymentSummaryValues(
|
||||
fee: controller.aggregateFeeAmount == null
|
||||
? l10n.noFee
|
||||
: formatMoneyUiWithL10n(
|
||||
l10n,
|
||||
controller.aggregateFeeAmount,
|
||||
separator: nonBreakingSpace,
|
||||
),
|
||||
recipientReceives: formatMoneyUiWithL10n(
|
||||
l10n,
|
||||
: formatMoneyUi(context, controller.aggregateFeeAmount),
|
||||
recipientReceives: formatMoneyUi(
|
||||
context,
|
||||
controller.aggregateSettlementAmount,
|
||||
separator: nonBreakingSpace,
|
||||
),
|
||||
total: formatMoneyUiWithL10n(
|
||||
l10n,
|
||||
controller.aggregateDebitAmount,
|
||||
separator: nonBreakingSpace,
|
||||
),
|
||||
total: formatMoneyUi(context, controller.aggregateDebitAmount),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ class UploadHistorySection extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProxyProvider<PaymentsProvider, RecentPaymentsController>(
|
||||
return ChangeNotifierProxyProvider<
|
||||
PaymentsProvider,
|
||||
RecentPaymentsController
|
||||
>(
|
||||
create: (_) => RecentPaymentsController(),
|
||||
update: (_, payments, controller) => controller!..update(payments),
|
||||
child: const _RecentPaymentsView(),
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:pweb/pages/dashboard/payouts/summary/row.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class PaymentFeeRow extends StatelessWidget {
|
||||
const PaymentFeeRow({super.key});
|
||||
|
||||
@@ -19,7 +18,7 @@ class PaymentFeeRow extends StatelessWidget {
|
||||
final l10 = AppLocalizations.of(context)!;
|
||||
return PaymentSummaryRow(
|
||||
labelFactory: l10.fee,
|
||||
asset: fee,
|
||||
money: fee,
|
||||
value: fee == null ? l10.noFee : null,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
);
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:pweb/pages/dashboard/payouts/summary/row.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class PaymentRecipientReceivesRow extends StatelessWidget {
|
||||
const PaymentRecipientReceivesRow({super.key});
|
||||
|
||||
@@ -16,7 +15,7 @@ class PaymentRecipientReceivesRow extends StatelessWidget {
|
||||
Widget build(BuildContext context) => Consumer<QuotationProvider>(
|
||||
builder: (context, provider, _) => PaymentSummaryRow(
|
||||
labelFactory: AppLocalizations.of(context)!.recipientWillReceive,
|
||||
asset: provider.recipientGets,
|
||||
money: provider.recipientGets,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pshared/models/asset.dart';
|
||||
import 'package:money2/money2.dart';
|
||||
|
||||
import 'package:pweb/utils/money_display.dart';
|
||||
|
||||
|
||||
class PaymentSummaryRow extends StatelessWidget {
|
||||
final String Function(String) labelFactory;
|
||||
final Asset? asset;
|
||||
final Money? money;
|
||||
final String? value;
|
||||
final TextStyle? style;
|
||||
|
||||
const PaymentSummaryRow({
|
||||
super.key,
|
||||
required this.labelFactory,
|
||||
required this.asset,
|
||||
required this.money,
|
||||
this.value,
|
||||
this.style,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final formatted = value ?? formatAssetUi(context, asset);
|
||||
final formatted = value ?? formatMoneyUi(context, money);
|
||||
return Text(labelFactory(formatted), style: style);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:pweb/pages/dashboard/payouts/summary/row.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class PaymentTotalRow extends StatelessWidget {
|
||||
const PaymentTotalRow({super.key});
|
||||
|
||||
@@ -16,8 +15,10 @@ class PaymentTotalRow extends StatelessWidget {
|
||||
Widget build(BuildContext context) => Consumer<QuotationProvider>(
|
||||
builder: (context, provider, _) => PaymentSummaryRow(
|
||||
labelFactory: AppLocalizations.of(context)!.total,
|
||||
asset: provider.total,
|
||||
style: Theme.of(context).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w600),
|
||||
money: provider.total,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleMedium!.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,16 +8,11 @@ import 'package:pweb/pages/dashboard/payouts/summary/total.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class PaymentSummary extends StatelessWidget {
|
||||
final double spacing;
|
||||
final PaymentSummaryValues? values;
|
||||
|
||||
const PaymentSummary({
|
||||
super.key,
|
||||
required this.spacing,
|
||||
this.values,
|
||||
});
|
||||
const PaymentSummary({super.key, required this.spacing, this.values});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -32,20 +27,20 @@ class PaymentSummary extends StatelessWidget {
|
||||
children: [
|
||||
PaymentSummaryRow(
|
||||
labelFactory: loc.fee,
|
||||
asset: null,
|
||||
money: null,
|
||||
value: resolvedValues.fee,
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
PaymentSummaryRow(
|
||||
labelFactory: loc.recipientWillReceive,
|
||||
asset: null,
|
||||
money: null,
|
||||
value: resolvedValues.recipientReceives,
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
SizedBox(height: spacing),
|
||||
PaymentSummaryRow(
|
||||
labelFactory: loc.total,
|
||||
asset: null,
|
||||
money: null,
|
||||
value: resolvedValues.total,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -69,4 +64,4 @@ class PaymentSummary extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user