99 lines
3.1 KiB
Dart
99 lines
3.1 KiB
Dart
import 'dart:math';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:sxchnge_wallet/sxchnge_wallet.dart';
|
|
|
|
import '../destinations/details.dart';
|
|
|
|
import 'copy.dart';
|
|
|
|
import '../generated/i18n/app_localizations.dart';
|
|
|
|
class TransferSummary extends StatelessWidget {
|
|
const TransferSummary({super.key, required this.quote});
|
|
final Quote quote;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final p = context.read<WalletProvider>();
|
|
final l = AppLocalizations.of(context)!;
|
|
final q = quote;
|
|
final a = p.account(q.request.source);
|
|
final b = p.account(q.request.destination) ?? a;
|
|
if (a == null || b == null) return Text(l.wNotFound);
|
|
return Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
_row(
|
|
context,
|
|
q.request.kind == TransferKind.topUp ? l.wYouPay : l.wTotalDebit,
|
|
money(context, a, q.debit),
|
|
large: true,
|
|
),
|
|
const Divider(height: 32),
|
|
_row(context, l.wFee, money(context, a, q.fee)),
|
|
if (q.request.kind == TransferKind.exchange) ...[
|
|
const SizedBox(height: 16),
|
|
_row(
|
|
context,
|
|
l.wRate,
|
|
'1 ${a.currency} = ${NumberFormat('0.0000', Localizations.localeOf(context).toLanguageTag()).format(q.rateNumerator / q.rateDenominator)} ${b.currency}',
|
|
),
|
|
],
|
|
const SizedBox(height: 16),
|
|
_row(
|
|
context,
|
|
q.request.kind == TransferKind.payout
|
|
? l.wRecipientGets
|
|
: l.wCredit,
|
|
q.payoutTerms == null
|
|
? money(context, b, q.credit)
|
|
: '${NumberFormat.decimalPatternDigits(locale: Localizations.localeOf(context).toLanguageTag(), decimalDigits: q.payoutTerms!.precision).format(q.payoutTerms!.amount / pow(10, q.payoutTerms!.precision))} ${q.payoutTerms!.assetLabel}',
|
|
large: true,
|
|
),
|
|
if (q.payoutTerms != null) ...[
|
|
const SizedBox(height: 12),
|
|
Text(l.dTiming(q.payoutTerms!.expectedSeconds)),
|
|
if (p.service.isSimulated) Text(l.dDemoTerms),
|
|
],
|
|
if (q.request.kind == TransferKind.payout) ...[
|
|
const Divider(height: 32),
|
|
Text(l.wRecipient),
|
|
if (q.payoutSnapshot != null)
|
|
DestinationDetailsView(details: q.payoutSnapshot!)
|
|
else
|
|
SelectableText(q.request.recipient),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _row(
|
|
BuildContext context,
|
|
String label,
|
|
String value, {
|
|
bool large = false,
|
|
}) => Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(label),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
value,
|
|
style: large
|
|
? Theme.of(context).textTheme.headlineSmall
|
|
: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
],
|
|
);
|
|
}
|